stmnk commited on
Commit
a2a1e86
·
1 Parent(s): 3dc5ca1

add pipeline

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -1,4 +1,21 @@
1
  import streamlit as st
 
2
 
3
  x = st.slider('Select a value')
4
  st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
 
4
  x = st.slider('Select a value')
5
  st.write(x, 'squared is', x * x)
6
+
7
+ question_answerer = pipeline("question-answering")
8
+
9
+ context = r""" Extractive Question Answering is the task of extracting an answer from a text given a question.
10
+ An example of a question answering dataset is the SQuAD dataset, which is entirely based on that task.
11
+ If you would like to fine-tune a model on a SQuAD task, you may leverage the
12
+ examples/pytorch/question-answering/run_squad.py script."""
13
+ question = "What is extractive question answering?" #"What is a good example of a question answering dataset?"
14
+ result = question_answerer(question=question, context=context)
15
+ answer = result['answer']
16
+ score = round(result['score'], 4)
17
+ span = f"start: {result['start']}, end: {result['end']}"
18
+
19
+ st.write(answer)
20
+ st.write(f"score: {score}")
21
+ st.write(f"span: {span}")