Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,9 +13,9 @@ st.markdown('## QA Dataset Auto Generation', unsafe_allow_html=True)
|
|
13 |
|
14 |
|
15 |
##########
|
16 |
-
#
|
17 |
##########
|
18 |
-
st.markdown('##
|
19 |
|
20 |
st.markdown('### Select a model: ', unsafe_allow_html=True)
|
21 |
|
@@ -59,7 +59,7 @@ with col2:
|
|
59 |
default_question = "To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"
|
60 |
default_context = """Architecturally, the school has a Catholic character. Atop the Main Building's gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary."""
|
61 |
|
62 |
-
question = st.text_input("Enter the question: ", value=
|
63 |
context = st.text_area("Enter the context: ", value=default_context, height=100)
|
64 |
|
65 |
# 添加一个按钮,用户点击后执行问答
|
@@ -75,37 +75,38 @@ if st.button('Extract the answer'):
|
|
75 |
else:
|
76 |
st.write("Please enter both a question and context.")
|
77 |
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
""
|
80 |
-
|
81 |
-
default_context = "The referential DSSC with Pt CE was also measured under the same conditions, which yields η of 6.66% (Voc= 0.78 V, Jsc= 13.0 mA cm−2, FF = 65.9%)."
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
# 添加一个按钮,用户点击后执行问答
|
88 |
-
if st.button('Extract the property'):
|
89 |
-
question_1 = f"What is the value of {property}?"
|
90 |
-
if context and question_1:
|
91 |
-
out = pipe({
|
92 |
-
'question': question_1,
|
93 |
-
'context': context
|
94 |
-
})
|
95 |
-
value = out["answer"]
|
96 |
-
st.write(f"First-turn question: {question_1}")
|
97 |
-
st.write(f"First-turn answer: {value}")
|
98 |
-
question_2 = f"What material has {property} of {value}?"
|
99 |
-
out = pipe({
|
100 |
-
'question': question_2,
|
101 |
-
'context': context
|
102 |
-
})
|
103 |
-
material = out["answer"]
|
104 |
-
st.write(f"Second-turn question: {question_2}")
|
105 |
-
st.write(f"First-turn answer: {material}")
|
106 |
-
else:
|
107 |
-
st.write("Please enter both a question and context.")
|
108 |
-
"""
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
|
|
|
13 |
|
14 |
|
15 |
##########
|
16 |
+
# Question Answering
|
17 |
##########
|
18 |
+
st.markdown('## Question Answering', unsafe_allow_html=True)
|
19 |
|
20 |
st.markdown('### Select a model: ', unsafe_allow_html=True)
|
21 |
|
|
|
59 |
default_question = "To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"
|
60 |
default_context = """Architecturally, the school has a Catholic character. Atop the Main Building's gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary."""
|
61 |
|
62 |
+
question = st.text_input("Enter the question: ", value=default_question)
|
63 |
context = st.text_area("Enter the context: ", value=default_context, height=100)
|
64 |
|
65 |
# 添加一个按钮,用户点击后执行问答
|
|
|
75 |
else:
|
76 |
st.write("Please enter both a question and context.")
|
77 |
|
78 |
+
##########
|
79 |
+
# Property Extraction
|
80 |
+
##########
|
81 |
+
st.markdown('## Property Extraction', unsafe_allow_html=True)
|
82 |
|
83 |
+
default_property = "FF"
|
84 |
+
default_context = "The referential DSSC with Pt CE was also measured under the same conditions, which yields η of 6.66% (Voc= 0.78 V, Jsc= 13.0 mA cm−2, FF = 65.9%)."
|
|
|
85 |
|
86 |
+
# 获取用户输入的问题和上下文
|
87 |
+
property = st.text_input("Enter the name of the property: ", value=default_property)
|
88 |
+
context = st.text_area("Enter the context: ", value=default_context, height=100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
# 添加一个按钮,用户点击后执行问答
|
91 |
+
if st.button('Extract the property'):
|
92 |
+
question_1 = f"What is the value of {property}?"
|
93 |
+
if context and question_1:
|
94 |
+
out = pipe({
|
95 |
+
'question': question_1,
|
96 |
+
'context': context
|
97 |
+
})
|
98 |
+
value = out["answer"]
|
99 |
+
st.write(f"First-turn question: {question_1}")
|
100 |
+
st.write(f"First-turn answer: {value}")
|
101 |
+
question_2 = f"What material has {property} of {value}?"
|
102 |
+
out = pipe({
|
103 |
+
'question': question_2,
|
104 |
+
'context': context
|
105 |
+
})
|
106 |
+
material = out["answer"]
|
107 |
+
st.write(f"Second-turn question: {question_2}")
|
108 |
+
st.write(f"First-turn answer: {material}")
|
109 |
+
else:
|
110 |
+
st.write("Please enter both a question and context.")
|
111 |
|
112 |
|