import gradio as gr from transformers import pipeline model_name = "deepset/roberta-base-squad2" pipe = pipeline("question-answering", model=model_name, tokenizer=model_name) context = "my name is diogo and i'm 32 years old, i live in portugal neraby the ocean." def q_and_a(text): query = { 'question': text, 'context': context } return pipe(query)['answer'] interface = gr.Interface( fn=q_and_a, inputs='text', outputs='text' ) interface.launch()