Spaces:
Sleeping
Sleeping
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) | |