Spaces:
Runtime error
Runtime error
Commit
·
596896c
1
Parent(s):
4bd1056
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,13 @@ def compare_text(source, target):
|
|
13 |
embeddings_target = model.encode(target, convert_to_tensor=True)
|
14 |
# Compute cosine-similarities
|
15 |
cosine_scores = util.cos_sim(embeddings_source, embeddings_target)
|
16 |
-
|
|
|
17 |
|
18 |
import gradio as gr
|
19 |
|
20 |
with gr.Blocks(css=".gradio-container { background-color: white; background-image: url('file=./qc-logo.png'); background-size: 75px 75px; background-repeat: no-repeat; background-position: 0px 0px; }") as demo:
|
21 |
-
gr.Markdown(f"# {' ' * 8}Sentence comparer with
|
22 |
with gr.Row():
|
23 |
source = gr.Textbox(lines=3, label="Source sentence", placeholder="Source sentence")
|
24 |
with gr.Row():
|
@@ -26,7 +27,8 @@ with gr.Blocks(css=".gradio-container { background-color: white; background-imag
|
|
26 |
btn = gr.Button(value="Compare!", variant="primary")
|
27 |
with gr.Row():
|
28 |
label = gr.Label()
|
29 |
-
|
|
|
30 |
gr.Examples([
|
31 |
["Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems.","most advanced conversation intelligence and AI powered coaching platform"],
|
32 |
["Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems. And what does that really mean? So, um, communication coaching is something that is typically delivered one on one between a communication coach who has a, uh, a doctorate or a, um, background and experience in teaching people how to be better communicators and how to express themselves effectively.","most advanced conversation intelligence and AI powered coaching platform"],
|
|
|
13 |
embeddings_target = model.encode(target, convert_to_tensor=True)
|
14 |
# Compute cosine-similarities
|
15 |
cosine_scores = util.cos_sim(embeddings_source, embeddings_target)
|
16 |
+
cosine = cosine_scores[0][0].item()
|
17 |
+
return { "Similarity": cosine }, round(cosine,3)
|
18 |
|
19 |
import gradio as gr
|
20 |
|
21 |
with gr.Blocks(css=".gradio-container { background-color: white; background-image: url('file=./qc-logo.png'); background-size: 75px 75px; background-repeat: no-repeat; background-position: 0px 0px; }") as demo:
|
22 |
+
gr.Markdown(f"# {' ' * 8}Sentence comparer with BERT (paraphrase-distilroberta-base-v2)")
|
23 |
with gr.Row():
|
24 |
source = gr.Textbox(lines=3, label="Source sentence", placeholder="Source sentence")
|
25 |
with gr.Row():
|
|
|
27 |
btn = gr.Button(value="Compare!", variant="primary")
|
28 |
with gr.Row():
|
29 |
label = gr.Label()
|
30 |
+
score = gr.Textbox(label="Score", interactive=False)
|
31 |
+
btn.click(fn=compare_text, inputs=[source,target], outputs=[label,score])
|
32 |
gr.Examples([
|
33 |
["Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems.","most advanced conversation intelligence and AI powered coaching platform"],
|
34 |
["Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems. And what does that really mean? So, um, communication coaching is something that is typically delivered one on one between a communication coach who has a, uh, a doctorate or a, um, background and experience in teaching people how to be better communicators and how to express themselves effectively.","most advanced conversation intelligence and AI powered coaching platform"],
|