DexterSptizu's picture
Update app.py
86f4f00 verified
raw
history blame
1.09 kB
import gradio as gr
from wordllama import WordLlama
# Load the default WordLlama model
wl = WordLlama.load()
# Define the function that calculates similarity between two sentences
def calculate_similarity(sentence1, sentence2):
similarity_score = wl.similarity(sentence1, sentence2)
return similarity_score
# Define Gradio interface
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."
)
# Define five example inputs
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)