track:nlp-llm

NLP / LLM

A focused route through sequence models, transformers, adaptation, evaluation, and language-model serving.

10

Lessons

Formal explanations, examples, simulations, and checkpoints.

Sequence ML: RNNs, GRUs & LSTMs

Sequences are not IID

In sequence learning, chronology is part of the feature schema: define the cutoff first, then construct inputs, labels, and splits around it.

Sequence ML: RNNs, GRUs & LSTMs

Recurrent state and BPTT

Recurrent state carries information forward; BPTT carries responsibility backward, and truncation decides how far that responsibility can travel.

Sequence ML: RNNs, GRUs & LSTMs

Gates that remember: LSTM and GRU

Gates do not create memory by magic; they create learnable paths for preserving, replacing, and exposing state.

Sequence ML: RNNs, GRUs & LSTMs

Many-to-one and many-to-many training

Choose the output pattern from the target, then make padding mathematically invisible to both state selection and loss.

Sequence ML: RNNs, GRUs & LSTMs

Stateful streaming inference without future leakage

For streaming inference, the state transition, ordering policy, deduplication rule, and model version are all part of the model.

Build a transformer from scratch

Text to tensors: tokenization, embeddings, position

Tokenizer and position scheme are not preprocessing trivia; together they define what symbols and order the transformer can represent.

Build a transformer from scratch

Scaled dot-product self-attention by hand

Attention is a masked, normalized lookup: queries score keys, softmax allocates influence, and values carry the information.

Build a transformer from scratch

Heads, norms, residuals, and MLPs

Attention mixes tokens, the MLP mixes channels, and normalized residual paths let both transformations accumulate without losing the original stream.

Build a transformer from scratch

Train a causal language model

Causal LM training is next-token alignment plus a no-looking-ahead proof; everything else scales that contract.

Build a transformer from scratch

Sampling, KV cache, and efficient generation

Efficient generation couples a declared sampling policy with a position-correct KV cache whose logits match the uncached model.