Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -113,7 +113,7 @@ def get_splade_cocondenser_representation(text):
|
|
| 113 |
|
| 114 |
sorted_representation = sorted(meaningful_tokens.items(), key=lambda item: item[1], reverse=True)
|
| 115 |
|
| 116 |
-
formatted_output = "SPLADE-cocondenser-distil
|
| 117 |
if not sorted_representation:
|
| 118 |
formatted_output += "No significant terms found for this input.\n"
|
| 119 |
else:
|
|
@@ -237,9 +237,9 @@ def get_splade_doc_representation(text):
|
|
| 237 |
def predict_representation_explorer(model_choice, text):
|
| 238 |
if model_choice == "SPLADE-cocondenser-distil (weighting and expansion)":
|
| 239 |
return get_splade_cocondenser_representation(text)
|
| 240 |
-
elif model_choice == "SPLADE-v3-
|
| 241 |
return get_splade_lexical_representation(text)
|
| 242 |
-
elif model_choice == "
|
| 243 |
return get_splade_doc_representation(text)
|
| 244 |
else:
|
| 245 |
return "Please select a model."
|
|
@@ -357,12 +357,12 @@ def format_sparse_vector_output(splade_vector, tokenizer, is_binary=False):
|
|
| 357 |
|
| 358 |
# --- NEW/MODIFIED: Helper to get the correct vector function, tokenizer, and binary flag ---
|
| 359 |
def get_model_assets(model_choice_str):
|
| 360 |
-
if model_choice_str == "SPLADE-cocondenser-distil
|
| 361 |
-
return get_splade_cocondenser_vector, tokenizer_splade, False, "SPLADE-cocondenser-distil
|
| 362 |
-
elif model_choice_str == "SPLADE-v3-
|
| 363 |
-
return get_splade_lexical_vector, tokenizer_splade_lexical, False, "SPLADE-v3-
|
| 364 |
-
elif model_choice_str == "
|
| 365 |
-
return get_splade_doc_vector, tokenizer_splade_doc, True, "
|
| 366 |
else:
|
| 367 |
return None, None, False, "Unknown Model"
|
| 368 |
|
|
@@ -418,7 +418,7 @@ with gr.Blocks(title="SPLADE Demos") as demo:
|
|
| 418 |
"Binary Encoder"
|
| 419 |
],
|
| 420 |
label="Choose Sparse Encoder",
|
| 421 |
-
value="SPLADE-cocondenser-distil
|
| 422 |
),
|
| 423 |
gr.Textbox(
|
| 424 |
lines=5,
|
|
@@ -437,9 +437,9 @@ with gr.Blocks(title="SPLADE Demos") as demo:
|
|
| 437 |
|
| 438 |
# Define the common model choices for cleaner code
|
| 439 |
model_choices = [
|
| 440 |
-
"SPLADE-cocondenser-distil
|
| 441 |
-
"SPLADE-v3-
|
| 442 |
-
"
|
| 443 |
]
|
| 444 |
|
| 445 |
gr.Interface(
|
|
@@ -448,12 +448,12 @@ with gr.Blocks(title="SPLADE Demos") as demo:
|
|
| 448 |
gr.Radio(
|
| 449 |
model_choices,
|
| 450 |
label="Choose Query Encoding Model",
|
| 451 |
-
value="SPLADE-cocondenser-distil
|
| 452 |
),
|
| 453 |
gr.Radio(
|
| 454 |
model_choices,
|
| 455 |
label="Choose Document Encoding Model",
|
| 456 |
-
value="SPLADE-cocondenser-distil
|
| 457 |
),
|
| 458 |
gr.Textbox(
|
| 459 |
lines=3,
|
|
|
|
| 113 |
|
| 114 |
sorted_representation = sorted(meaningful_tokens.items(), key=lambda item: item[1], reverse=True)
|
| 115 |
|
| 116 |
+
formatted_output = "MLM encoder (SPLADE-cocondenser-distil):\n"
|
| 117 |
if not sorted_representation:
|
| 118 |
formatted_output += "No significant terms found for this input.\n"
|
| 119 |
else:
|
|
|
|
| 237 |
def predict_representation_explorer(model_choice, text):
|
| 238 |
if model_choice == "SPLADE-cocondenser-distil (weighting and expansion)":
|
| 239 |
return get_splade_cocondenser_representation(text)
|
| 240 |
+
elif model_choice == "MLP encoder (SPLADE-v3-lexical)":
|
| 241 |
return get_splade_lexical_representation(text)
|
| 242 |
+
elif model_choice == "Binary encoder":
|
| 243 |
return get_splade_doc_representation(text)
|
| 244 |
else:
|
| 245 |
return "Please select a model."
|
|
|
|
| 357 |
|
| 358 |
# --- NEW/MODIFIED: Helper to get the correct vector function, tokenizer, and binary flag ---
|
| 359 |
def get_model_assets(model_choice_str):
|
| 360 |
+
if model_choice_str == "MLM encoder (SPLADE-cocondenser-distil)":
|
| 361 |
+
return get_splade_cocondenser_vector, tokenizer_splade, False, "MLM encoder (SPLADE-cocondenser-distil)"
|
| 362 |
+
elif model_choice_str == "MLP encoder (SPLADE-v3-lexical)":
|
| 363 |
+
return get_splade_lexical_vector, tokenizer_splade_lexical, False, "MLP encoder (SPLADE-v3-lexical)"
|
| 364 |
+
elif model_choice_str == "Binary encoder":
|
| 365 |
+
return get_splade_doc_vector, tokenizer_splade_doc, True, "Binary encoder"
|
| 366 |
else:
|
| 367 |
return None, None, False, "Unknown Model"
|
| 368 |
|
|
|
|
| 418 |
"Binary Encoder"
|
| 419 |
],
|
| 420 |
label="Choose Sparse Encoder",
|
| 421 |
+
value="MLM encoder (SPLADE-cocondenser-distil)"
|
| 422 |
),
|
| 423 |
gr.Textbox(
|
| 424 |
lines=5,
|
|
|
|
| 437 |
|
| 438 |
# Define the common model choices for cleaner code
|
| 439 |
model_choices = [
|
| 440 |
+
"MLM encoder (SPLADE-cocondenser-distil)",
|
| 441 |
+
"MLP encoder (SPLADE-v3-lexical)",
|
| 442 |
+
"Binary encoder"
|
| 443 |
]
|
| 444 |
|
| 445 |
gr.Interface(
|
|
|
|
| 448 |
gr.Radio(
|
| 449 |
model_choices,
|
| 450 |
label="Choose Query Encoding Model",
|
| 451 |
+
value="MLM encoder (SPLADE-cocondenser-distil)" # Default value
|
| 452 |
),
|
| 453 |
gr.Radio(
|
| 454 |
model_choices,
|
| 455 |
label="Choose Document Encoding Model",
|
| 456 |
+
value="MLM encoder (SPLADE-cocondenser-distil)" # Default value
|
| 457 |
),
|
| 458 |
gr.Textbox(
|
| 459 |
lines=3,
|