Overview

6 Deep transfer learning for NLP with recurrent neural networks

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
06_01
(Duplicated from the previous chapter for your convenience.) Visualizing SIMOn architecture in the context of the tabular column-type classification example
06_01_05_01
The process of converting unstructured text for consumption by SIMOn
06_02
Visualization of the convergence of the percent class transfer tabular data experiment
06_03
(Duplicated) Visualizing ELMo architecture in the context of the tabular column-type classification example
06_03_05_02
Forward language model equation
06_04
Backward language model equation.
06_05
The joint bidirectional language modeling (LM) objective equation that ELMo uses to build bidirectional context for any given token in a sequence
06_06
Convergence results for the ELMo model trained on the fake news dataset
06_07
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.
06_08

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).

FAQ

What are the three representative RNN-based transfer learning methods covered in Chapter 6?SIMOn, ELMo, and ULMFiT are the three representative deep transfer learning methods for NLP discussed in this chapter.
Why does SIMOn use character-level encoding instead of word-level encoding?SIMOn uses character-level encoding to better handle misspellings, emoticons, niche vernacular, and other dynamic language patterns common in social media and similar text sources.
How does the SIMOn architecture process text before classification?SIMOn first encodes each sentence at the character level, then applies convolution, max-pooling, dropout, and bidirectional LSTM layers to create sentence embeddings. A second bidirectional LSTM-based document encoder then combines sentence embeddings into a document representation for classification.
How can SIMOn be applied to tabular data?Each cell in a column is treated as a sentence, and the entire column is treated as a document. The model then classifies the column into a column type such as text, integer, or float.
What was the purpose of transferring SIMOn to the library dataset example?It was used to extend a pretrained column-type classifier so it could recognize a new class, percent, beyond the original set of supported classes.
How was the new percent class added to the pretrained SIMOn model?The output layer was expanded from 9 to 10 classes, and the new percent weights were initialized using the weights of the closest existing class, text. The model was then fine-tuned with a small dataset containing percentage and integer samples.
What is the main idea behind ELMo’s bidirectional language modeling?ELMo combines a forward language model and a backward language model to learn context-aware token representations. It uses both left-to-right and right-to-left context to build richer embeddings.
How does ELMo generate word embeddings for downstream tasks?ELMo forms a token representation as a learned linear combination of the internal states from all layers of its bidirectional LSTM language model, allowing each task to choose the most useful level of context.
What are the key ULMFiT fine-tuning techniques introduced in this chapter?The chapter introduces discriminative fine-tuning, slanted triangular learning rates, concat pooling, and gradual unfreezing as techniques to adapt pretrained NLP models more effectively.
Why are discriminative fine-tuning and gradual unfreezing important in ULMFiT?They help reduce catastrophic forgetting and overfitting during transfer learning. Discriminative fine-tuning uses different learning rates for different layers, while gradual unfreezing fine-tunes the model from top layers downward in stages.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Transfer Learning for Natural Language Processing Transfer Learning for Natural Language Processing ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Transfer Learning for Natural Language Processing Transfer Learning for Natural Language Processing ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Transfer Learning for Natural Language Processing Transfer Learning for Natural Language Processing ebook for free