SnowFlash383935 commited on
Commit
341b6f5
·
verified ·
1 Parent(s): 71d47ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,14 +1,17 @@
1
  import gradio as gr
2
- import transformers
3
- def update(name):
4
- return f"Welcome to Gradio, {name}!"
 
 
 
5
 
6
  with gr.Blocks(theme='SnowFlash383935/emerald') as demo:
7
- gr.Markdown("Start typing below and then click **Run** to see the output.")
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()