nguyenvulebinh
commited on
Commit
•
662376d
1
Parent(s):
0fb532b
add description
Browse files
README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
---
|
2 |
language:
|
3 |
- vi
|
|
|
4 |
- en
|
5 |
tags:
|
6 |
- question-answering
|
@@ -17,3 +18,65 @@ widget:
|
|
17 |
- text: "Bình được công nhận với danh hiệu gì ?"
|
18 |
context: "Bình Nguyễn là một người đam mê với lĩnh vực xử lý ngôn ngữ tự nhiên . Anh nhận chứng chỉ Google Developer Expert năm 2020"
|
19 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
language:
|
3 |
- vi
|
4 |
+
- vn
|
5 |
- en
|
6 |
tags:
|
7 |
- question-answering
|
|
|
18 |
- text: "Bình được công nhận với danh hiệu gì ?"
|
19 |
context: "Bình Nguyễn là một người đam mê với lĩnh vực xử lý ngôn ngữ tự nhiên . Anh nhận chứng chỉ Google Developer Expert năm 2020"
|
20 |
---
|
21 |
+
## Model Description
|
22 |
+
|
23 |
+
- Language model: [XLM-RoBERTa](https://huggingface.co/transformers/model_doc/xlmroberta.html)
|
24 |
+
- Fine-tune: [MRCQuestionAnswering](https://github.com/nguyenvulebinh/extractive-qa-mrc)
|
25 |
+
- Language: Vietnamese, Englsih
|
26 |
+
- Downstream-task: Extractive QA
|
27 |
+
- Dataset (combine English and Vietnamese):
|
28 |
+
- [Squad 2.0](https://rajpurkar.github.io/SQuAD-explorer/)
|
29 |
+
- [mailong25](https://github.com/mailong25/bert-vietnamese-question-answering/tree/master/dataset)
|
30 |
+
- [UIT-ViQuAD](https://www.aclweb.org/anthology/2020.coling-main.233/)
|
31 |
+
- [MultiLingual Question Answering](https://github.com/facebookresearch/MLQA)
|
32 |
+
|
33 |
+
This model is intended to be used for QA in the Vietnamese language so the valid set is Vietnamese only (but English works fine). The evaluation result below using 10% of the Vietnamese dataset.
|
34 |
+
|
35 |
+
Model | EM | F1 |
|
36 |
+
|:---: |:---: |:---: |
|
37 |
+
base | 76.43 | 84.16 |
|
38 |
+
large | 77.32 | 85.46 |
|
39 |
+
|
40 |
+
[MRCQuestionAnswering](https://github.com/nguyenvulebinh/extractive-qa-mrc) using [XLM-RoBERTa](https://huggingface.co/transformers/model_doc/xlmroberta.html) as a pre-trained language model. By default, XLM-RoBERTa will split word in to sub-words. But in my implementation, I re-combine sub-words representation (after encoded by BERT layer) into word representation using sum strategy.
|
41 |
+
|
42 |
+
## Using pre-trained model
|
43 |
+
|
44 |
+
- Hugging Face pipeline style (**NOT using sum features strategy**).
|
45 |
+
|
46 |
+
```python
|
47 |
+
from transformers import pipeline
|
48 |
+
# model_checkpoint = "nguyenvulebinh/vi-mrc-large"
|
49 |
+
model_checkpoint = "nguyenvulebinh/vi-mrc-base"
|
50 |
+
nlp = pipeline('question-answering', model=model_checkpoint,
|
51 |
+
tokenizer=model_checkpoint)
|
52 |
+
QA_input = {
|
53 |
+
'question': "Bình là chuyên gia về gì ?",
|
54 |
+
'context': "Bình Nguyễn là một người đam mê với lĩnh vực xử lý ngôn ngữ tự nhiên . Anh nhận chứng chỉ Google Developer Expert năm 2020"
|
55 |
+
}
|
56 |
+
res = nlp(QA_input)
|
57 |
+
print('pipeline: {}'.format(res))
|
58 |
+
```
|
59 |
+
|
60 |
+
- More accurate infer process ([**Using sum features strategy**](https://github.com/nguyenvulebinh/extractive-qa-mrc))
|
61 |
+
```python
|
62 |
+
from infer import tokenize_function, data_collator, extract_answer
|
63 |
+
from model.mrc_model import MRCQuestionAnswering
|
64 |
+
from transformers import AutoTokenizer
|
65 |
+
|
66 |
+
# model_checkpoint = "nguyenvulebinh/vi-mrc-large"
|
67 |
+
model_checkpoint = "nguyenvulebinh/vi-mrc-base"
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
69 |
+
model = MRCQuestionAnswering.from_pretrained(model_checkpoint)
|
70 |
+
|
71 |
+
QA_input = {
|
72 |
+
'question': "Bình được công nhận với danh hiệu gì ?",
|
73 |
+
'context': "Bình Nguyễn là một người đam mê với lĩnh vực xử lý ngôn ngữ tự nhiên . Anh nhận chứng chỉ Google Developer Expert năm 2020"
|
74 |
+
}
|
75 |
+
|
76 |
+
inputs = [tokenize_function(*QA_input)]
|
77 |
+
inputs_ids = data_collator(inputs)
|
78 |
+
outputs = model(**inputs_ids)
|
79 |
+
answer = extract_answer(inputs, outputs, tokenizer)
|
80 |
+
|
81 |
+
print(answer)
|
82 |
+
```
|