Spaces:
Runtime error
Runtime error
pratik-aivantage
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -23,18 +23,16 @@
|
|
23 |
# iface.launch(share=True)
|
24 |
|
25 |
import gradio as gr
|
26 |
-
from transformers import
|
27 |
-
|
28 |
-
model_name = "gpt2"
|
29 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
30 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
31 |
|
|
|
|
|
32 |
|
|
|
33 |
def generate_answer(question):
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
return answer
|
38 |
|
39 |
iface = gr.Interface(
|
40 |
fn=generate_answer,
|
|
|
23 |
# iface.launch(share=True)
|
24 |
|
25 |
import gradio as gr
|
26 |
+
from transformers import pipeline
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
# Load the question answering pipeline
|
29 |
+
qa_pipeline = pipeline("question-answering", model="distilbert-base-cased-distilled-squad", tokenizer="distilbert-base-cased")
|
30 |
|
31 |
+
# Define a function to generate answer for the given question
|
32 |
def generate_answer(question):
|
33 |
+
# Call the question answering pipeline
|
34 |
+
result = qa_pipeline(question=question, context=None)
|
35 |
+
return result["answer"]
|
|
|
36 |
|
37 |
iface = gr.Interface(
|
38 |
fn=generate_answer,
|