Spaces:
Runtime error
Runtime error
File size: 1,002 Bytes
4929642 35c7483 a3df29c 4929642 2a61345 4929642 b5fc908 4929642 2a61345 4929642 b5fc908 |
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 |
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)
|