Updated fixed context
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import torch
|
@@ -41,16 +42,22 @@ def QA_function(context, question):
|
|
41 |
|
42 |
# a) Get predictions
|
43 |
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
def get_answer(context,question):
|
46 |
QA_input = {
|
47 |
'question': question,
|
48 |
-
'context':
|
49 |
}
|
50 |
res = nlp(QA_input)
|
51 |
return res['answer']
|
52 |
|
53 |
-
gradio_ui = gr.Interface(get_answer, [gr.inputs.Textbox(lines=7, label="Context"), gr.inputs.Textbox(label="Question")], gr.outputs.Textbox(label="Answer"))
|
|
|
54 |
|
55 |
gradio_ui.launch()
|
56 |
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
import torch
|
|
|
42 |
|
43 |
# a) Get predictions
|
44 |
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
45 |
+
fixed_context = """Ishaan is 6 year old kid. he is very good in football. He is very good sports person.
|
46 |
+
he is smart kid. He can run very fast. as fast as 10 meters in 1 minute.
|
47 |
+
He goes to Vidyani ketan school. He goes to school from 8 am to 3:30 pm.
|
48 |
+
Ishaan has many friends.
|
49 |
+
Vineet is his brother. """
|
50 |
|
51 |
def get_answer(context,question):
|
52 |
QA_input = {
|
53 |
'question': question,
|
54 |
+
'context': fixed_context
|
55 |
}
|
56 |
res = nlp(QA_input)
|
57 |
return res['answer']
|
58 |
|
59 |
+
# gradio_ui = gr.Interface(get_answer, [gr.inputs.Textbox(lines=7, label="Context"), gr.inputs.Textbox(label="Question")], gr.outputs.Textbox(label="Answer"))
|
60 |
+
gradio_ui = gr.Interface(get_answer, [gr.inputs.Textbox(label="Question")], gr.outputs.Textbox(label="Answer"))
|
61 |
|
62 |
gradio_ui.launch()
|
63 |
|