Overview

5 Preprocessing data for recurrent neural network deep transfer learning experiments

This chapter introduces the practical preprocessing needed for deep transfer learning experiments in NLP that rely on recurrent neural networks. It begins by contrasting earlier shallow, static embeddings such as word2vec and sent2vec with deeper contextual approaches, emphasizing that RNN-based models can produce embeddings that depend on surrounding context and therefore support disambiguation. The chapter also previews three representative frameworks—SIMOn, ELMo, and ULMFiT—while noting the specific ways they use deeper architectures and fine-tuning strategies to adapt pretrained language models to new tasks.

A major focus is tabular text preprocessing for a column-type classification task, where each column in a dataset is assigned one or more fundamental types such as integer, float, address, or text. Using examples from baseball statistics and public library data, the chapter shows how raw tables can be reshaped into a form suitable for SIMOn by selecting relevant columns, treating columns as sequences of cells, and encoding cell contents into numerical arrays. The preprocessing pipeline includes loading pretrained SIMOn components, extracting encoder settings such as supported categories, and standardizing inputs to fixed sizes so the model can process them consistently.

The chapter then turns to a second application: preparing data for automated fake news detection. It explains that fact-checking data must be loaded as complete documents for ELMo-style processing, then combined into unified strings, labeled, shuffled, and split into training and validation sets. Along the way, it highlights important cautions about labeling bias, the limitations of framing misinformation as a simple true-versus-false problem, and the broader challenge of influence operations. Overall, the chapter’s main contribution is showing how to convert real-world, messy text data into the structured numeric inputs required by later RNN-based transfer learning models.

Visualizing SIMOn architecture in the context of the tabular column-type classification example
05_01
Visualizing ELMo architecture in the context of the tabular column-type classification example
05_02
Visualizing the tabular column data-type classification problem with a simple example
05_03
Visualizing the tabular data-modeling parameters. The parameter max_cells specifies the maximum number of cells or rows per column in the table. The parameter max_len specifies the maximum length of each cell or row.
05_04

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.

1. P. Azunre et al., “Semantic Classification of Tabular Datasets via Character-Level Convolutional Neural Networks,” arXiv (2019).

2. M. E. Peters et al., “Deep Contextualized Word Representations,” Proc. of NAACL-HLT (2018).

3. J. Howard et al., “Universal Language Model Fine-Tuning for Text Classification,” Proc. of the 56th Annual Meeting of the Association for Computational Linguistics (2018).

5. N. Dhamani et al., “Using Deep Networks and Transfer Learning to Address Disinformation,” AI for Social Good ICML Workshop (2019).

9. P. Azunre et al., “Disinformation: Detect to Disrupt,” Conference for Truth and Trust Online 1, no. 1 (2019).

FAQ

What is the main focus of Chapter 5 in “Transfer Learning for Natural Language Processing”?The chapter focuses on preprocessing data for recurrent neural network (RNN)-based deep transfer learning experiments in NLP. It introduces SIMOn, ELMo, and ULMFiT, and shows how to prepare tabular column-type data and fake news detection data for these models.
Why are SIMOn, ELMo, and ULMFiT discussed in this chapter?These are representative deep transfer learning frameworks that rely on RNNs. The chapter uses them to show how contextual embeddings and pretrained language models can be applied to practical NLP problems.
How is SIMOn used as an example in this chapter?SIMOn is used as a practical example of transfer learning for tabular text data. The chapter shows how it can classify table columns into types such as integer, float, string, address, and more.
What is the purpose of the tabular column-type classification task?The task is to determine the fundamental data type of each column in a tabular dataset. This helps an AutoML system decide how to process the data, such as identifying regression inputs, classification targets, or geographic coordinates.
Which tabular datasets are used in the chapter?The chapter uses two datasets: a baseball player statistics dataset from OpenML and a British Columbia public library statistics dataset. These are used to demonstrate preprocessing for SIMOn-based experiments.
What are max_cells and max_len in the SIMOn preprocessing pipeline?max_cells is the maximum number of cells per column, and max_len is the maximum length of each cell. These values ensure that input data has a fixed shape suitable for the CNN-based encoder used by SIMOn.
Why does the SIMOn encoder convert data into fixed-size arrays?CNN-based models require inputs of a fixed, pre-specified length. The encoder standardizes each column to a fixed number of cells and each cell to a fixed character length so the data can be processed consistently.
What categories can the pretrained SIMOn model recognize?The pretrained SIMOn encoder supports categories such as address, boolean, datetime, email, float, int, phone, text, and uri.
How is the fake news dataset prepared for modeling in this chapter?The chapter loads true and fake news articles, samples 1,000 from each class, combines them into one dataset, converts each article into a single lowercase string, assigns labels, and then shuffles and splits the data into training and validation sets.
What special consideration is mentioned for fake news detection data?The chapter notes that fake-news labels can reflect human bias and that “fake news” detection is more complex than simple factual classification. It also points out that real-world influence operations may require anomaly detection and human oversight.

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