import gradio as gr from transformers import pipeline pipe = pipeline("question-answering", model="deepset/bert-base-cased-squad2") def main(question, context): answer = pipe(question=question, context=context) return answer["answer"] with gr.Blocks() as demo: gr.Markdown("""# Question Answerer!""") with gr.Row(): with gr.Column(): text1 = gr.Textbox( label="Question", lines=1, value="Who does Cristiano Ronaldo play for?", ) text2 = gr.Textbox( label="Context", lines=3, value="Cristiano Ronaldo is a player for Manchester United", ) output = gr.Textbox() b1 = gr.Button("Ask Question!") b1.click(main, inputs=[text1, text2], outputs=output) gr.Markdown("""#### powered by [Tassle](https://bit.ly/3LXMklV)""") if __name__ == "__main__": demo.launch()