USMA MA289: Mathematics of AI

Neural Networks: Embeddings, Sequence Models & Attention

Overview

This block builds directly from the 20 October introduction to feed-forward neural networks. Cadets first use the same forward-propagation, loss, gradient-descent, and backpropagation ideas to learn word embeddings from language context. The course then adds sequence memory with RNNs and LSTMs, introduces encoder-decoder models, and finishes the block with attention as the bridge to transformers and modern LLMs.

Neural-Network Progression

  1. Feed-Forward Neural Networks: inputs, hidden layers, activations, loss, gradient descent, and backpropagation.
  2. Word Embeddings: learn a dense vector for each token by predicting nearby context tokens.
  3. RNN / LSTM: add ordered hidden state and memory so representations can depend on sequence context.
  4. Encoder-Decoder Models: map an input sequence into a representation used to generate an output sequence.
  5. Attention: replace a single fixed context bottleneck with learned weighted access to sequence states.
  6. Transformers / LLMs: combine attention, embeddings, and feed-forward networks to build contextual representations at scale.

Kaggle Competition 3: Neural Network Word Embeddings

Status: Live

Launch: 02 Nov 2026

Due: 17 Nov 2026 NLT 2359

Open the MA289 AY27-1 Neural Network Word Embedding Competition

Cadets receive anonymized real-language text in which retained words are represented by tokens such as tok_0147. The scored representation must be learned from the provided MA289 corpus rather than from pretrained embeddings, pretrained language models, or external text corpora.

The basic self-supervised learning task is center token → embedding → feed-forward output → nearby context token . Backpropagation updates the embedding matrix. After training, cadets compare token vectors with cosine similarity and submit one similarity estimate for every pair in test.csv.

The released data contain a 900-token anonymous vocabulary, 300,000 center/context training pairs, and 1,200 scored token pairs. Kaggle evaluates submissions using Mean Squared Error (MSE); lower is better.

Final deliverables are the Kaggle submission and a GitHub repository containing a Colab-compatible notebook, supporting code, final submission.csv, experiment results, and a reproducible README.md.

Key Topics, Lesson Objectives, Readings, and Competition Work

Date Key Topics Lesson Objectives Readings Competition Work
03 Nov 2026 Practical Word Embeddings with Feed-Forward Neural Networks
PyTorch / Google Colab
Competition 3
Explain why categorical tokens require a numerical representation.

Represent a vocabulary with a learned embedding matrix E in RV x d.

Construct center-token/context-token examples using words before and after a center token.

Trace the computation token ID → embedding lookup → logits → softmax → cross-entropy loss .

Explain how backpropagation changes the selected rows of the embedding matrix.

Extract learned embeddings and compare token pairs with cosine similarity.
Lesson Notes
Practical Neural-Network Word Embeddings - PyTorch / Colab

Student Notebook
PyTorch + Word Embeddings Student Intro Notebook

Previous Lesson
20 October Feed-Forward Neural Network Lesson Notes

Géron
Chapter 16: Natural Language Processing with RNNs and Attention
Selected background on word representations and NLP.
Join Competition 3 and inspect train_corpus.txt, context_train.csv, test.csv, and sample_submission.csv.

Train a baseline PyTorch embedding network in Google Colab.

Generate token-pair cosine similarities and submit a first Kaggle file.

Create the GitHub repository and begin the experiment table in the README.
10 Nov 2026 Recurrent Neural Networks & LSTMs Explain the limitation of assigning one fixed embedding vector to a token regardless of its position or surrounding sequence.

Compute the recurrent update ht = f(xt, ht-1).

Explain weight sharing through time and backpropagation through time.

Identify vanishing-gradient limitations of basic RNNs.

Describe how LSTM gates create a controlled memory path for longer dependencies.
Géron
Chapter 15: Processing Sequences Using RNNs and CNNs

Recurrent neurons and layers
Training RNNs
Long short-term memory (LSTM) cells
Continue Competition 3 experiments.

Compare embedding dimension, context window, epochs, learning rate, optimizer, batch size, and optional hidden-layer choices.

Record model settings and Kaggle MSE in the GitHub README.
17 Nov 2026 Encoder-Decoder Models, Attention & the Transformer Bridge
Competition 3 Review
Distinguish many-to-one, one-to-many, and many-to-many sequence tasks.

Explain how an encoder creates sequence representations and how a decoder uses them to produce an output sequence.

Identify the fixed-context bottleneck in a basic encoder-decoder model.

Interpret attention as a learned weighted combination of sequence states.

Explain the conceptual roles of queries, keys, and values.

Connect embeddings, attention, and feed-forward layers to transformers and contextual token representations used by modern LLMs.
Géron
Chapter 16: Natural Language Processing with RNNs and Attention

Encoder-decoder networks
Attention mechanisms
Transformer architecture
Competition 3 Due: 17 Nov 2026 NLT 2359

Submit the final Kaggle similarity file.

Submit the GitHub repository containing the README, Colab notebook, supporting code, final submission, experiment table, and final reported MSE.

Explain what the learned embedding represents and why fixed embeddings motivate contextual sequence models.

Resources

Home Intro Parametric Models Non-Parametric Models Unsupervised + Neural Networks Embeddings, Sequence Models & Attention Security & Ethics Kaggle Competitions