Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load a
|
| 5 |
qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
|
| 6 |
|
| 7 |
def get_answer(question):
|
| 8 |
-
# Define a
|
| 9 |
context = """
|
| 10 |
-
|
| 11 |
"""
|
| 12 |
answer = qa_pipeline(question=question, context=context)
|
| 13 |
return answer["answer"]
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load a question-answering model instead of a text generator
|
| 5 |
qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
|
| 6 |
|
| 7 |
def get_answer(question):
|
| 8 |
+
# Define a factual context
|
| 9 |
context = """
|
| 10 |
+
Washington, D.C. is the capital of the United States of America.
|
| 11 |
"""
|
| 12 |
answer = qa_pipeline(question=question, context=context)
|
| 13 |
return answer["answer"]
|