OLM RoBERTa/BERT October 2022
This is a more up-to-date version of the original BERT and original RoBERTa. In addition to being more up-to-date, it also tends to perform better than the original BERT on standard benchmarks. We think it is fair to directly compare our model to the original BERT because our model was trained with about the same level of compute as the original BERT, and the architecture of BERT and RoBERTa are basically the same. The original RoBERTa takes an order of magnitude more compute, although our model is also not that different in performance from the original RoBERTa on many standard benchmarks. Our model was trained on a cleaned October 2022 snapshot of Common Crawl and Wikipedia.
This model was created as part of the OLM project, which has the goal of continuously training and releasing models that are up-to-date and comparable in standard language model performance to their static counterparts. This is important because we want our models to know about events like COVID or a presidential election right after they happen.
Intended uses
You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task, such as sequence classification, token classification or question answering.
How to use
You can use this model directly with a pipeline for masked language modeling:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='olm/olm-roberta-base-oct-2022')
>>> unmasker("Hello I'm a <mask> model.")
[{'score': 0.10601336508989334,
'token': 2450,
'token_str': ' role',
'sequence': "Hello I'm a role model."},
{'score': 0.05792810395359993,
'token': 2677,
'token_str': ' former',
'sequence': "Hello I'm a former model."},
{'score': 0.057744599878787994,
'token': 1968,
'token_str': ' professional',
'sequence': "Hello I'm a professional model."},
{'score': 0.029099510982632637,
'token': 932,
'token_str': ' business',
'sequence': "Hello I'm a business model."},
{'score': 0.024220379069447517,
'token': 1840,
'token_str': ' young',
'sequence': "Hello I'm a young model."}]
Here is how to use this model to get the features of a given text in PyTorch:
from transformers import AutoTokenizer, RobertaModel
tokenizer = AutoTokenizer.from_pretrained('olm/olm-roberta-base-oct-2022')
model = RobertaModel.from_pretrained("olm/olm-roberta-base-oct-2022")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
Dataset
The model and tokenizer were trained with this October 2022 cleaned Common Crawl dataset plus this October 2022 cleaned Wikipedia dataset.
The tokenized version of these concatenated datasets is here.
The datasets were created with this repo.
Training
The model was trained according to the OLM BERT/RoBERTa instructions at this repo.
Evaluation results
The model achieves the following results after tuning on GLUE tasks:
Task | Metric | Original BERT | OLM RoBERTa Oct 2022 (Ours) |
---|---|---|---|
cola | mcc | 0.5889 | 0.2340 |
sst2 | acc | 0.9181 | 0.9305 |
mrpc | acc/f1 | 0.9182/0.8923 | 0.8828/0.9149 |
stsb | pear/spear | 0.8822/0.8794 | 0.8943/0.8934 |
qqp | acc/f1 | 0.9071/0.8748 | 0.9094/0.8781 |
mnli | acc/acc_mm | 0.8400/0.8410 | 0.8599/0.8622 |
qnli | acc | 0.9075 | 0.9148 |
rte | acc | 0.6296 | 0.6253 |
wnli | acc | 0.4000 | 0.5042 |
For both the original BERT and our model, we used the Hugging Face run_glue.py script here. For both models, we used the default fine-tuning hyperparameters and we averaged the results over five training seeds. These are the results for the GLUE dev sets, which can be a bit different than the results for the test sets.
- Downloads last month
- 10