Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
with gr.Blocks(theme='SnowFlash383935/emerald') as demo:
|
7 |
-
gr.Markdown("
|
8 |
with gr.Row():
|
9 |
inp = gr.Textbox(placeholder="What is your name?")
|
10 |
out = gr.Textbox()
|
11 |
btn = gr.Button("Run")
|
12 |
-
btn.click(fn=update, inputs=inp, outputs=out)
|
13 |
|
14 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from sentence_transformers import SentenceTransformer
|
3 |
+
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
4 |
+
def update(raw, model):
|
5 |
+
sentences = raw.split("$")
|
6 |
+
embeddings = model.encode(sentences)
|
7 |
+
return embeddings
|
8 |
|
9 |
with gr.Blocks(theme='SnowFlash383935/emerald') as demo:
|
10 |
+
gr.Markdown("Sentence Similarity. Type sentences with $ separator")
|
11 |
with gr.Row():
|
12 |
inp = gr.Textbox(placeholder="What is your name?")
|
13 |
out = gr.Textbox()
|
14 |
btn = gr.Button("Run")
|
15 |
+
btn.click(fn=update, inputs=[inp, model], outputs=out)
|
16 |
|
17 |
demo.launch()
|