Michael Beukman
commited on
Commit
•
fcdd65a
1
Parent(s):
fc7e38f
Added Model Card
Browse files
README.md
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- rw
|
4 |
+
tags:
|
5 |
+
- NER
|
6 |
+
datasets:
|
7 |
+
- masakhaner
|
8 |
+
metrics:
|
9 |
+
- f1
|
10 |
+
- precision
|
11 |
+
- recall
|
12 |
+
---
|
13 |
+
|
14 |
+
|
15 |
+
# xlm-roberta-base-finetuned-kinyarwanda-finetuned-ner-kinyarwanda
|
16 |
+
This is a token classification (specifically NER) model that fine-tuned [xlm-roberta-base-finetuned-kinyarwanda](https://huggingface.co/Davlan/xlm-roberta-base-finetuned-kinyarwanda) on the [MasakhaNER](https://arxiv.org/abs/2103.11811) dataset, specifically the Kinyarwanda part.
|
17 |
+
|
18 |
+
More information, and other similar models can be found in the [main Github repository](https://github.com/Michael-Beukman/NERTransfer).
|
19 |
+
|
20 |
+
## About
|
21 |
+
This models is transformer based and was fine-tuned on the MasakhaNER dataset. It is a named entity recognition dataset, containing mostly news articles in 10 different African languages.
|
22 |
+
The model was fine-tuned for 50 epochs, with a maximum sequence length of 200, 32 batch size, 5e-5 learning rate. This process was repeated 5 times (with different random seeds), and this uploaded model performed the best out of those 5 seeds (aggregate F1 on on test set).
|
23 |
+
|
24 |
+
These models were fine-tuned by me, Michael Beukman, while doing a project at the University of the Witwatersrand, Johannesburg.
|
25 |
+
## Data
|
26 |
+
The train, evaluation and test datasets were taken directly from the MasakhaNER [Github](https://github.com/masakhane-io/masakhane-ner) repository, with minimal to no preprocessing.
|
27 |
+
The motivation for the use of this data is that it is the "first large, publicly available, high quality dataset for named entity recognition (NER) in ten African languages" ([source](https://arxiv.org/pdf/2103.11811.pdf)). The high-quality data, as well as the groundwork laid by the paper introducing it are some more reasons why this dataset was used. For evaluation, the dedicated test split was used, which is from the same distribution as the training data, so the models may not generalise to other distributions. The exact distribution of the data is covered in detail [here](https://arxiv.org/abs/2103.11811).
|
28 |
+
|
29 |
+
## Intended Use
|
30 |
+
This model are intended to be used for NLP research into e.g. interpretability or transfer learning. Using this model in production is not supported, as generalisability and downright performance is limited. In particular, this is not designed to be used in any important downstream task that could affect people, as harm could be caused by the limitations of the model, described next.
|
31 |
+
|
32 |
+
## Limitations
|
33 |
+
These models were only trained on one (relatively small) dataset, covering one task (NER) in one domain (news articles) and in a set span of time. The results may not generalise, and the model may perform badly, or in an unfair / biased way if used on other tasks. Although the purpose of this project was to investigate transfer learning, the performance on languages that the model was not trained for does suffer.
|
34 |
+
|
35 |
+
|
36 |
+
Because this model used xlm-roberta-base as its starting point (potentially with domain adaptive fine-tuning on specific languages), this model's limitations can also apply here. These can include being biased towards the hegemonic viewpoint of most of its training data, being ungrounded and having subpar results on other languages (possibly due to unbalanced training data).
|
37 |
+
|
38 |
+
As [Adelani et al. (2021)](https://arxiv.org/abs/2103.11811) showed, the models in general struggled with entities that were either longer than 3 words and entities that were not contained in the training data. This could bias the models towards not finding, e.g. names of people that have many words, possibly leading to a misrepresentation in the results. Similarly, names that are uncommon, and may not have been found in the training data (due to e.g. different languages) would also be predicted less often.
|
39 |
+
|
40 |
+
|
41 |
+
Additionally, this model has not been verified in practice, and other, more subtle problems may become prevalent if used without any verification that it does what it is supposed to.
|
42 |
+
## Privacy
|
43 |
+
The data comes from only publicly available news sources, the only available data should cover public figures and those that agreed to be reported on. See the original MasakhaNER paper for more details.
|
44 |
+
|
45 |
+
## Training Resources
|
46 |
+
In the interest of openness, and reporting resources used, we list here how long the training process took, as well as what the minimum resources would be to reproduce this. Fine-tuning each model on the NER dataset took between 10 and 30 minutes, and was performed on a NVIDIA RTX3090 GPU. To use a batch size of 32, at least 14GB of GPU memory was required, although it was just possible to fit these models in around 6.5GB's of VRAM when using a batch size of 1.
|
47 |
+
## Contact
|
48 |
+
For more information about the models, you can contact me by filing an issue on the [main Github repository](https://github.com/Michael-Beukman/NERTransfer).
|
49 |
+
|
50 |
+
## Metrics
|
51 |
+
The language adaptive models achieve (mostly) superior performance over starting with xlm-roberta-base. Our main metric was the aggregate F1 score for all NER categories.
|
52 |
+
|
53 |
+
These metrics are on the test set for MasakhaNER, so the data distribution is similar to the training set, so these results do not directly indicate how well models generalise.
|
54 |
+
We do find large variation in transfer results when starting from different seeds, indicating that the fine-tuning process for transfer might be unstable.
|
55 |
+
## Model Structure
|
56 |
+
Here are some performance details on this specific model, compared to others we trained.
|
57 |
+
All of these metrics were calculated on the test set, and the seed was chosen that gave the best overall F1 score. The first three result columns are averaged over all categories, and the latter 4 provide performance broken down by category.
|
58 |
+
|
59 |
+
|
60 |
+
| Model Name | Staring point | Evaluation Language | F1 | Precision | Recall | F1 (DATE) | F1 (LOC) | F1 (ORG) | F1 (PER) |
|
61 |
+
| -------------------------------------------------- | -------------------- | -------------------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- |
|
62 |
+
| [xlm-roberta-base-finetuned-kinyarwanda-finetuned-ner-kinyarwanda](https://huggingface.co/mbeukman/xlm-roberta-base-finetuned-kinyarwanda-finetuned-ner-kinyarwanda) (This model) | [kin](https://huggingface.co/Davlan/xlm-roberta-base-finetuned-kinyarwanda) | kin | 79.55 | 75.56 | 83.99 | 69.00 | 79.00 | 77.00 | 90.00 |
|
63 |
+
| [xlm-roberta-base-finetuned-swahili-finetuned-ner-kinyarwanda](https://huggingface.co/mbeukman/xlm-roberta-base-finetuned-swahili-finetuned-ner-kinyarwanda) | [swa](https://huggingface.co/Davlan/xlm-roberta-base-finetuned-swahili) | kin | 76.31 | 72.64 | 80.37 | 70.00 | 76.00 | 75.00 | 84.00 |
|
64 |
+
| [xlm-roberta-base-finetuned-ner-kinyarwanda](https://huggingface.co/mbeukman/xlm-roberta-base-finetuned-ner-kinyarwanda) | [base](https://huggingface.co/xlm-roberta-base) | kin | 74.59 | 72.17 | 77.17 | 70.00 | 75.00 | 70.00 | 82.00 |
|
65 |
+
## Usage
|
66 |
+
To use these models, you can do the following, with just changing the model name ([source](https://huggingface.co/dslim/bert-base-NER)):
|
67 |
+
|
68 |
+
```
|
69 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
70 |
+
from transformers import pipeline
|
71 |
+
model_name = 'mbeukman/xlm-roberta-base-finetuned-kinyarwanda-finetuned-ner-kinyarwanda'
|
72 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
73 |
+
model = AutoModelForTokenClassification.from_pretrained(model_name)
|
74 |
+
|
75 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
|
76 |
+
example = "A (Kinyarwanda) sentence that may contain entities"
|
77 |
+
|
78 |
+
ner_results = nlp(example)
|
79 |
+
print(ner_results)
|
80 |
+
```
|