Spaces:
Runtime error
Runtime error
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline | |
import streamlit as st | |
model_name = "deepset/roberta-base-squad2" | |
# a) Get predictions | |
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name) | |
def main(): | |
st.title("English to German") | |
with st.form("text_field"): | |
text = st.text_area('enter some english word:') | |
# clicked==True only when the button is clicked | |
clicked = st.form_submit_button("Submit") | |
if clicked: | |
results = classifier([text]) | |
st.json(results) | |
if __name__ == "__main__": | |
main() | |
QA_input = { | |
'question': 'Why is model conversion important?', | |
'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.' | |
} | |
res = nlp(QA_input) | |
# b) Load model & tokenizer | |
model = AutoModelForQuestionAnswering.from_pretrained(model_name) | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |