distilbert-base-uncased

Version: 14
DistilBERT is a transformers model, smaller and faster than BERT, which was pretrained on the same corpus in a
self-supervised fashion, using the BERT base model as a teacher. 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 using the BERT base model. More precisely, it was pretrained
with three objectives:
  • Distillation loss: the model was trained to return the same probabilities as the BERT base model.
  • Masked language modeling (MLM): this is part of the original training loss of the BERT base model. When 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.
  • Cosine embedding loss: the model was also trained to generate hidden states as close as possible as the BERT base
    model.
This way, the model learns the same inner representation of the English language than its teacher model, while being
faster for inference or downstream tasks.
This model is a distilled version of the BERT base model . It was
introduced in this paper . The code for the distillation process can be found
here .
Note: This model is uncased: it does not make a difference between english and English.

Training Data

DistilBERT pretrained on the same data as BERT, which is BookCorpus , a dataset
consisting of 11,038 unpublished books and English Wikipedia
(excluding lists, tables and headers).

Training Procedure

Preprocessing

The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
then of the form:
[CLS] Sentence A [SEP] Sentence B [SEP]
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
"sentences" has a combined length of less than 512 tokens.
The details of the masking procedure for each sentence are the following:
  • 15% of the tokens are masked.
  • In 80% of the cases, the masked tokens are replaced by [MASK].
  • In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
  • In the 10% remaining cases, the masked tokens are left as is.

Pretraining

The model was trained on 8 16 GB V100 for 90 hours. See the
training code for all hyperparameters
details.
When fine-tuned on downstream tasks, this model achieves the following results: Glue test results:
TaskMNLIQQPQNLISST-2CoLASTS-BMRPCRTE
82.288.589.291.351.385.887.559.9

Quick facts

Model provider
TypeFill mask
LifecycleGenerally available (GA)