Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -270,7 +270,7 @@ def get_splade_doc_representation(text):
|
|
| 270 |
|
| 271 |
sorted_representation = sorted(meaningful_tokens.items(), key=lambda item: item[0]) # Sort alphabetically for clarity
|
| 272 |
|
| 273 |
-
formatted_output = "Binary
|
| 274 |
if not sorted_representation:
|
| 275 |
formatted_output += "No significant terms found for this input.\n"
|
| 276 |
else:
|
|
@@ -292,7 +292,7 @@ def predict_representation_explorer(model_choice, text):
|
|
| 292 |
return get_splade_cocondenser_representation(text)
|
| 293 |
elif model_choice == "MLP encoder (SPLADE-v3-lexical)":
|
| 294 |
return get_splade_lexical_representation(text)
|
| 295 |
-
elif model_choice == "Binary
|
| 296 |
return get_splade_doc_representation(text)
|
| 297 |
else:
|
| 298 |
return "Please select a model.", "" # Return two empty strings for consistency
|
|
@@ -414,7 +414,7 @@ def get_model_assets(model_choice_str):
|
|
| 414 |
return get_splade_cocondenser_vector, tokenizer_splade, False, "MLM encoder (SPLADE-cocondenser-distil)"
|
| 415 |
elif model_choice_str == "MLP encoder (SPLADE-v3-lexical)":
|
| 416 |
return get_splade_lexical_vector, tokenizer_splade_lexical, False, "MLP encoder (SPLADE-v3-lexical)"
|
| 417 |
-
elif model_choice_str == "Binary
|
| 418 |
return get_splade_doc_vector, tokenizer_splade_doc, True, "Binary Bag-of-Words"
|
| 419 |
else:
|
| 420 |
return None, None, False, "Unknown Model"
|
|
@@ -480,7 +480,7 @@ with gr.Blocks(title="SPLADE Demos", css=css) as demo:
|
|
| 480 |
[
|
| 481 |
"MLM encoder (SPLADE-cocondenser-distil)",
|
| 482 |
"MLP encoder (SPLADE-v3-lexical)",
|
| 483 |
-
"Binary
|
| 484 |
],
|
| 485 |
label="Choose Sparse Encoder",
|
| 486 |
value="MLM encoder (SPLADE-cocondenser-distil)"
|
|
@@ -549,7 +549,7 @@ with gr.Blocks(title="SPLADE Demos", css=css) as demo:
|
|
| 549 |
model_choices = [
|
| 550 |
"MLM encoder (SPLADE-cocondenser-distil)",
|
| 551 |
"MLP encoder (SPLADE-v3-lexical)",
|
| 552 |
-
"Binary
|
| 553 |
]
|
| 554 |
|
| 555 |
# Input components for the second tab
|
|
|
|
| 270 |
|
| 271 |
sorted_representation = sorted(meaningful_tokens.items(), key=lambda item: item[0]) # Sort alphabetically for clarity
|
| 272 |
|
| 273 |
+
formatted_output = "Binary:\n\n"
|
| 274 |
if not sorted_representation:
|
| 275 |
formatted_output += "No significant terms found for this input.\n"
|
| 276 |
else:
|
|
|
|
| 292 |
return get_splade_cocondenser_representation(text)
|
| 293 |
elif model_choice == "MLP encoder (SPLADE-v3-lexical)":
|
| 294 |
return get_splade_lexical_representation(text)
|
| 295 |
+
elif model_choice == "Binary": # Changed name
|
| 296 |
return get_splade_doc_representation(text)
|
| 297 |
else:
|
| 298 |
return "Please select a model.", "" # Return two empty strings for consistency
|
|
|
|
| 414 |
return get_splade_cocondenser_vector, tokenizer_splade, False, "MLM encoder (SPLADE-cocondenser-distil)"
|
| 415 |
elif model_choice_str == "MLP encoder (SPLADE-v3-lexical)":
|
| 416 |
return get_splade_lexical_vector, tokenizer_splade_lexical, False, "MLP encoder (SPLADE-v3-lexical)"
|
| 417 |
+
elif model_choice_str == "Binary":
|
| 418 |
return get_splade_doc_vector, tokenizer_splade_doc, True, "Binary Bag-of-Words"
|
| 419 |
else:
|
| 420 |
return None, None, False, "Unknown Model"
|
|
|
|
| 480 |
[
|
| 481 |
"MLM encoder (SPLADE-cocondenser-distil)",
|
| 482 |
"MLP encoder (SPLADE-v3-lexical)",
|
| 483 |
+
"Binary"
|
| 484 |
],
|
| 485 |
label="Choose Sparse Encoder",
|
| 486 |
value="MLM encoder (SPLADE-cocondenser-distil)"
|
|
|
|
| 549 |
model_choices = [
|
| 550 |
"MLM encoder (SPLADE-cocondenser-distil)",
|
| 551 |
"MLP encoder (SPLADE-v3-lexical)",
|
| 552 |
+
"Binary"
|
| 553 |
]
|
| 554 |
|
| 555 |
# Input components for the second tab
|