Spaces:
Runtime error
Runtime error
File size: 596 Bytes
2bd2d16 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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()
|