Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
pipe = pipeline("question-answering", model="ZongqianLi/bert-base-cased-scqa2")
|
5 |
-
text = st.text_area("enter some text")
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# 初始化管道
|
5 |
pipe = pipeline("question-answering", model="ZongqianLi/bert-base-cased-scqa2")
|
|
|
6 |
|
7 |
+
# 创建文本输入区域以供用户输入上下文和问题
|
8 |
+
context = st.text_area("Enter the context here")
|
9 |
+
question = st.text_input("Enter your question here")
|
10 |
+
|
11 |
+
# 当获取到问题和上下文后,执行问题回答
|
12 |
+
if context and question:
|
13 |
+
out = pipe({
|
14 |
+
'question': question,
|
15 |
+
'context': context
|
16 |
+
})
|
17 |
+
st.json(out)
|