ruisp commited on
Commit
42a39da
1 Parent(s): 170359e

Some frontend cosmetics and refactoring.

Browse files
Files changed (2) hide show
  1. filterminutes.py +3 -3
  2. public_app.py +3 -3
filterminutes.py CHANGED
@@ -67,15 +67,15 @@ def search_with_filter(vector_store, query, filter_dict, target_k=5, init_k=100,
67
  if len_docs_begin >= target_k:
68
  log.info(f'Initial search contains {len_docs_begin} documents. Expansion not required. ')
69
  return context
70
- CUT_THE_LOOP_N = 500
71
- for top_k_docs in np.arange(init_k, CUT_THE_LOOP_N * init_k, step):
72
  log.info(f'Context contains {len(context)} documents')
73
  log.info(f'Expanding search with k={top_k_docs}')
74
  context = filter_docs_by_meta(vector_store.similarity_search(query, k=int(top_k_docs)), filter_dict)
75
  if len(context) >= target_k:
76
  log.info(f'Success. Context contains {len(context)} documents matching the filtering criteria')
77
  return context
78
- log.info(f'Failed to reach target number of documents after {CUT_THE_LOOP_N} loops,'
79
  f' context contains {len(context)} documents matching the filtering criteria')
80
  return context
81
 
 
67
  if len_docs_begin >= target_k:
68
  log.info(f'Initial search contains {len_docs_begin} documents. Expansion not required. ')
69
  return context
70
+ MAX_K = 50000 # This is more than the number of actual documents.
71
+ for top_k_docs in np.arange(init_k, MAX_K, step):
72
  log.info(f'Context contains {len(context)} documents')
73
  log.info(f'Expanding search with k={top_k_docs}')
74
  context = filter_docs_by_meta(vector_store.similarity_search(query, k=int(top_k_docs)), filter_dict)
75
  if len(context) >= target_k:
76
  log.info(f'Success. Context contains {len(context)} documents matching the filtering criteria')
77
  return context
78
+ log.info(f'Failed to reach target number of documents,'
79
  f' context contains {len(context)} documents matching the filtering criteria')
80
  return context
81
 
public_app.py CHANGED
@@ -81,7 +81,7 @@ if __name__ == '__main__':
81
  'cultural, financial, and political developments occurring at a given time.'
82
  ' The model actively looks for the presence of date elements in the query '
83
  'and will stop the execution if cannot find them to minimize the risk of model '
84
- 'hallucination. Nevertheless, the usual caveats for application making use of generative AI apply.'
85
  ' Click the query examples below to see some possible outputs from the model.',
86
  article='**Disclaimer**: This app is for demonstration purposes only, and no assurance of uninterrupted'
87
  ' functionality can be given at this time. Answers may take some'
@@ -89,9 +89,9 @@ if __name__ == '__main__':
89
  'during periods of heavy usage. There is still significant work planned ahead. Please be patient :)',
90
  analytics_enabled=True,
91
  allow_flagging="manual",
92
- flagging_options=["error", "ambiguous", "not useful"],
93
  outputs=gr.Textbox(lines=1, label='Answer'),
94
- title='Search the FED minutes',
95
  examples=FedMinutesSearch,
96
  cache_examples=False
97
  )
 
81
  'cultural, financial, and political developments occurring at a given time.'
82
  ' The model actively looks for the presence of date elements in the query '
83
  'and will stop the execution if cannot find them to minimize the risk of model '
84
+ 'hallucination. Nevertheless, the usual caveats for applications making use of generative AI apply.'
85
  ' Click the query examples below to see some possible outputs from the model.',
86
  article='**Disclaimer**: This app is for demonstration purposes only, and no assurance of uninterrupted'
87
  ' functionality can be given at this time. Answers may take some'
 
89
  'during periods of heavy usage. There is still significant work planned ahead. Please be patient :)',
90
  analytics_enabled=True,
91
  allow_flagging="manual",
92
+ flagging_options=["error", "ambiguous", "not true"],
93
  outputs=gr.Textbox(lines=1, label='Answer'),
94
+ title='Search the FED minutes archive',
95
  examples=FedMinutesSearch,
96
  cache_examples=False
97
  )