KoichiYasuoka commited on
Commit
9c109fa
1 Parent(s): cbbba0e

align_to_words=False

Browse files
Files changed (1) hide show
  1. README.md +3 -9
README.md CHANGED
@@ -28,17 +28,11 @@ This is a DeBERTa(V2) model pretrained on Japanese Wikipedia and 青空文庫 te
28
  ## How to Use
29
 
30
  ```py
31
- import torch
32
- from transformers import AutoTokenizer,AutoModelForQuestionAnswering
33
  tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/deberta-base-japanese-wikipedia-ud-head")
34
  model=AutoModelForQuestionAnswering.from_pretrained("KoichiYasuoka/deberta-base-japanese-wikipedia-ud-head")
35
- question="国語"
36
- context="全学年にわたって小学校の国語の教科書に挿し絵が用いられている"
37
- inputs=tokenizer(question,context,return_tensors="pt",return_offsets_mapping=True)
38
- offsets=inputs.pop("offset_mapping").tolist()[0]
39
- outputs=model(**inputs)
40
- start,end=torch.argmax(outputs.start_logits),torch.argmax(outputs.end_logits)
41
- print(context[offsets[start][0]:offsets[end][-1]])
42
  ```
43
 
44
  or (with [ufal.chu-liu-edmonds](https://pypi.org/project/ufal.chu-liu-edmonds/))
 
28
  ## How to Use
29
 
30
  ```py
31
+ from transformers import AutoTokenizer,AutoModelForQuestionAnswering,QuestionAnsweringPipeline
 
32
  tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/deberta-base-japanese-wikipedia-ud-head")
33
  model=AutoModelForQuestionAnswering.from_pretrained("KoichiYasuoka/deberta-base-japanese-wikipedia-ud-head")
34
+ qap=QuestionAnsweringPipeline(tokenizer=tokenizer,model=model,align_to_words=False)
35
+ print(qap(question="国語",context="全学年にわたって小学校の国語の教科書に挿し絵>が用いられている"))
 
 
 
 
 
36
  ```
37
 
38
  or (with [ufal.chu-liu-edmonds](https://pypi.org/project/ufal.chu-liu-edmonds/))