Skip to content

Combine ParentdocumentRetriever with Reranking: Rerank retrieved child chunks #21966

Discussion options

You must be logged in to vote

Hi thanks for your suggestion! I was able to resolve it with modifying the MultiVectorRetriever (multi_vector.py). I added the function "get_matching_reranked_docs" which is returning the right order of the reranked results as Langchain Document with the "score" key in metadata. In "_get_relevant_documents" I implemented the reranking changes.

Here is the full code that works for me:

from enum import Enum
from typing import Dict, List, Optional

from langchain_core.callbacks import (
    AsyncCallbackManagerForRetrieverRun,
    CallbackManagerForRetrieverRun,
)
from langchain_core.documents import Document
from langchain_core.pydantic_v1 import Field, root_validator
from langchain_core.re…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@weissenbacherpwc
Comment options

Comment options

You must be logged in to vote
3 replies
@weissenbacherpwc
Comment options

Answer selected by weissenbacherpwc
@maximeperrindev
Comment options

@weissenbacherpwc
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants