import gradio as gr from keybert import KeyBERT # KeyBERT model keybert_model = KeyBERT(model='all-MiniLM-L6-v2') def get_bert_keywords(text, num_keywords=5): result = keybert_model.extract_keywords(text, keyphrase_ngram_range=(1, 1), top_n=num_keywords) keyberts = [keyword for keyword, score in result] return keyberts iface = gr.Interface(fn=get_bert_keywords, inputs=["text", gr.inputs.Slider(1, 10, default=5, step=1)], outputs="text") iface.launch()