Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Universal Language Model Fine-tuning for Text Classification

Fine-tuned language models classify text with little labeled data

  • Problem Transfer in NLP mostly reused word embeddings, and fine-tuning a language model overfit small labeled sets and forgot pretrained knowledge. Classifiers therefore needed task-specific design and training from scratch.
  • Method ULMFiT pretrains a 3-layer LSTM language model on Wikitext-103, then fine-tunes it on the target text. It uses per-layer learning rates and slanted triangular rates, and gradually unfreezes layers while training a classifier head.
  • Results ULMFiT reduces error by 18 to 24 percent on most of six text classification datasets. With only 100 labeled examples it matches training from scratch on 100 times more data.

Why language model fine-tuning had stalled for NLP

Most NLP transfer has been limited to the embedding layer. Pretrained word vectors serve as inputs, while the task model is still trained from scratch. Methods that concatenate embeddings from other tasks at several layers keep the pretrained parts fixed, which limits how much the main model can benefit. Dai and Le (2015) fine-tuned a language model, but they needed millions of in-domain documents for good results and overfit with 10k labeled examples.

The authors locate the failure in how these models were trained rather than in the idea itself. Language models overfit small datasets, and they lose pretrained knowledge through catastrophic forgetting when a classifier is attached. NLP models are also shallower than vision models, so the fine-tuning recipe borrowed from vision needs different techniques.

A three-stage recipe built on one language model

ULMFiT uses the same 3-layer LSTM for every task, with the same hyperparameters and only the dropout settings tuned. The LSTM is a regular one, with no attention and no shortcut connections, so the gains come from the training procedure rather than from architectural additions.

A language model is used as the source task because raw text is available in close to unlimited amounts for most domains and languages. Predicting the next words requires the model to pick up long-term dependencies, hierarchical relations and sentiment, which many downstream tasks need.

The procedure runs in three steps: a general-domain language model is pretrained, that model is fine-tuned on the target task's text, and a classifier is fine-tuned on top of it. The method aims to meet four practical criteria. It has to work across tasks that differ in document size, number and label type. It has to use one architecture and one training procedure.

It has to need no custom feature engineering or preprocessing. It has to avoid extra in-domain documents or labels.

Pretraining corpus and discriminative fine-tuning

The general-domain pretraining uses Wikitext-103, which has 28,595 preprocessed Wikipedia articles and 103 million words. Pretraining is meant to run once and then serve every downstream task, although the authors expect more diverse corpora to help and leave them to future work.

Target text may follow a different distribution from the pretraining corpus, so the language model is fine-tuned on that text before the classifier is trained. This step only has to adapt the model to the target's peculiarities, so it converges faster and gives a robust language model even when the target dataset is small.

Discriminative fine-tuning gives each layer its own learning rate, because different layers capture different kinds of information and should change by different amounts. In the usual SGD update all parameters share one rate. Here the parameters are split into layer groups, and layer l is updated with its own rate:

\[ \theta^{l}_{t} = \theta^{l}_{t-1} - \eta^{l}\cdot\nabla_{\theta^{l}} J(\theta) \] In this update, \(\theta^{l}\) holds the parameters of layer l, \(\eta^{l}\) is that layer's learning rate, and \(J(\theta)\) is the objective. The minus sign means each layer moves against its gradient.

The rates are set by first tuning the learning rate \(\eta^{L}\) of the last layer while only that layer is fine-tuned. Each lower layer then takes the rate of the layer above divided by 2.6, that is \(\eta^{l-1}=\eta^{l}/2.6\).

Slanted triangular learning rates

A constant rate or an annealed rate does not suit the aim of reaching a good region of parameter space quickly and then refining within it. Slanted triangular learning rates rise linearly over a short initial phase and then decay linearly over a much longer phase.

The switch point is cut, computed from the total number of iterations T and the fraction cut_frac of iterations spent increasing the rate. \[ \text{cut}=\lfloor T\cdot\text{cut\_frac}\rfloor,\qquad p=\begin{cases} t/\text{cut}, & t<\text{cut}\\ 1-\dfrac{t-\text{cut}}{\text{cut}\,(1/\text{cut\_frac}-1)}, & \text{otherwise}\end{cases} \]

The learning rate at iteration t is \(\eta_t=\eta_{max}\cdot\dfrac{1+p\,(\text{ratio}-1)}{\text{ratio}}\), where \(\eta_{max}\) is the maximum rate. The ratio sets how much smaller the lowest rate is than the maximum rate, so the schedule is a rescaled version of the phase variable and never leaves the range between the lowest and the maximum rate.

The defaults are cut_frac = 0.1, ratio = 32 and \(\eta_{max}=0.01\). The schedule modifies triangular learning rates from Smith (2017) by using a short increase and a long decay, which the authors found key for good performance. In the classifier ablation it is compared with aggressive cosine annealing, which the authors describe as a schedule recently used for state-of-the-art results in computer vision.

Classifier head, pooling and unfreezing

Two linear blocks are added to the language model. Each uses batch normalization and dropout, the intermediate block uses ReLU, and the last block uses softmax to give a distribution over the target classes. These blocks are the only parameters learned from scratch; everything else comes from the fine-tuned language model.

The signal for classification is often carried by a few words that can sit anywhere in the document, so the last hidden state alone can lose information. \[ h_c=[h_T,\ \text{maxpool}(H),\ \text{meanpool}(H)] \]

Unfreezing every layer at once risks catastrophic forgetting. Gradual unfreezing starts with the last layer, which holds the least general knowledge, and fine-tunes all unfrozen layers for one epoch. The next lower frozen layer is then unfrozen, and the cycle repeats until all layers are trained to convergence. This resembles chain-thaw, except that layers accumulate instead of training one layer at a time.

Backpropagation through time over long documents is made feasible by splitting each document into fixed-length batches of size b. Each batch starts from the final state of the previous batch. Mean and max pooling track the hidden states across batches, and gradients reach only the batches whose hidden states feed the final prediction.

The language model can run in either direction, so a forward and a backward language model are both pretrained. A classifier is fine-tuned on each language model independently, and their predictions are averaged.

Datasets, baselines and training settings

The six datasets cover sentiment analysis (IMDb, Yelp-bi and Yelp-full), question classification on TREC-6, and topic classification on AG and DBpedia. TREC-6 has 5.5k training examples and 6 classes, while DBpedia has 560k examples across 14 classes.

The same hyperparameters are used across tasks, and they were tuned on the IMDb validation set. The AWD-LSTM has an embedding size of 400, 3 layers and 1150 hidden activations per layer, with a BPTT batch size of 70.

Training uses Adam with \(\beta_1=0.7\) instead of 0.9 and \(\beta_2=0.99\), a batch size of 64, and base learning rates of 0.004 for LM fine-tuning and 0.01 for classifier fine-tuning. The number of epochs is tuned on each task's validation set. On TREC-6 the LM was fine-tuned for 15 epochs, and 50 epochs was the default for classifier fine-tuning.

For IMDb and TREC-6 the comparison is with CoVe, a transfer learning method for NLP. For AG, Yelp and DBpedia it is with the text categorization method of Johnson and Zhang (2017).

IMDb and TREC-6 against CoVe

The authors state that this is a 43.9% reduction in error relative to CoVe and a 22% reduction relative to the prior state of the art. The compared systems use more complex architectures, several forms of attention or sophisticated embedding schemes, while ULMFiT uses a regular LSTM with dropout.

The language model fine-tuning approach of Dai and Le (2015) reaches an IMDb error of 7.64, compared with 4.6 for ULMFiT.

The authors state that the TREC-6 improvement is not statistically significant, because the test set has only 500 examples.

AG, DBpedia and Yelp results

The authors report error reductions relative to the state of the art of 23.7% on AG, 4.8% on DBpedia, 18.2% on Yelp-bi and 2.0% on Yelp-full. The size of the gain varies widely across these datasets, from the large AG and Yelp-bi reductions to the small Yelp-full one.

Effect of Wikitext-103 pretraining

The comparison uses validation error on a split of 10% of the training set, with unidirectional language models. Without pretraining, validation error is 5.63 on IMDb, 10.67 on TREC-6 and 5.52 on AG. With pretraining it is 5.00, 5.69 and 5.38. The largest change is on TREC-6, and the authors note that pretraining also improves results on large datasets.

Effect of language model fine-tuning variants

With no LM fine-tuning, validation error is 6.99 on IMDb, 6.38 on TREC-6 and 6.09 on AG. Full LM fine-tuning gives 5.86, 6.54 and 5.61. On TREC-6, full LM fine-tuning without the two added techniques is higher than with no LM fine-tuning. The authors say the two techniques are necessary there. Adding discriminative fine-tuning and STLR to full fine-tuning lowers IMDb validation error from 5.86 to 5.00, TREC-6 from 6.54 to 5.69 and AG from 5.61 to 5.38.

A vanilla LM without dropout reaches 5.98 on IMDb, 7.41 on TREC-6 and 5.76 on AG, against 5.00, 5.69 and 5.38 for the AWD-LSTM LM. The authors suggest that without dropout the vanilla model risks overfitting on the smaller TREC-6, which lowers its performance there. The vanilla classifier was trained for only 5 epochs to limit overfitting.

Classifier fine-tuning methods

Training from scratch gives validation error 9.93 on IMDb, 13.36 on TREC-6 and 6.81 on AG. Fine-tuning the full model gives 6.87, 6.86 and 5.81. Fine-tuning only the last layer underfits: on TREC-6 its validation error is 16.09, and the authors say its training error never reaches 0.

Gradual unfreezing with discriminative fine-tuning and STLR gives 5.00 on IMDb, 5.69 on TREC-6 and 5.38 on AG, the best values on IMDb and TREC-6. On AG, gradual unfreezing with cosine annealing reaches 5.29, slightly below 5.38, and the authors describe cosine annealing as competitive on large data but weaker on smaller datasets.

Chain-thaw gives 5.39 on IMDb and 6.71 on TREC-6, but 5.90 on AG. Discriminative fine-tuning helps full and gradual fine-tuning on IMDb and TREC-6, but it does not help on AG, where gradual unfreezing with discriminative fine-tuning reaches 6.04 against 5.81 without it.

Low-shot learning

Two settings are compared. In the supervised setting only the labeled examples are used for LM fine-tuning, while in the semi-supervised setting all task data, including the unlabeled examples, is used. Supervised ULMFiT with 100 labeled IMDb examples matches training from scratch with 10 times more data, and on AG it matches training from scratch with 20 times more data.

With the unlabeled examples added (50k for IMDb and 100k for AG), 100 labeled examples match training from scratch with 50 times more data on AG and 100 times more data on IMDb.

On TREC-6, ULMFiT improves significantly on training from scratch in the authors' comparison, and supervised and semi-supervised variants give similar results. The authors link this to TREC-6 examples being shorter and fewer.

Training dynamics and bidirectionality

Figure 4 tracks validation error over epochs for classifier fine-tuning with ULMFiT and with full fine-tuning on IMDb, TREC-6 and AG. Full fine-tuning reaches its lowest validation error early, already after the first epoch on IMDb, and then the error rises as the model overfits. ULMFiT's error stays similar or keeps improving until late epochs.

The authors attribute this to the learning rate schedule.

The gain is reported at around 0.5-0.7.

Limits of the evidence

The TREC-6 gain is not statistically significant because the 500-example test set is small. Pretraining uses only Wikitext-103, and more diverse pretraining corpora are left to future work.

Hyperparameters were tuned on the IMDb validation set and then reused for all tasks. The ablations report validation error with unidirectional language models and cover only IMDb, TREC-6 and AG. The bidirectional gain is measured only on IMDb.

The baselines were trained on different pretraining data, so the comparison with CoVe is not controlled for data. Sequence labeling is described as a straightforward extension but was not tested, and tasks such as entailment and question answering were not tested.

Paper info

Authors
Jeremy Howard, Sebastian Ruder
Venue
arXiv · Preprint
First published
2018-1-18
Added
2026-11-6
Updated
2018-5-23
Version
v5
arXiv
1801.06146
Category
cs.CL · cs.LG · stat.ML
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Jeremy Howard, Sebastian Ruder (2018). Universal Language Model Fine-tuning for Text Classification. arXiv:1801.06146v5. https://arxiv.org/abs/1801.06146v5

BibTeX
@misc{howard2018universal,
  title = {{Universal Language Model Fine-tuning for Text Classification}},
  author = {Jeremy Howard and Sebastian Ruder},
  year = {2018},
  eprint = {1801.06146},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1801.06146v5}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up