Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -354,7 +354,7 @@ def optimize_query(
|
|
| 354 |
|
| 355 |
Returns:
|
| 356 |
Expanded query string
|
| 357 |
-
"""
|
| 358 |
try:
|
| 359 |
# Set device
|
| 360 |
device = "cuda" if use_gpu and torch.cuda.is_available() else "cpu"
|
|
@@ -383,7 +383,7 @@ def optimize_query(
|
|
| 383 |
Enhance the followinf search query with relevant terms.
|
| 384 |
|
| 385 |
show me just the new term. You SHOULD NOT include any other text in the response.
|
| 386 |
-
|
| 387 |
<|eot_id|><|start_header_id|>user<|end_header_id|>
|
| 388 |
{query}
|
| 389 |
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
|
@@ -1084,10 +1084,10 @@ def get_llm_suggested_settings(file, num_chunks=1):
|
|
| 1084 |
|
| 1085 |
prompt=f'''
|
| 1086 |
<|start_header_id|>system<|end_header_id|>
|
| 1087 |
-
You are an expert in information retrieval.
|
| 1088 |
You know about strenghs and weaknesses of all models.
|
| 1089 |
|
| 1090 |
-
Given the following text chunks from a document,
|
| 1091 |
suggest optimal settings for an embedding-based search system. The settings should include:
|
| 1092 |
|
| 1093 |
1. Embedding model type and name
|
|
@@ -1113,13 +1113,13 @@ def get_llm_suggested_settings(file, num_chunks=1):
|
|
| 1113 |
"apply_preprocessing": True,
|
| 1114 |
"optimize_vocab": True,
|
| 1115 |
"apply_phonetic": False,
|
| 1116 |
-
"phonetic_weight": 0.3 #
|
| 1117 |
}}
|
| 1118 |
|
| 1119 |
Provide your suggestions in a Python dictionary format.
|
| 1120 |
|
| 1121 |
show me settings You SHOULD NOT include any other text in the response.
|
| 1122 |
-
Fill out the seeting and chose usefull values.
|
| 1123 |
Respect the users use cases and content snipet. Choose the setting based on the chunks
|
| 1124 |
|
| 1125 |
<|eot_id|><|start_header_id|>user<|end_header_id|>
|
|
@@ -1142,13 +1142,13 @@ def get_llm_suggested_settings(file, num_chunks=1):
|
|
| 1142 |
max_new_tokens=1900, # Control the length of the output,
|
| 1143 |
truncation=True, # Enable truncation
|
| 1144 |
)
|
| 1145 |
-
|
| 1146 |
print(suggested_settings[0]['generated_text'])
|
| 1147 |
# Safely parse the generated text to extract the dictionary
|
| 1148 |
try:
|
| 1149 |
# Using ast.literal_eval for safe parsing
|
| 1150 |
settings_dict = ast.literal_eval(suggested_settings[0]['generated_text'])
|
| 1151 |
-
|
| 1152 |
# Convert the settings to match the interface inputs
|
| 1153 |
return {
|
| 1154 |
"embedding_models": settings_dict["embedding_models"],
|
|
@@ -1388,7 +1388,11 @@ def launch_interface(debug=True):
|
|
| 1388 |
)
|
| 1389 |
###
|
| 1390 |
|
| 1391 |
-
with gr.Tab("
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1392 |
with gr.Row():
|
| 1393 |
results_output = gr.DataFrame(label="Results")
|
| 1394 |
stats_output = gr.DataFrame(label="Statistics")
|
|
|
|
| 354 |
|
| 355 |
Returns:
|
| 356 |
Expanded query string
|
| 357 |
+
"""
|
| 358 |
try:
|
| 359 |
# Set device
|
| 360 |
device = "cuda" if use_gpu and torch.cuda.is_available() else "cpu"
|
|
|
|
| 383 |
Enhance the followinf search query with relevant terms.
|
| 384 |
|
| 385 |
show me just the new term. You SHOULD NOT include any other text in the response.
|
| 386 |
+
|
| 387 |
<|eot_id|><|start_header_id|>user<|end_header_id|>
|
| 388 |
{query}
|
| 389 |
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
|
|
|
| 1084 |
|
| 1085 |
prompt=f'''
|
| 1086 |
<|start_header_id|>system<|end_header_id|>
|
| 1087 |
+
You are an expert in information retrieval.
|
| 1088 |
You know about strenghs and weaknesses of all models.
|
| 1089 |
|
| 1090 |
+
Given the following text chunks from a document,
|
| 1091 |
suggest optimal settings for an embedding-based search system. The settings should include:
|
| 1092 |
|
| 1093 |
1. Embedding model type and name
|
|
|
|
| 1113 |
"apply_preprocessing": True,
|
| 1114 |
"optimize_vocab": True,
|
| 1115 |
"apply_phonetic": False,
|
| 1116 |
+
"phonetic_weight": 0.3 #
|
| 1117 |
}}
|
| 1118 |
|
| 1119 |
Provide your suggestions in a Python dictionary format.
|
| 1120 |
|
| 1121 |
show me settings You SHOULD NOT include any other text in the response.
|
| 1122 |
+
Fill out the seeting and chose usefull values.
|
| 1123 |
Respect the users use cases and content snipet. Choose the setting based on the chunks
|
| 1124 |
|
| 1125 |
<|eot_id|><|start_header_id|>user<|end_header_id|>
|
|
|
|
| 1142 |
max_new_tokens=1900, # Control the length of the output,
|
| 1143 |
truncation=True, # Enable truncation
|
| 1144 |
)
|
| 1145 |
+
|
| 1146 |
print(suggested_settings[0]['generated_text'])
|
| 1147 |
# Safely parse the generated text to extract the dictionary
|
| 1148 |
try:
|
| 1149 |
# Using ast.literal_eval for safe parsing
|
| 1150 |
settings_dict = ast.literal_eval(suggested_settings[0]['generated_text'])
|
| 1151 |
+
|
| 1152 |
# Convert the settings to match the interface inputs
|
| 1153 |
return {
|
| 1154 |
"embedding_models": settings_dict["embedding_models"],
|
|
|
|
| 1388 |
)
|
| 1389 |
###
|
| 1390 |
|
| 1391 |
+
with gr.Tab("Chat"):
|
| 1392 |
+
with gr.Row():
|
| 1393 |
+
chat_output =
|
| 1394 |
+
chat_input =
|
| 1395 |
+
|
| 1396 |
with gr.Row():
|
| 1397 |
results_output = gr.DataFrame(label="Results")
|
| 1398 |
stats_output = gr.DataFrame(label="Statistics")
|