Natural Language Processing · Advanced level

Advanced level · Module 2 of 10 · 14 guided hours

Recurrent Neural Networks for Language

Modelling word and character order with recurrent networks: hidden states, character-level classification, language modelling and text generation, and the vanishing-gradient problem.

Learning objectives

  • Explain how RNNs process sequences of tokens
  • Build character-level RNN classifiers and language models
  • Explain vanishing gradients and their effect on long texts

Topics

  • sequences and hidden states
  • nn.RNN in PyTorch
  • character-level models
  • language modelling and perplexity
  • sampling and temperature
  • vanishing gradients

Lessons

  1. Lesson 1 How Recurrent Networks Read Text

    Learners trace an RNN reading a sentence one token at a time, updating a hidden state that summarises what it has seen.

    recurrencehidden statenn.RNN(batch_first=True)outputs vs final hidden stateorder sensitivity

  2. Lesson 2 Character-Level Classification

    Learners follow and adapt the PyTorch character-level RNN tutorial to classify short strings, such as detecting the language or script style of words.

    character vocabularyone-hot or embedded characterstraining on short stringsconfusion matrixlanguage identification

  3. Lesson 3 Language Models, Generation and Vanishing Gradients

    Learners train a small character-level language model on public-domain text, generate text with temperature sampling, measure perplexity and observe why plain RNNs forget long contexts.

    language modelnext-token predictionperplexitytemperature samplingvanishing gradients

Practical activity

Build a character-level language identifier for short words and a small character language model, with per-language evaluation and a demonstration of vanishing gradients.

Expected outcomes

  • Understanding of sequence modelling for language
  • Practical character-level models

Assessment

Notebook review (70%) and an oral explanation of the RNN computation (30%).

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.