Spaces:
Build error
Build error
import gradio as gr | |
from transformers import pipeline | |
model = pipeline(model="marksverdhei/t5-base-define") | |
model.model.config.max_length = 300 | |
description = """ | |
Enter a word and a sentence that uses the word. We then generate a definition | |
""" | |
def predict(word, example) -> str: | |
input_text = f"define \"{word}\": {example}" | |
output = model(input_text, truncation=True) | |
output_text = output[0]["generated_text"] | |
return output_text | |
gr.Interface( | |
fn=predict, | |
inputs=["text", "text"], | |
outputs=[ | |
gr.Textbox(label="Generated definition") | |
], | |
title="Word definition", | |
description=description, | |
).launch() |