Transformers

Transformers

Attention variants, RoPE, MoE, RMSNorm, MTP, sparse attention, FlashAttention.

58Articles
58Topics covered
Articles in this category

All 58 articles, sorted alphabetically

Advertisement
ARTICLE · 01

Attention Is All You Need

What aged and what didn't.

Read article
ARTICLE · 02

Attention Is All You Need

The 2017 paper that started everything, re-explained for 2026.

Read article
ARTICLE · 03

Attention Variants in 2026

MHA, MQA, GQA, MLA — what's deployed.

Read article
ARTICLE · 04

Causal vs Bidirectional Attention

Decoder encoder prefix-LM uses.

Read article
ARTICLE · 05

FlashAttention Explained

How the attention kernel was rewritten to be 5-10x faster.

Read article
ARTICLE · 06

HuggingFace Accelerate

How accelerate simplifies distributed training and inference across GPUs and nodes.

Read article
ARTICLE · 07

HuggingFace Datasets

How the datasets library provides memory-mapped, streamable access to huge datasets.

Read article
ARTICLE · 08

HuggingFace Evaluate

How the evaluate library provides standardized ML metrics (accuracy, BLEU, ROUGE, and hundreds more).

Read article
ARTICLE · 09

HuggingFace Hub

How the Hub distributes models, datasets, and Spaces, and how it centralized ML resource sharing.

Read article
ARTICLE · 10

HuggingFace Model Cards

What model cards are, why they matter for responsible ML, and how to write good ones.

Read article
ARTICLE · 11

HuggingFace PEFT

How the PEFT library implements LoRA, QLoRA, adapters, prefix tuning, and other efficient fine-tuning methods.

Read article
ARTICLE · 12

HuggingFace Pipelines

How pipelines provide task-focused inference APIs (classification, generation, etc.) with minimal setup.

Read article
ARTICLE · 13

HuggingFace Tokenizers Library

How the tokenizers library provides fast tokenization via Rust, and the algorithms it supports (BPE, WordPiece, Unigram).

Read article
ARTICLE · 14

HuggingFace Trainer

How the Trainer class abstracts training loops, handling optimization, evaluation, and checkpointing.

Read article
ARTICLE · 15

KV Cache Explained

Why generation is fast: the attention KV cache and its memory implications.

Read article
ARTICLE · 16

Long-Context Evaluation

Needle-in-haystack and what it misses.

Read article
ARTICLE · 17

Mixture of Depths

Routing tokens through different depths.

Read article
ARTICLE · 18

Multi-Token Prediction (MTP)

DeepSeek V3's MTP and the speed-quality trade.

Read article
ARTICLE · 20

Rotary Position Embeddings (RoPE)

The position encoding that replaced sinusoidal and enabled long-context extrapolation.

Read article
ARTICLE · 21

Relative position embeddings architecture

Deep-dive on relative position embeddings: distance, bias table, T5 buckets, Shaw edges, ALiBi, extrapolation.

Read article
ARTICLE · 22

The Transformer Breakdown: A Deep Dive into Self-Attention, Key-Value Pairs, and Positional Encoding

Read article
ARTICLE · 23

The Vanishing Gradient Problem: How Transformers Solved What Killed Earlier RNNs

Read article
ARTICLE · 24

Tokenization Choices Compared

BPE, SentencePiece, Tiktoken — and why it matters.

Read article
ARTICLE · 25

Transformer Block Anatomy

What's inside one of the N layers.

Read article
ARTICLE · 26

Transformer Training Loss Curves

Reading them and what each shape means.

Read article
ARTICLE · 27

HuggingFace Accelerate Architecture in Depth

A 2500-word walkthrough of HuggingFace Accelerate: Accelerator, config, DDP, FSDP, DeepSpeed, Megatron, TPU/MPS, mixed precision, save+resume.

Read article
ARTICLE · 28

HuggingFace Datasets Architecture in Depth

A 2500-word walkthrough of HuggingFace Datasets: Arrow storage, splits, cache, streaming, map/filter, Hub, data cards, interop.

Read article
ARTICLE · 29

Hugging Face generate() architecture

Deep-dive on the Transformers generate() method: the GenerationConfig as single source of truth, the ordered logits-processor pipeline (temperature, t…

Read article
ARTICLE · 30

HuggingFace Transformers Library Architecture in Depth

A 2500-word walkthrough of the HuggingFace Transformers library architecture: Hub, auto classes, tokenizer, model, Trainer, TRL/PEFT, Accelerate, and …

Read article
ARTICLE · 31

HuggingFace Transformers Library Overview

What the transformers library is, its role in the ML ecosystem, and the primitives it provides.

Read article
ARTICLE · 32

HuggingFace Transformers Pipelines Architecture in Depth

A 2500-word walkthrough of HuggingFace pipelines: task registry, model selection, preprocessor, forward, postprocessor, batching, device, streaming, O…

Read article
ARTICLE · 33

Tokenizers

Deep-dive on tokenizers: the normalization/pre-tokenization/subword pipeline, BPE/WordPiece/Unigram algorithms, vocabulary and token IDs, special toke…

Read article
ARTICLE · 34

Hugging Face Trainer architecture

Deep-dive on the HF Trainer: how TrainingArguments configures a run, the Trainer orchestrates the step over an Accelerate backend, gradient accumulati…

Read article
ARTICLE · 35

ALiBi attention architecture

Deep-dive on ALiBi (Attention with Linear Biases): replacing input position embeddings with a static per-head linear penalty on attention scores, the …

Read article
ARTICLE · 36

Attention sinks -- why the first tokens matter for streaming LLMs

Deep-dive on attention sinks: the infinite-generation KV-cache problem, sliding-window KV and its collapse, attention sinks (initial tokens absorbing …

Read article
ARTICLE · 37

Cross-attention architecture

Deep-dive on cross-attention, the attention variant where queries come from a target sequence and keys/values from a separate source, powering transla…

Read article
ARTICLE · 38

Dropout architecture

Deep-dive on dropout: standard, inverted, attention, residual, layer drop, DropPath, inference mode, modern LLM practice.

Read article
ARTICLE · 39

FlashAttention -- IO-aware exact attention

Deep-dive on FlashAttention: the O(N^2) attention memory problem, the IO-awareness insight (attention is memory-IO-bound), tiling Q/K/V into SRAM bloc…

Read article
ARTICLE · 40

Transformer gate architecture

Deep-dive on transformer gates: SwiGLU/GeGLU vs plain GeLU, MoE routing gate, attention output gating, numerics, kernel fusion.

Read article
ARTICLE · 41

KV cache architecture

Deep-dive on the transformer KV cache: prefill vs decode regimes, per-token memory math, paged allocation and block tables, prefix caching with copy-o…

Read article
ARTICLE · 42

MoE transformer architecture

Deep-dive on MoE transformers: gate MLP, top-K selection, expert MLPs, load balance loss, router z-loss, capacity factor, jitter.

Read article
ARTICLE · 43

Multi-head latent attention (MLA) architecture

Deep-dive on MLA: down/up-projecting keys and values into a cached low-rank latent, decoupled RoPE for position, weight absorption so inference attend…

Read article
ARTICLE · 44

Positional encoding architecture

Deep-dive on positional encoding: sinusoidal, learned, relative, RoPE, ALiBi, long-context extension (PI, NTK, YaRN), kernels.

Read article
ARTICLE · 45

Pre-norm vs post-norm architecture

Deep-dive on pre-norm vs post-norm placement: gradient flow, stability, LR warmup, DeepNet init, sandwich norm, final LN.

Read article
ARTICLE · 46

QK-Norm architecture

Deep-dive on query-key normalization: why QK^T/sqrt(d) logits grow without bound, how softmax saturation kills gradients, per-head RMSNorm placement b…

Read article
ARTICLE · 47

Ring Attention: Architecture Deep-Dive

How ring attention shards sequences across devices and rotates KV blocks to compute exact attention beyond single-device memory limits — architecture,…

Read article
ARTICLE · 48

RMSNorm

Deep-dive on RMSNorm: normalizing activations by their root-mean-square with a learned gain and no bias, why dropping LayerNorm&#x…

Read article
ARTICLE · 49

RoPE architecture

Deep-dive on RoPE and long-context extensions: rotation math, Position Interpolation, NTK-aware scaling, YaRN, kernel fusion, and eval.

Read article
ARTICLE · 50

Sparse attention architecture

Deep-dive on sparse attention patterns: local, strided, global, block, Longformer, BigBird, kernel support, training/serving.

Read article
ARTICLE · 51

Speculative decoding architecture

Deep-dive on speculative decoding: why decoding is memory-bandwidth bound, a draft model proposing K tokens, single-pass parallel verification, the re…

Read article
ARTICLE · 52

SwiGLU architecture

Deep-dive on the SwiGLU FFN: the SiLU/Swish activation, the two up-projection gate multiplied elementwise and projected down, the two-thirds d_ff resc…

Read article