Ritesh-hf commited on
Commit
c6124d7
·
verified ·
1 Parent(s): 6bc333e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -82,6 +82,12 @@ retriever = PineconeHybridSearchRetriever(
82
  # llm = ChatGroq(model="llama-3.1-70b-versatile", temperature=0, max_tokens=1024, max_retries=2)
83
  llm = ChatPerplexity(temperature=0, pplx_api_key=GROQ_API_KEY, model="llama-3.1-sonar-large-128k-online", max_tokens=1024, max_retries=2)
84
 
 
 
 
 
 
 
85
  # Contextualization prompt and retriever
86
  contextualize_q_system_prompt = """Given a chat history and the latest user question \
87
  which might reference context in the chat history, formulate a standalone question \
@@ -95,7 +101,7 @@ contextualize_q_prompt = ChatPromptTemplate.from_messages(
95
  ("human", "{input}")
96
  ]
97
  )
98
- history_aware_retriever = create_history_aware_retriever(llm, retriever, contextualize_q_prompt)
99
 
100
  # QA system prompt and chain
101
  qa_system_prompt = """You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively. \
 
82
  # llm = ChatGroq(model="llama-3.1-70b-versatile", temperature=0, max_tokens=1024, max_retries=2)
83
  llm = ChatPerplexity(temperature=0, pplx_api_key=GROQ_API_KEY, model="llama-3.1-sonar-large-128k-online", max_tokens=1024, max_retries=2)
84
 
85
+ # Initialize Reranker
86
+ compressor = FlashrankRerank()
87
+ compression_retriever = ContextualCompressionRetriever(
88
+ base_compressor=compressor, base_retriever=retriever
89
+ )
90
+
91
  # Contextualization prompt and retriever
92
  contextualize_q_system_prompt = """Given a chat history and the latest user question \
93
  which might reference context in the chat history, formulate a standalone question \
 
101
  ("human", "{input}")
102
  ]
103
  )
104
+ history_aware_retriever = create_history_aware_retriever(llm, compression_retriever, contextualize_q_prompt)
105
 
106
  # QA system prompt and chain
107
  qa_system_prompt = """You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively. \