Edit model card

RoBERTa for Multilingual Named Entity Recognition

Model description

This model detects entities by classifying every token according to the IOB format:

['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC']

Languages:

TBD

Training data

This mode was traind using a subset of all wikiann dataset.

Evaluation results

This model achieves the following results (meassured using the validation portion of the wikiann):

{'LOC': {'f1': 0.8541617653978262,
         'number': 42016,
         'precision': 0.8444273885942878,
         'recall': 0.8641231911652704},
 'ORG': {'f1': 0.7504633739856393,
         'number': 31226,
         'precision': 0.7305394669011736,
         'recall': 0.7715045154678793},
 'PER': {'f1': 0.8639735635284596,
         'number': 29647,
         'precision': 0.863711444463172,
         'recall': 0.8642358417377812},
 'overall_accuracy': 0.926459490605155,
 'overall_f1': 0.8250250567072849,
 'overall_precision': 0.814290312198262,
 'overall_recall': 0.8360466133405904}

Per Entity Type:

TBD

Per Language:

TBD

About RoBERTa

This model is a fine-tuned version of XLM-RoBERTa. 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 by Conneau et al. and first released in this repository.

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.

Usage

You can use this model by using the AutoTokenize and AutoModelForTokenClassification class:

from transformers import AutoTokenizer, AutoModelForTokenClassification 

tokenizer = AutoTokenizer.from_pretrained("julian-schelb/roberta-ner-multilingual/", add_prefix_space=True)                          
model = AutoModelForTokenClassification.from_pretrained("julian-schelb/roberta-ner-multilingual/")

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

BibTeX entry and citation info

TBD
Downloads last month
171
Hosted inference API
Token Classification
Examples
Examples
This model can be loaded on the Inference API on-demand.

Dataset used to train julian-schelb/roberta-ner-multilingual