NEW_MODEL_2 / app.py
13Aluminium's picture
Create app.py
2bd2d16 verified
raw
history blame contribute delete
596 Bytes
import gradio as gr
from gensim.models import FastText
# Load your trained FastText model
model_path = "fasttext_cs.model"
ft_model = FastText.load(model_path)
def get_nearest(word):
if word in ft_model.wv:
return ft_model.wv.most_similar(word, topn=10)
else:
return f"Word '{word}' not found in vocabulary."
# Define a Gradio interface
iface = gr.Interface(
fn=get_nearest,
inputs="text",
outputs="json",
title="FastText Nearest Neighbors",
description="Enter a word from the cs_query vocabulary to see its top 10 similar words."
)
iface.launch()