Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from sentence_transformers import CrossEncoder
|
| 3 |
+
|
| 4 |
+
# Load CrossEncoder model
|
| 5 |
+
model = CrossEncoder("cross-encoder/nli-deberta-v3-base")
|
| 6 |
+
|
| 7 |
+
def predict_similarity(sentence1, sentence2):
|
| 8 |
+
score = model.predict([(sentence1, sentence2)])
|
| 9 |
+
return float(score)
|
| 10 |
+
|
| 11 |
+
demo = gr.Interface(
|
| 12 |
+
fn=predict_similarity,
|
| 13 |
+
inputs=["text", "text"],
|
| 14 |
+
outputs="number",
|
| 15 |
+
title="CrossEncoder (nli-deberta-v3-base)",
|
| 16 |
+
description="Enter two sentences to compute semantic similarity."
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
demo.launch()
|