|
import gradio as gr |
|
from wordllama import WordLlama |
|
|
|
|
|
wl = WordLlama.load() |
|
|
|
|
|
def calculate_similarity(sentence1, sentence2): |
|
similarity_score = wl.similarity(sentence1, sentence2) |
|
return similarity_score |
|
|
|
|
|
iface = gr.Interface( |
|
fn=calculate_similarity, |
|
inputs=[ |
|
gr.Textbox(lines=2, placeholder="Enter first sentence..."), |
|
gr.Textbox(lines=2, placeholder="Enter second sentence...") |
|
], |
|
outputs="number", |
|
title="Sentence Similarity with WordLlama", |
|
description="Calculate the similarity between two sentences using the WordLlama model from Hugging Face." |
|
) |
|
|
|
|
|
examples = [ |
|
["I went to the car", "I went to the pawn shop"], |
|
["The cat is on the roof", "A dog is in the yard"], |
|
["She loves playing tennis", "She enjoys sports"], |
|
["This is a bright day", "It's a sunny morning"], |
|
["I bought a new phone", "I got a new mobile"] |
|
] |
|
|
|
iface.launch(share=True, examples=examples) |