ZongqianLi commited on
Commit
f881630
·
verified ·
1 Parent(s): 24e19f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
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
- if text:
8
- out = pipe(text)
9
- st.json(out)
 
 
 
 
 
 
 
 
 
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)