Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
os.system("pip install gradio==3.11")
|
2 |
+
os.system("pip install transformers")
|
3 |
+
os.system("pip install torch")
|
4 |
+
|
5 |
+
import requests
|
6 |
+
import gradio as gr
|
7 |
+
import os
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
from transformers import pipeline
|
12 |
+
|
13 |
+
qa_model = pipeline("question-answering")
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
def question(context,question):
|
18 |
+
output = qa_model(question = question, context = context)
|
19 |
+
return output['answer']
|
20 |
+
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=question,
|
23 |
+
inputs=[gr.Textbox(lines=8, placeholder="context Here..."), gr.Textbox(lines=2, placeholder="question Here...")],
|
24 |
+
outputs="text",title="Question answering app",
|
25 |
+
description="This is a question answering app, it can prove useful when you want to extract an information from a large text. All you need to do is copy and paste the text you want to query and then query it with a relevant question",
|
26 |
+
examples=[
|
27 |
+
["My name is Oluwafunbi Adeneye and I attended Federal University of Agriculture Abeokuta", "What is the name of Oluwafunbi's school?"],
|
28 |
+
["Cocoa house is the tallest building in Ibadan","what is the name of the tallest building in Ibadan?"],
|
29 |
+
],
|
30 |
+
)
|
31 |
+
demo.launch()
|