Open kikiWhite opened 1 month ago
@kikiWhite Thanks for the feedback. Please check the step 3.1 in the notebook where reranker is added as part of contextual compression retriever.
from langchain.retrievers.contextual_compression import ContextualCompressionRetriever
from langchain_google_community import VertexAIRank
# Instantiate the VertexAIReranker with the SDK manager
reranker = VertexAIRank(
project_id=PROJECT_ID,
location_id="global",
ranking_config="default_ranking_config",
title_field="source", # metadata field to preserve with reranked results
top_n=5,
)
basic_retriever = vector_store.as_retriever(
search_kwargs={"k": 5}
) # fetch top 5 documents
# Create the ContextualCompressionRetriever with the VertexAIRanker as a Reranker
retriever_with_reranker = ContextualCompressionRetriever(
base_compressor=reranker, base_retriever=basic_retriever
)
Does that help?
@RajeshThallam Thank you, Rajesh. Everything is clear now. I understand the use of the contextual compression retriever in step 3.1. I just wanted to kindly point out that step 4 mentioned the use of VertexAIRank, but it wasn't actually used in that step. Just wanted to bring it to your attention. Thanks again for your help!
In the part
Step 4. Query in Real Time and Check Grounding
ofgenai-on-vertex-ai/retrieval_augmented_generation/diy_rag_with_vertexai_apis/build_grounded_rag_app_with_vertex.ipynb
The notebook mentioned that this step will "pass retrieved documents to the reranker API via the
VertexAIRank
" But I only saw the usage ofVertexAI
class and a basic retriever with the following code:I feel a bit confused. If I am wrong or I miss something, please correct me! Thank you for your attention to this matter : )