pendrag commited on
Commit
951e11b
·
1 Parent(s): 182ca97

expansion fixed

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -76,22 +76,21 @@ def llm_expand_query(query):
76
 
77
 
78
  prompt = f"""
79
- Expand this query into a the query format used for a fulltext search
80
  over the INSPIRE HEP database. Propose alternatives of the query to
81
- maximize the recall and join those variantes using OR operators and
82
- prepend each variant with the ft prefix. Just provide the expanded
83
- query, without explanations.
84
 
85
  Example of query:
86
  how far are black holes?
87
 
88
  Expanded query:
89
- ft "how far are black holes" OR ft "distance from black holes" OR ft
90
- "distances to black holes" OR ft "measurement of distance to black
91
- holes" OR ft "remoteness of black holes" OR ft "distance to black
92
- holes" OR ft "how far are singularities" OR ft "distance to
93
- singularities" OR ft "distances to event horizon" OR ft "distance
94
- from Schwarzschild radius" OR ft "black hole distance"
95
 
96
  Query: {query}
97
 
@@ -213,9 +212,9 @@ def clean_refs(answer, results):
213
  def search(query, progress=gr.Progress()):
214
  time.sleep(1)
215
  progress(0, desc="Expanding query...")
216
- query = llm_expand_query(query)
217
  progress(0.25, desc="Searching INSPIRE HEP...")
218
- results = search_inspire(query)
219
  progress(0.50, desc="Generating answer...")
220
  context = results_context(results)
221
  prompt = user_prompt(query, context)
@@ -244,6 +243,7 @@ with gr.Blocks() as demo:
244
  search_btn = gr.Button("Search")
245
  examples = gr.Examples([["Which one is closest star?"], ["In which particles does the Higgs Boson decay to?"]], query)
246
  gr.HTML("<img src='https://sinai.ujaen.es/sites/default/files/SINAI%20-%20logo%20tx%20azul%20%5Baf%5D.png' width='200'></img>")
 
247
  with gr.Column():
248
  results = gr.Markdown("Answer will appear here...", label="Search Results", )
249
  search_btn.click(fn=search, inputs=query, outputs=results, api_name="search", show_progress=True)
 
76
 
77
 
78
  prompt = f"""
79
+ Expand this query into a the query format used for a search
80
  over the INSPIRE HEP database. Propose alternatives of the query to
81
+ maximize the recall and join those variantes using OR operators.
82
+ Just provide the expanded query, without explanations.
 
83
 
84
  Example of query:
85
  how far are black holes?
86
 
87
  Expanded query:
88
+ "how far are black holes" OR "distance from black holes" OR
89
+ "distances to black holes" OR "measurement of distance to black
90
+ holes" OR "remoteness of black holes" OR "distance to black
91
+ holes" OR "how far are singularities" OR "distance to
92
+ singularities" OR "distances to event horizon" OR "distance
93
+ from Schwarzschild radius" OR "black hole distance"
94
 
95
  Query: {query}
96
 
 
212
  def search(query, progress=gr.Progress()):
213
  time.sleep(1)
214
  progress(0, desc="Expanding query...")
215
+ expanded_query = llm_expand_query(query)
216
  progress(0.25, desc="Searching INSPIRE HEP...")
217
+ results = search_inspire(expanded_query)
218
  progress(0.50, desc="Generating answer...")
219
  context = results_context(results)
220
  prompt = user_prompt(query, context)
 
243
  search_btn = gr.Button("Search")
244
  examples = gr.Examples([["Which one is closest star?"], ["In which particles does the Higgs Boson decay to?"]], query)
245
  gr.HTML("<img src='https://sinai.ujaen.es/sites/default/files/SINAI%20-%20logo%20tx%20azul%20%5Baf%5D.png' width='200'></img>")
246
+ gr.HTML("<img src='https://diariodigital.ujaen.es/sites/default/files/general/logo-uja.svg' width='200'></img>")
247
  with gr.Column():
248
  results = gr.Markdown("Answer will appear here...", label="Search Results", )
249
  search_btn.click(fn=search, inputs=query, outputs=results, api_name="search", show_progress=True)