Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load the model
|
| 5 |
-
model = pipeline("
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Define the Gradio interface
|
| 11 |
interface = gr.Interface(
|
| 12 |
-
fn=
|
| 13 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter your
|
| 14 |
outputs="text",
|
| 15 |
-
title="
|
| 16 |
-
description="A
|
| 17 |
)
|
| 18 |
|
| 19 |
# Launch the interface
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the question-answering model
|
| 5 |
+
model = pipeline("question-answering", model="Rishitha0208/new-llm-for-advanced-materials")
|
| 6 |
|
| 7 |
+
def answer_question(question):
|
| 8 |
+
# Generate an answer from the model
|
| 9 |
+
result = model(question=question, context="") # Provide an empty context if not required
|
| 10 |
+
return result['answer']
|
| 11 |
|
| 12 |
# Define the Gradio interface
|
| 13 |
interface = gr.Interface(
|
| 14 |
+
fn=answer_question,
|
| 15 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your question here...", label="Question"),
|
| 16 |
outputs="text",
|
| 17 |
+
title="Polymer Knowledge Model",
|
| 18 |
+
description="A model fine-tuned to answer questions about polymers."
|
| 19 |
)
|
| 20 |
|
| 21 |
# Launch the interface
|