stmnk commited on
Commit
44c842f
1 Parent(s): 9f65500

Create pipe.txt

Browse files
Files changed (1) hide show
  1. pipe.txt +22 -0
pipe.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
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}")
22
+ """