DexterSptizu commited on
Commit
9732442
1 Parent(s): 86f4f00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -9,18 +9,6 @@ def calculate_similarity(sentence1, sentence2):
9
  similarity_score = wl.similarity(sentence1, sentence2)
10
  return similarity_score
11
 
12
- # Define Gradio interface
13
- iface = gr.Interface(
14
- fn=calculate_similarity,
15
- inputs=[
16
- gr.Textbox(lines=2, placeholder="Enter first sentence..."),
17
- gr.Textbox(lines=2, placeholder="Enter second sentence...")
18
- ],
19
- outputs="number",
20
- title="Sentence Similarity with WordLlama",
21
- description="Calculate the similarity between two sentences using the WordLlama model from Hugging Face."
22
- )
23
-
24
  # Define five example inputs
25
  examples = [
26
  ["I went to the car", "I went to the pawn shop"],
@@ -30,4 +18,20 @@ examples = [
30
  ["I bought a new phone", "I got a new mobile"]
31
  ]
32
 
33
- iface.launch(share=True, examples=examples)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  similarity_score = wl.similarity(sentence1, sentence2)
10
  return similarity_score
11
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Define five example inputs
13
  examples = [
14
  ["I went to the car", "I went to the pawn shop"],
 
18
  ["I bought a new phone", "I got a new mobile"]
19
  ]
20
 
21
+ # Define Gradio interface
22
+ with gr.Blocks() as iface:
23
+ gr.Markdown("# Sentence Similarity with WordLlama")
24
+ gr.Markdown("Calculate the similarity between two sentences using the WordLlama model from Hugging Face.")
25
+
26
+ sentence1 = gr.Textbox(lines=2, placeholder="Enter first sentence...")
27
+ sentence2 = gr.Textbox(lines=2, placeholder="Enter second sentence...")
28
+ output = gr.Number()
29
+
30
+ # Button to trigger similarity calculation
31
+ button = gr.Button("Calculate Similarity")
32
+ button.click(calculate_similarity, inputs=[sentence1, sentence2], outputs=output)
33
+
34
+ # Examples section
35
+ gr.Examples(examples=examples, inputs=[sentence1, sentence2])
36
+
37
+ iface.launch(share=True)