File size: 871 Bytes
ade7754
 
 
30821be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24e19f9
45a301c
6302321
 
 
f881630
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import streamlit as st
from transformers import pipeline

# 定义一个包含模型名称的列表
models = [
    "bert-base-uncased",
    "distilbert-base-uncased",
    "roberta-base",
    "gpt2",
    "ZongqianLi/bert-base-cased-scqa2"  # 你可以在这里添加更多模型
]

# 使用st.selectbox创建一个下拉选择框,让用户从列表中选择一个模型
model = st.selectbox("Choose a model:", models)

# 显示用户当前选择的模型
st.write(f"You selected: {model}")

pipe = pipeline("question-answering", model="ZongqianLi/bert-base-cased-scqa2")

st.write("Here's our first attempt at using data to create a table:")

context = st.text_input("Enter the context here")
question = st.text_input("Enter your question here")

if context and question:
    out = pipe({
        'question': question,
        'context': context
    })
    st.json(out)