Ritesh-hf commited on
Commit
2ea940a
1 Parent(s): 26c88d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -86,9 +86,14 @@ retriever = PineconeHybridSearchRetriever(
86
  llm = ChatPerplexity(temperature=0, pplx_api_key=GROQ_API_KEY, model="llama-3.1-sonar-large-128k-chat", max_tokens=512, max_retries=2)
87
 
88
  # Initialize Reranker
89
- from langchain.retrievers.document_compressors import FlashrankRerank
 
 
 
 
 
 
90
 
91
- compressor = FlashrankRerank(model="ms-marco-MultiBERT-L-12", score_threshold=0.6)
92
  compression_retriever = ContextualCompressionRetriever(
93
  base_compressor=compressor, base_retriever=retriever
94
  )
@@ -98,7 +103,7 @@ compression_retriever = ContextualCompressionRetriever(
98
  )
99
 
100
  # Contextualization prompt and retriever
101
- contextualize_q_system_prompt = """Given a chat history and the latest user question \
102
  which might reference context in the chat history, formulate a standalone question \
103
  which can be understood without the chat history. Do NOT answer the question, \
104
  just reformulate it if needed and otherwise return it as is.
 
86
  llm = ChatPerplexity(temperature=0, pplx_api_key=GROQ_API_KEY, model="llama-3.1-sonar-large-128k-chat", max_tokens=512, max_retries=2)
87
 
88
  # Initialize Reranker
89
+ # from langchain.retrievers.document_compressors import FlashrankRerank
90
+
91
+ # compressor = FlashrankRerank(model="ms-marco-MultiBERT-L-12", score_threshold=0.6)
92
+
93
+ from langchain_community.document_compressors.rankllm_rerank import RankLLMRerank
94
+
95
+ compressor = RankLLMRerank(top_n=6, model="zephyr")
96
 
 
97
  compression_retriever = ContextualCompressionRetriever(
98
  base_compressor=compressor, base_retriever=retriever
99
  )
 
103
  )
104
 
105
  # Contextualization prompt and retriever
106
+ contextualize_q_system_prompt = """ Given a chat history and the latest user question \
107
  which might reference context in the chat history, formulate a standalone question \
108
  which can be understood without the chat history. Do NOT answer the question, \
109
  just reformulate it if needed and otherwise return it as is.