Spaces:
Sleeping
Sleeping
Update app.py
#1
by
AIteen
- opened
app.py
CHANGED
@@ -27,16 +27,10 @@ def get_similarity_scores(queries: list, passages: list, model, tokenizer):
|
|
27 |
scores = (embeddings[:len(queries)] @ embeddings[len(queries):].T) * 100
|
28 |
return scores.tolist()
|
29 |
|
30 |
-
def similarity_ui(
|
31 |
task = 'Given a keyName, find similarity score against provided fields'
|
32 |
-
queries =
|
33 |
-
|
34 |
-
]
|
35 |
-
passages = [
|
36 |
-
field1,
|
37 |
-
field2,
|
38 |
-
field3
|
39 |
-
]
|
40 |
|
41 |
scores = get_similarity_scores(queries, passages, model, tokenizer)
|
42 |
return {'Similarity Scores': scores}
|
@@ -48,7 +42,7 @@ model = AutoModel.from_pretrained('Salesforce/SFR-Embedding-Mistral')
|
|
48 |
# Create Gradio Interface
|
49 |
gr.Interface(
|
50 |
fn=similarity_ui,
|
51 |
-
inputs=
|
52 |
outputs="text",
|
53 |
title="Similarity Score Calculator",
|
54 |
description="Enter a Key Name and 3 Fields to find similarity scores"
|
|
|
27 |
scores = (embeddings[:len(queries)] @ embeddings[len(queries):].T) * 100
|
28 |
return scores.tolist()
|
29 |
|
30 |
+
def similarity_ui(keyNames:list, fields:list):
|
31 |
task = 'Given a keyName, find similarity score against provided fields'
|
32 |
+
queries = keyNames
|
33 |
+
passages = fields
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
scores = get_similarity_scores(queries, passages, model, tokenizer)
|
36 |
return {'Similarity Scores': scores}
|
|
|
42 |
# Create Gradio Interface
|
43 |
gr.Interface(
|
44 |
fn=similarity_ui,
|
45 |
+
inputs="text", "text",
|
46 |
outputs="text",
|
47 |
title="Similarity Score Calculator",
|
48 |
description="Enter a Key Name and 3 Fields to find similarity scores"
|