Matt Hartman commited on
Commit
c8931c8
1 Parent(s): cd7c7d7

question answer

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
  import gradio as gr
2
 
3
+ from transformers import pipeline
4
+ model = pipeline(task="question-answering", model="deepset/roberta-base-squad2")
5
+
6
+ context = """
7
+ The Sun is the star at the center of the Solar System. It is a nearly perfect ball of hot plasma, heated to incandescence by nuclear fusion reactions in its core, radiating the energy mainly as light, ultraviolet, and infrared radiation. It is the most important source of energy for life on Earth.
8
+
9
+ The Sun's diameter is about 1.39 million kilometers (864,000 miles), or 109 times that of Earth. Its mass is about 330,000 times that of Earth, comprising about 99.86% of the total mass of the Solar System. Roughly three-quarters of the Sun's mass consists of hydrogen (~73%); the rest is mostly helium (~25%), with much smaller quantities of heavier elements, including oxygen, carbon, neon, and iron.
10
+ """
11
+
12
+ question = "What does the sun provide to the earth?"
13
+ response = model({ "question": question, "context": context })
14
+
15
+
16
  def greet(name):
17
+ response = model({ name: question, "context": context })
18
+ return response
19
 
20
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
21
  iface.launch()