KoichiYasuoka commited on
Commit
c8b64c4
1 Parent(s): e58dcf1

align_to_words=False

Browse files
Files changed (1) hide show
  1. README.md +3 -9
README.md CHANGED
@@ -27,17 +27,11 @@ This is a DeBERTa(V2) model pretrained on Thai Wikipedia texts for dependency-pa
27
  ## How to Use
28
 
29
  ```py
30
- import torch
31
- from transformers import AutoTokenizer,AutoModelForQuestionAnswering
32
  tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/deberta-base-thai-ud-head")
33
  model=AutoModelForQuestionAnswering.from_pretrained("KoichiYasuoka/deberta-base-thai-ud-head")
34
- question="กว่า"
35
- context="หลายหัวดีกว่าหัวเดียว"
36
- inputs=tokenizer(question,context,return_tensors="pt",return_offsets_mapping=True)
37
- offsets=inputs.pop("offset_mapping").tolist()[0]
38
- outputs=model(**inputs)
39
- start,end=torch.argmax(outputs.start_logits),torch.argmax(outputs.end_logits)
40
- print(context[offsets[start][0]:offsets[end][-1]])
41
  ```
42
 
43
  or (with [ufal.chu-liu-edmonds](https://pypi.org/project/ufal.chu-liu-edmonds/))
 
27
  ## How to Use
28
 
29
  ```py
30
+ from transformers import AutoTokenizer,AutoModelForQuestionAnswering,QuestionAnsweringPipeline
 
31
  tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/deberta-base-thai-ud-head")
32
  model=AutoModelForQuestionAnswering.from_pretrained("KoichiYasuoka/deberta-base-thai-ud-head")
33
+ qap=QuestionAnsweringPipeline(tokenizer=tokenizer,model=model,align_to_words=False)
34
+ print(qap(question="กว่า",context="หลายหัวดีกว่าหัวเดียว"))
 
 
 
 
 
35
  ```
36
 
37
  or (with [ufal.chu-liu-edmonds](https://pypi.org/project/ufal.chu-liu-edmonds/))