Views
No views yet
1>>> from transformers.pipelines import pipeline
2>>> from transformers import AutoTokenizer, AutoModelForQuestionAnswering
3
4>>> tokenizer = AutoTokenizer.from_pretrained("zhufy/squad-en-bert-base")
5>>> model = AutoModelForQuestionAnswering.from_pretrained("zhufy/squad-en-bert-base")
6>>> nlp = pipeline("question-answering", model=model, tokenizer=tokenizer)
7
8>>> context = "A problem is regarded as inherently difficult if its
9 solution requires significant resources, whatever the
10 algorithm used. The theory formalizes this intuition,
11 by introducing mathematical models of computation to
12 study these problems and quantifying the amount of
13 resources needed to solve them, such as time and storage.
14 Other complexity measures are also used, such as the
15 amount of communication (used in communication complexity),
16 the number of gates in a circuit (used in circuit
17 complexity) and the number of processors (used in parallel
18 computing). One of the roles of computational complexity
19 theory is to determine the practical limits on what
20 computers can and cannot do."
21
22>>> question = "What are two basic primary resources used to
23 guage complexity?"
24
25>>> inputs = {"question": question,
26 "context":context }
27
28>>> nlp(inputs)
29
30{'score': 0.8589141368865967,
31 'start': 305,
32 'end': 321,
33 'answer': 'time and storage'}
34