This chapter explores how recurrent neural networks can support deep transfer learning in NLP, using two running examples: column-type classification and fake news detection. It focuses on three representative approaches—SIMOn, ELMo, and ULMFiT—and shows how pretrained sequence models can be adapted to new tasks with limited labeled data. The central theme is that knowledge learned from large or simulated corpora can be reused effectively when the target dataset is smaller or differently distributed.
SIMOn is presented as a character-level text classifier originally designed for tabular column typing, but adaptable to arbitrary text by treating each column as a document and each cell as a sentence. Its architecture encodes sentences with character-level one-hot inputs, convolutional layers, and bidirectional LSTMs, then aggregates sentence embeddings with another bidirectional LSTM to classify the whole document. The chapter demonstrates that the pretrained model can accurately identify common column types and can be extended to new labels, such as percentages, by reusing learned weights, expanding the output layer, and fine-tuning on a small transfer dataset.
ELMo is then explained as a contextual embedding method built from bidirectional language modeling, where forward and backward LSTMs jointly learn representations that depend on surrounding context. Unlike a fixed embedding, ELMo combines internal states from multiple layers so downstream tasks can draw on both syntactic and semantic information. The chapter applies this to fake news detection with a compact classifier on top of pretrained ELMo embeddings, and closes by introducing ULMFiT, which addresses overfitting and catastrophic forgetting through discriminative fine-tuning, slanted learning rates, concat pooling, and gradual unfreezing, setting up more advanced adaptation methods for later study.
Contrasting word-level to character-level models for text classification
(Duplicated from the previous chapter for your convenience.) Visualizing SIMOn architecture in the context of the tabular column-type classification example
The process of converting unstructured text for consumption by SIMOn
Visualization of the convergence of the percent class transfer tabular data experiment
(Duplicated) Visualizing ELMo architecture in the context of the tabular column-type classification example
Forward language model equation
Backward language model equation.
The joint bidirectional language modeling (LM) objective equation that ELMo uses to build bidirectional context for any given token in a sequence
Convergence results for the ELMo model trained on the fake news dataset
Suggested ULMFiT rate schedule for the case of 10,000 total iterations. The rate increases linearly for 10% of the total number of iterations (i.e., 1,000), up to a maximum of 0.01, and then decreases linearly afterward to 0.
Summary
- Character-level models, as opposed to word-level models, can handle misspellings and other social media features, such as emoticons and niche vernacular.
- Bidirectional language modeling is key for building word embeddings that are aware of their local context.
- SIMOn and ELMo both employ character-level CNNs and bi-LSTMs, with the latter helping to achieve bidirectional context-building.
- Adapting a pretrained language model to a new scenario may benefit from fine-tuning the different layers of the model at different rates, which should initially increase and then decrease according to a slanted triangular schedule.
- Adapting a task-specific layer to a new scenario may benefit from unfreezing and fine-tuning the different layers gradually, starting from the last layer and unfreezing increasingly more until all layers are refined.
- ULMFiT employs discriminative fine-tuning, slanted triangular learning rates, and gradual unfreezing to alleviate overfitting and catastrophic forgetting when fine-tuning language models.
1. N. Dhamani et al., “Using Deep Networks and Transfer Learning to Address Disinformation,” AI for Social Good ICML Workshop (2019).
Transfer Learning for Natural Language Processing ebook for free