jenngang commited on
Commit
9cab537
·
verified ·
1 Parent(s): 30ed58e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -116,8 +116,7 @@ def expand_query(state):
116
  Dict: The updated state with the expanded query.
117
  """
118
  print("---------Expanding Query---------")
119
- system_message = # ________________________
120
- '''
121
  You are a domain expert assisting in answering questions related to research papers.
122
  Convert the user query into something that a nutritionist would understand. Use domain related words.
123
  Return 3 related search queries based on the user's request seperated by newline.
@@ -200,8 +199,7 @@ def craft_response(state: Dict) -> Dict:
200
  Dict: The updated state with the generated response.
201
  """
202
  print("---------craft_response---------")
203
- system_message = # ________________________
204
- '''
205
  Generates a response to a user query and context provided.
206
 
207
  Parameters:
@@ -250,10 +248,9 @@ def score_groundedness(state: Dict) -> Dict:
250
  Dict: The updated state with the groundedness score.
251
  """
252
  print("---------check_groundedness---------")
253
- system_message = # ________________________
254
- '''
255
  You are tasked with rating AI generated answers to questions posed by users.
256
- Please act as an impartial judge and evaluate the quality of the provided answer which attempts to answer the provided question based on a provided context.
257
  In the input, the context is {context}, while the AI generated response is {response}.
258
 
259
  Evaluation criteria:
@@ -300,11 +297,10 @@ def check_precision(state: Dict) -> Dict:
300
  Dict: The updated state with the precision score.
301
  """
302
  print("---------check_precision---------")
303
- system_message = # ________________________
304
- '''
305
  Given question, answer and context verify if the context was useful in arriving at the given answer.
306
  Give verdict as "1" if useful and "0" if not useful.
307
- Output your result as a float number between 0 and 1
308
  Give verdict as a scaled numeric value of type float between 0 and 1, such that
309
  0 or near 0 if it is least useful, 0.5 or near 0.5 if retry is warranted, and 1 or close to 1 is most useful.
310
  Do not show any instructions for deriving your answer.
@@ -338,9 +334,8 @@ def refine_response(state: Dict) -> Dict:
338
  """
339
  print("---------refine_response---------")
340
 
341
- system_message = # ________________________
342
- '''
343
- Since the last response failded the groundedness test, and is deemed not satisfactory,
344
  use the feedback in terms of the query, context and the last response
345
  to identify potential gaps, ambiguities, or missing details, and
346
  to suggest improvements to enhance accuracy and completeness of the response.
@@ -374,9 +369,8 @@ def refine_query(state: Dict) -> Dict:
374
  Dict: The updated state with query refinement suggestions.
375
  """
376
  print("---------refine_query---------")
377
- system_message = # ________________________
378
- '''
379
- Since the last response failded the precision test, and is deemed not satisfactory,
380
  use the feedback in terms of the query, context and re-generate extended queries
381
  to identify specific keywords, scope refinements, or missing details, and
382
  to provides structured suggestions for improvement to enhance accuracy and completeness of the response.
 
116
  Dict: The updated state with the expanded query.
117
  """
118
  print("---------Expanding Query---------")
119
+ system_message = '''
 
120
  You are a domain expert assisting in answering questions related to research papers.
121
  Convert the user query into something that a nutritionist would understand. Use domain related words.
122
  Return 3 related search queries based on the user's request seperated by newline.
 
199
  Dict: The updated state with the generated response.
200
  """
201
  print("---------craft_response---------")
202
+ system_message = '''
 
203
  Generates a response to a user query and context provided.
204
 
205
  Parameters:
 
248
  Dict: The updated state with the groundedness score.
249
  """
250
  print("---------check_groundedness---------")
251
+ system_message = '''
 
252
  You are tasked with rating AI generated answers to questions posed by users.
253
+ Please act as an impartial judge and evaluate the quality of the provided answer which attempts to answer the provided question based on a provided context.
254
  In the input, the context is {context}, while the AI generated response is {response}.
255
 
256
  Evaluation criteria:
 
297
  Dict: The updated state with the precision score.
298
  """
299
  print("---------check_precision---------")
300
+ system_message = '''
 
301
  Given question, answer and context verify if the context was useful in arriving at the given answer.
302
  Give verdict as "1" if useful and "0" if not useful.
303
+ Output your result as a float number between 0 and 1
304
  Give verdict as a scaled numeric value of type float between 0 and 1, such that
305
  0 or near 0 if it is least useful, 0.5 or near 0.5 if retry is warranted, and 1 or close to 1 is most useful.
306
  Do not show any instructions for deriving your answer.
 
334
  """
335
  print("---------refine_response---------")
336
 
337
+ system_message = '''
338
+ Since the last response failded the groundedness test, and is deemed not satisfactory,
 
339
  use the feedback in terms of the query, context and the last response
340
  to identify potential gaps, ambiguities, or missing details, and
341
  to suggest improvements to enhance accuracy and completeness of the response.
 
369
  Dict: The updated state with query refinement suggestions.
370
  """
371
  print("---------refine_query---------")
372
+ system_message = '''
373
+ Since the last response failded the precision test, and is deemed not satisfactory,
 
374
  use the feedback in terms of the query, context and re-generate extended queries
375
  to identify specific keywords, scope refinements, or missing details, and
376
  to provides structured suggestions for improvement to enhance accuracy and completeness of the response.