Natural Language Processing · Advanced level

Advanced level · Module 1 of 10 · 14 guided hours

Neural Networks for NLP

Language-specific neural modelling in PyTorch: turning text into token ids, embedding layers, a neural bag-of-embeddings classifier, training loops and comparison with classical baselines.

Learning objectives

  • Convert text into token ids and batches for neural models
  • Build and train an embedding-based text classifier in PyTorch
  • Compare neural and classical text models fairly

Topics

  • vocabularies and token ids
  • padding and batching text
  • nn.Embedding and nn.EmbeddingBag
  • training loops for text
  • baselines and fair comparison
  • CPU-friendly training

Lessons

  1. Lesson 1 From Text to Tensors

    Learners build a vocabulary, map tokens to integer ids, handle unknown words, and pad and batch variable-length texts for PyTorch.

    vocabulary<pad> and <unk> tokenstoken idspadding and truncationDataLoader with collate_fn

  2. Lesson 2 An Embedding-Based Text Classifier

    Learners build a fast neural classifier with nn.EmbeddingBag (averaged learned embeddings followed by a linear layer) and train it with cross-entropy loss.

    nn.EmbeddingBagnn.LinearCrossEntropyLossoptimizer (Adam)epochs and validation

  3. Lesson 3 Neural versus Classical Baselines

    Learners compare the neural classifier with the TF-IDF logistic regression baseline on accuracy, F1 by class and language, training time and model size, and decide which to use.

    baselinesame test setper-class F1training and inference timemodel size

Practical activity

Build, train and compare an EmbeddingBag classifier with the TF-IDF baseline on the news task, including <unk> rates and results for the local sample.

Expected outcomes

  • Working PyTorch text pipelines
  • Evidence-based model choice

Assessment

Notebook review (70%) and the comparison note (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.