Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,20 +3,11 @@ from transformers import pipeline
|
|
3 |
|
4 |
st.markdown("# Auto-generating Question-Answering Datasets with Domain-Specific Knowledge for Language Models in Scientific Tasks", unsafe_allow_html=True)
|
5 |
|
6 |
-
##########
|
7 |
# Transformation Algorithm
|
8 |
-
##########
|
9 |
st.markdown('## QA Dataset Auto Generation', unsafe_allow_html=True)
|
10 |
|
11 |
-
|
12 |
-
|
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 |
|
22 |
# 定义模型配置选项
|
@@ -43,26 +34,29 @@ st.markdown(f'##### {model}', unsafe_allow_html=True)
|
|
43 |
|
44 |
# 加载问答模型
|
45 |
pipe = pipeline("question-answering", model=model)
|
46 |
-
|
47 |
st.markdown('### QA: ', unsafe_allow_html=True)
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
col1, col2 = st.columns(2)
|
50 |
|
51 |
with col1:
|
52 |
if st.button("Solar Cell QA Dataset"):
|
53 |
-
default_question = "What is the value of FF?"
|
54 |
-
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%)."
|
55 |
-
|
56 |
-
default_question = ""
|
57 |
-
default_context = ""
|
58 |
|
59 |
with col2:
|
60 |
if st.button("SuAD Dataset QA"):
|
61 |
-
default_question = "To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"
|
62 |
-
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."""
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
66 |
|
67 |
# 添加一个按钮,用户点击后执行问答
|
68 |
if st.button('Extract the answer'):
|
|
|
3 |
|
4 |
st.markdown("# Auto-generating Question-Answering Datasets with Domain-Specific Knowledge for Language Models in Scientific Tasks", unsafe_allow_html=True)
|
5 |
|
|
|
6 |
# Transformation Algorithm
|
|
|
7 |
st.markdown('## QA Dataset Auto Generation', unsafe_allow_html=True)
|
8 |
|
|
|
|
|
|
|
|
|
|
|
9 |
# Question Answering
|
|
|
10 |
st.markdown('## Question Answering', unsafe_allow_html=True)
|
|
|
11 |
st.markdown('### Select a model: ', unsafe_allow_html=True)
|
12 |
|
13 |
# 定义模型配置选项
|
|
|
34 |
|
35 |
# 加载问答模型
|
36 |
pipe = pipeline("question-answering", model=model)
|
|
|
37 |
st.markdown('### QA: ', unsafe_allow_html=True)
|
38 |
|
39 |
+
# 使用Session State来存储默认的问题和上下文
|
40 |
+
if 'default_question' not in st.session_state:
|
41 |
+
st.session_state['default_question'] = ""
|
42 |
+
if 'default_context' not in st.session_state:
|
43 |
+
st.session_state['default_context'] = ""
|
44 |
+
|
45 |
col1, col2 = st.columns(2)
|
46 |
|
47 |
with col1:
|
48 |
if st.button("Solar Cell QA Dataset"):
|
49 |
+
st.session_state['default_question'] = "What is the value of FF?"
|
50 |
+
st.session_state['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%)."
|
|
|
|
|
|
|
51 |
|
52 |
with col2:
|
53 |
if st.button("SuAD Dataset QA"):
|
54 |
+
st.session_state['default_question'] = "To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"
|
55 |
+
st.session_state['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."""
|
56 |
+
|
57 |
+
# 这些输入字段现在使用session state来填充默认值
|
58 |
+
question = st.text_input("Enter the question: ", value=st.session_state['default_question'])
|
59 |
+
context = st.text_area("Enter the context: ", value=st.session_state['default_context'], height=100)
|
60 |
|
61 |
# 添加一个按钮,用户点击后执行问答
|
62 |
if st.button('Extract the answer'):
|