singhankur01 commited on
Commit
e75019f
·
verified ·
1 Parent(s): a0ff14a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -48,8 +48,8 @@ async def lifespan(app: FastAPI):
48
 
49
  # Load models into the shared dictionary
50
  ml_models["embedder"] = HuggingFaceEmbeddings(model_name="BAAI/bge-base-en-v1.5")
51
- # cross_encoder_model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-base")
52
- cross_encoder_model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-large")
53
  ml_models["reranker_compressor"] = CrossEncoderReranker(model=cross_encoder_model, top_n=5)
54
  ml_models["llm"] = ChatGoogleGenerativeAI(model="gemini-1.5-flash", api_key=GOOGLE_API_KEY)
55
  ml_models["prompt_template"] = PromptTemplate.from_template(
@@ -63,6 +63,10 @@ If not, the raw question is provided instead:
63
  We retrieved the following policy clauses and rules relevant to this case:
64
  {context}
65
 
 
 
 
 
66
  ### Task:
67
  If the details about age , gender , procedure , location , policy duration are available, do all of the following:
68
  1. Decide whether the procedure is covered.
@@ -70,7 +74,7 @@ If the details about age , gender , procedure , location , policy duration are a
70
  3. Justify with the relevant clause.
71
  and answer the query precisely as insurance agent.
72
 
73
- Otherwise, answer the question concisely and clearly using the retrieved context.
74
 
75
  ### Output format:
76
  If query involes age , gender , procedure , location , policy duration answer like below:
@@ -78,16 +82,14 @@ If query involes age , gender , procedure , location , policy duration answer li
78
  "decision": "approved / rejected",
79
  "amount": "INR amount or null",
80
  "justification": "Refer to specific clause"
81
- Make it a perfect and concise.
82
  }}
83
  Else:
84
  {{
85
  "response": "Concise natural language answer"
86
- Make it a perfect and concise.
87
  }}
88
-
89
- ##NOTE : Do not mention document id or its page number just mention clauses if applicable .
90
- """
91
  )
92
  print("✅ Models and prompt loaded successfully!")
93
  except Exception as e:
 
48
 
49
  # Load models into the shared dictionary
50
  ml_models["embedder"] = HuggingFaceEmbeddings(model_name="BAAI/bge-base-en-v1.5")
51
+ cross_encoder_model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-base")
52
+ # cross_encoder_model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-large")
53
  ml_models["reranker_compressor"] = CrossEncoderReranker(model=cross_encoder_model, top_n=5)
54
  ml_models["llm"] = ChatGoogleGenerativeAI(model="gemini-1.5-flash", api_key=GOOGLE_API_KEY)
55
  ml_models["prompt_template"] = PromptTemplate.from_template(
 
63
  We retrieved the following policy clauses and rules relevant to this case:
64
  {context}
65
 
66
+ Remember the below three points while answering or responsing the query :
67
+ 1:Do not mention document id or its page number just ,mention clauses if applicable .
68
+ 2:Do not make such statement in the response that you need more document or information to answer the query, just answer from retrieved data.
69
+ 3:UNDERSTAND THE QUERY ASKED SMARTLY AND ANSWER IT.
70
  ### Task:
71
  If the details about age , gender , procedure , location , policy duration are available, do all of the following:
72
  1. Decide whether the procedure is covered.
 
74
  3. Justify with the relevant clause.
75
  and answer the query precisely as insurance agent.
76
 
77
+ Otherwise, answer the question concisely , relevently and clearly using the retrieved context.
78
 
79
  ### Output format:
80
  If query involes age , gender , procedure , location , policy duration answer like below:
 
82
  "decision": "approved / rejected",
83
  "amount": "INR amount or null",
84
  "justification": "Refer to specific clause"
85
+ Make it concise ,perfect, relevent and clear .
86
  }}
87
  Else:
88
  {{
89
  "response": "Concise natural language answer"
90
+ Make it concise ,perfect, relevent and clear .
91
  }}
92
+ """
 
 
93
  )
94
  print("✅ Models and prompt loaded successfully!")
95
  except Exception as e: