rish13 commited on
Commit
8937d91
·
verified ·
1 Parent(s): b29446e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
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("text-generation", model="Rishitha0208/new-llm-for-advanced-materials")
6
 
7
- def generate_text(prompt):
8
- return model(prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
 
 
9
 
10
  # Define the Gradio interface
11
  interface = gr.Interface(
12
- fn=generate_text,
13
- inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
14
  outputs="text",
15
- title="Text Generation Model",
16
- description="A text generation model using Hugging Face Transformers."
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