hhou435 commited on
Commit
bc0e9f1
1 Parent(s): d5be715

Update README

Browse files
Files changed (1) hide show
  1. README.md +7 -6
README.md CHANGED
@@ -17,12 +17,13 @@ The model is used for extractive question answering. You can download the model
17
  You can use the model directly with a pipeline for extractive question answering:
18
 
19
  ```python
20
- >>> from transformers import pipeline
21
- >>> path = 'uer/roberta-base-chinese-extractive-qa'
22
- >>> nlp = pipeline('question-answering', model=path, tokenizer=path)
23
- >>> QA_input = {'question': "小王在哪上学?",'context': "小王在北京上学,他今年二十岁。"}
24
- >>> nlp(QA_input)
25
- {'score': 0.7618623375892639, 'start': 3, 'end': 5, 'answer': '北京'}
 
26
  ```
27
 
28
  ## Training data
 
17
  You can use the model directly with a pipeline for extractive question answering:
18
 
19
  ```python
20
+ >>> from transformers import AutoModelForQuestionAnswering,AutoTokenizer,pipeline
21
+ >>> model = AutoModelForQuestionAnswering.from_pretrained('uer/roberta-base-chinese-extractive-qa')
22
+ >>> tokenizer = AutoTokenizer.from_pretrained('uer/roberta-base-chinese-extractive-qa')
23
+ >>> QA = pipeline('question-answering', model=model, tokenizer=tokenizer)
24
+ >>> QA_input = {'question': "著名诗歌《假如生活欺骗了你》的作者是",'context': "普希金从那里学习人民的语言,吸取了许多有益的养料,这一切对普希金后来的创作产生了很大的影响。这两年里,普希金创作了不少优秀的作品,如《囚徒》、《致大海》、《致凯恩》和《假如生活欺骗了你》等几十首抒情诗,叙事诗《努林伯爵》,历史剧《鲍里斯·戈都诺夫》,以及《叶甫盖尼·奥涅金》前六章。"}
25
+ >>> QA(QA_input)
26
+ {'score': 0.9766426682472229, 'start': 0, 'end': 3, 'answer': '普希金'}
27
  ```
28
 
29
  ## Training data