singhankur01 commited on
Commit
866c970
·
verified ·
1 Parent(s): 8281c67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -107,14 +107,15 @@ async def lifespan(app: FastAPI):
107
  ml_models["prompt_template"] = ChatPromptTemplate.from_template("""
108
  **Role**: You are an expert assistant in insurance, legal compliance, human resources, and contract management.
109
  Your job is to answer using ONLY the provided context, in a way that feels natural, clear, and helpful — as if speaking to a client.
110
- Do not invent or assume information that is not explicitly stated in the context. Do not use line breaks between the statements of the response.
111
- If the answer is not found in the context, politely state that You do not know the answer.
112
 
113
  **Tone & Style**:
114
  - Be professional yet approachable.
115
  - Use complete sentences and natural phrasing.
116
  - Avoid legal jargon unless it is in the context.
117
  - Keep answers concise but complete.
 
118
 
119
  **Context**:
120
  {context}
@@ -234,7 +235,7 @@ async def run_hackrx(req: RunRequest):
234
  keyword_retriever = BM25Retriever.from_documents(chunks)
235
  keyword_retriever.k = 8
236
  # dense_retriever = Chroma.from_documents(documents=chunks, embedding=ml_models["embedder"]).as_retriever()
237
- ensemble_retriever = EnsembleRetriever(retrievers=[keyword_retriever, dense_retriever], weights=[0.6, 0.4],search_kwargs={"k": 11})
238
  ### to make it faster we are now using our built reranker thats why commenting the code below
239
  # compression_retriever = ContextualCompressionRetriever(
240
  # base_retriever=ensemble_retriever, base_compressor=ml_models["reranker_compressor"]
 
107
  ml_models["prompt_template"] = ChatPromptTemplate.from_template("""
108
  **Role**: You are an expert assistant in insurance, legal compliance, human resources, and contract management.
109
  Your job is to answer using ONLY the provided context, in a way that feels natural, clear, and helpful — as if speaking to a client.
110
+ Do not invent or assume information that is not explicitly stated in the context just say. Do not use line breaks between the statements of the response.
111
+ If the answer is not found in the context, politely state that Please ask query related to the Document only.
112
 
113
  **Tone & Style**:
114
  - Be professional yet approachable.
115
  - Use complete sentences and natural phrasing.
116
  - Avoid legal jargon unless it is in the context.
117
  - Keep answers concise but complete.
118
+ - do not make it unnecessary lengthy.
119
 
120
  **Context**:
121
  {context}
 
235
  keyword_retriever = BM25Retriever.from_documents(chunks)
236
  keyword_retriever.k = 8
237
  # dense_retriever = Chroma.from_documents(documents=chunks, embedding=ml_models["embedder"]).as_retriever()
238
+ ensemble_retriever = EnsembleRetriever(retrievers=[keyword_retriever, dense_retriever], weights=[0.35, 0.65],search_kwargs={"k": 11})
239
  ### to make it faster we are now using our built reranker thats why commenting the code below
240
  # compression_retriever = ContextualCompressionRetriever(
241
  # base_retriever=ensemble_retriever, base_compressor=ml_models["reranker_compressor"]