File size: 6,920 Bytes
e72dc7c 1b53e0f 163db08 7df89e1 1b53e0f 7df89e1 1b53e0f b3f9993 1b53e0f e72dc7c 1b53e0f b3f9993 e72dc7c 1b53e0f e72dc7c b18e680 163db08 d0b93db eeb5506 f091ca6 1b53e0f f091ca6 27c6a86 1b53e0f 27c6a86 1b53e0f 83078d9 1b53e0f f091ca6 1b53e0f b18e680 1b53e0f b18e680 1b53e0f 163db08 5b91a3b 1b53e0f b18e680 5b91a3b 564c962 5b91a3b 1b53e0f 5b91a3b 564c962 5b91a3b 564c962 5b91a3b f80a6d9 5b91a3b 1733f36 5b91a3b b18e680 1b53e0f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
---
language:
- en
- de
- fr
- zh
- it
- es
- hi
- bn
- ar
- ru
- uk
- pt
- ur
- id
- ja
- ne
- nl
- tr
- ca
- bg
- yue
widget:
- text: >-
In December 1903 in France the Royal Swedish Academy of Sciences awarded
Pierre Curie, Marie Curie, and Henri Becquerel the Nobel Prize in Physics.
- text: >-
Für Richard Phillips Feynman war es immer wichtig in New York, die
unanschaulichen Gesetzmäßigkeiten der Quantenphysik Laien und Studenten
nahezubringen und verständlich zu machen.
- text: My name is Julian and I live in Constance.
- text: >-
Terence David John Pratchett est né le 28 avril 1948 à Beaconsfield dans le
Buckinghamshire, en Angleterre.
- text: >-
北京市,通称北京(汉语拼音:Běijīng;邮政式拼音:Peking),简称“京”,是中华人民共和国的首都及直辖市,是该国的政治、文化、科技、教育、军事和国际交往中心,是一座全球城市,是世界人口第三多的城市和人口最多的首都,具有重要的国际影响力,同時也是目前世界唯一的“双奥之城”,即唯一既主办过夏季
tags:
- roberta
- ner
- nlp
license: mit
datasets:
- wikiann
metrics:
- f1
- precision
- accuracy
- recall
---
# RoBERTa for Multilingual Named Entity Recognition
## Model description
This model detects entities by classifying every token according to the IOB format:
```python
['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC']
```
You can find the code in [this](https://github.com/julianschelb/roberta-ner-multilingual) Github repository.
## Training data
This model was fine-tuned on a portion of the [wikiann](https://huggingface.co/datasets/wikiann) dataset corresponding to the following languages:
```python
["en","de", "fr",
"zh", "it", "es",
"hi", "bn", "ar",
"ru", "uk", "pt",
"ur", "id", "ja",
"ne", "nl", "tr",
"ca", "bg", "zh-yue"]
```
The model was fine-tuned on 375.100 sentences in the training set, with a validation set of 173.100 examples. Performance metrics reported are based on additional 173.100 examples. The complete WikiANN dataset includes training examples for 282 languages and was constructed from Wikipedia. Training examples are extracted in an automated manner, exploiting entities mentioned in Wikipedia articles, often are formatted as hyperlinks to the source article. Provided NER tags are in the IOB2 format. Named entities are classified as location (LOC), person (PER), or organization (ORG).
## Evaluation results
This model achieves the following results (meassured using the test split of the [wikiann](https://huggingface.co/datasets/wikiann) dataset):
```python
{'LOC': {'f1': 0.9310524680196053,
'number': 545516,
'precision': 0.9230957726278464,
'recall': 0.9391475227124411},
'ORG': {'f1': 0.884603763901478,
'number': 363324,
'precision': 0.8868243944134171,
'recall': 0.8823942266406843},
'PER': {'f1': 0.939167449173159,
'number': 367750,
'precision': 0.934642687866253,
'recall': 0.9437362338545208},
'overall_accuracy': 0.9588396024156357,
'overall_f1': 0.9202625613733114,
'overall_precision': 0.9162434124141294,
'overall_recall': 0.9243171260937341}
```
## Usage
You can load this model by using the AutoTokenize and AutoModelForTokenClassification class:
```python
from transformers import AutoTokenizer, AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained("julian-schelb/roberta-ner-multilingual-wikiann/", add_prefix_space=True)
model = AutoModelForTokenClassification.from_pretrained("julian-schelb/roberta-ner-multilingual-wikiann/")
text = "In December 1903 in France the Royal Swedish Academy of Sciences awarded Pierre Curie, Marie Curie, and Henri Becquerel the Nobel Prize in Physics."
inputs = tokenizer(
text,
add_special_tokens=False,
return_tensors="pt"
)
with torch.no_grad():
logits = model(**inputs).logits
predicted_token_class_ids = logits.argmax(-1)
# Note that tokens are classified rather then input words which means that
# there might be more predicted token classes than words.
# Multiple token classes might account for the same word
predicted_tokens_classes = [model.config.id2label[t.item()] for t in predicted_token_class_ids[0]]
predicted_tokens_classes
```
## About RoBERTa
This model is a fine-tuned version of [XLM-RoBERTa](https://huggingface.co/xlm-roberta-large). The original model was pre-trained on 2.5TB of filtered CommonCrawl data containing 100 languages. It was introduced in the paper [Unsupervised Cross-lingual Representation Learning at Scale](https://arxiv.org/abs/1911.02116) by Conneau et al. and first released in [this repository](https://github.com/pytorch/fairseq/tree/master/examples/xlmr).
RoBERTa is a transformers model pretrained on a large corpus in a self-supervised fashion. This means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts.
More precisely, it was pretrained with the Masked language modeling (MLM) objective. Taking a sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the sentence.
This way, the model learns an inner representation of 100 languages that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard classifier using the features produced by the XLM-RoBERTa model as inputs.
#### Limitations and bias
This model is limited by its training dataset of entity-annotated news articles from a specific span of time. This may not generalize well for all use cases in different domains.
## Related Papers
* Pan, X., Zhang, B., May, J., Nothman, J., Knight, K., & Ji, H. (2017). Cross-lingual Name Tagging and Linking for 282 Languages. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) (pp. 1946–1958). Association for Computational Linguistics.
* Rahimi, A., Li, Y., & Cohn, T. (2019). Massively Multilingual Transfer for NER. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (pp. 151–164). Association for Computational Linguistics.
* Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., & Stoyanov, V.. (2019). RoBERTa: A Robustly Optimized BERT Pretraining Approach.
|