@Huahuazo: Still piecing together LLM fundamentals from scattered resources? LLM Internals lays out a complete learning path for you. Starting with tokenization, BPE, and the Transformer, it covers training, fine-tuning, RAG, Agents, and inference optimization. Q/K/V, RoPE, causal masking, GQA...

X AI KOLs Timeline Tools

Summary

The open-source repo LLM Internals provides a complete LLM fundamentals learning path covering tokenization, BPE, Transformer, attention mechanisms, training, fine-tuning, RAG, Agents, and inference optimization — with blog posts and videos for each module.

Still piecing together LLM fundamentals from a pile of scattered resources? LLM Internals lays out a complete learning path for you. Starting with tokenization, BPE, and the Transformer, it walks you through training, fine-tuning, RAG, Agents, and all the way to inference optimization. 1️⃣ Attention mechanisms: Q/K/V, RoPE, causal masking, GQA 2️⃣ Core components: Transformer, MoE, LoRA, normalization, and more 3️⃣ Backpropagation, cross-entropy, RLHF, reasoning models 4️⃣ Inference techniques: KV Cache, Flash Attention, Paged Attention, speculative decoding, etc. Each module comes with a blog post and video — perfect for stitching your scattered knowledge back together. 🔗 https://github.com/amitshekhariitbhu/llm-internals
Original Article
View Cached Full Text

Cached at: 11/26/26, 01:54 AM

Still piecing together how LLMs work from a scattered pile of resources? LLM Internals lays out a complete roadmap for you. It starts with tokenization, BPE, and the Transformer, then walks you through training, fine-tuning, RAG, and Agents, all the way to inference optimization.

1️⃣ Attention mechanisms like Q/K/V, RoPE, causal masking, and GQA 2️⃣ Core components such as the Transformer, MoE, LoRA, and normalization 3️⃣ Backpropagation, cross-entropy, RLHF, and reasoning models 4️⃣ Inference techniques including KV Cache, Flash Attention, Paged Attention, and speculative decoding

Every module comes with blog posts and videos — a perfect way to string all those scattered pieces of knowledge back together.

🔗 https://github.com/amitshekhariitbhu/llm-internals…


amitshekhariitbhu/llm-internals

Source: https://github.com/amitshekhariitbhu/llm-internals

LLM Internals

Learn LLM internals step by step - from tokenization to attention to inference optimization.


Prepared and maintained by the Founder of Outcome School: Amit Shekhar (https://x.com/amitiitbhu)


Note: This series will continue to grow as I write more blogs and create more videos on new topics. Keep learning.


Large Language Models (LLMs)

Before diving into the internals of an LLM, it’s a good idea to first understand what an LLM actually is. In this video, we will cover the following:

  • LLM
  • RAG
  • MCP
  • Agent
  • Fine-tuning
  • Quantization

Let’s get started: AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, Quantization (https://www.youtube.com/watch?v=lnfWvX66FUk)


How does an LLM work?

In this blog, we will learn about how an LLM works. We will also see how text is turned into tokens and embeddings, how the Transformer and attention work, how an LLM generates an answer word by word, how it is trained, what the context window and hallucination are, and where it is used in the real world. We will cover the following:

  • What is an LLM?
  • What does it really do? (Predicting the next word)
  • How a computer turns words into numbers (Tokens)
  • How a token becomes meaning (Embeddings)
  • The Transformer
  • Attention
  • How an LLM generates a full answer, word by word
  • How an LLM is trained
  • Pretraining and Fine-tuning
  • The Context Window
  • Why an LLM sometimes makes things up (Hallucination)
  • Real-World Applications

Let’s get started: How does an LLM work? (https://outcomeschool.com/blog/large-language-model-llm)


Tokenization in Large Language Models (LLMs)

In this video, we will learn about Tokenization and why they are essential for Large Language Models.

Let’s get started: Tokenization in Large Language Models (LLMs) (https://www.youtube.com/watch?v=sK2s9I84EVI)


Tokenization in LLMs

In this blog, we will learn about Tokenization in LLMs, the very first step that turns our text into numbers before a Large Language Model can process it. We will also see what a token is, the three approaches to break text into tokens, how BPE works, how tokens are decoded back to text, and how tokenization affects LLMs in practice. We will cover the following:

  • What is Tokenization?
  • Why do we need Tokenization?
  • What is a Token?
  • Approach 1: Character-level Tokenization
  • Approach 2: Word-level Tokenization
  • Approach 3: Subword-level Tokenization
  • How does Byte Pair Encoding (BPE) work?
  • Vocabulary and Token IDs
  • Decoding: From Tokens back to Text
  • Tokenization in action with code
  • Special Tokens
  • How Tokenization affects LLMs in practice
  • Where it works well and where it fails

Let’s get started: Tokenization in LLMs (https://outcomeschool.com/blog/tokenization-in-llms)


Byte Pair Encoding in LLMs

In this blog, we will learn about BPE (Byte Pair Encoding) - the tokenization algorithm used by most modern Large Language Models (LLMs) to break text into smaller pieces before processing it. We will understand what BPE is, why it is needed, and how it works step by step with a simple example. We will cover the following:

  • What is Tokenization?
  • The Problem: How to Break Text into Tokens?
  • What is BPE (Byte Pair Encoding)?
  • How BPE Works: Step by Step
  • How BPE Tokenizes New Text
  • Why BPE is Used in Modern LLMs

Let’s get started: Byte Pair Encoding in LLMs (https://outcomeschool.com/blog/bpe-in-llms)


Stop Tokens in LLMs

In this blog, we will learn about Stop Tokens in LLMs, the special tokens that tell a Large Language Model when to stop generating text. We will also see how an LLM generates text one token at a time, why it needs to stop, how the model learns to produce a Stop Token, how a Stop Token differs from a Stop Sequence, and how chat models use Stop Tokens to end their turn. We will cover the following:

  • What is a Token?
  • How does an LLM generate text?
  • Why does an LLM need to stop?
  • What is a Stop Token?
  • How does the model learn to produce a Stop Token?
  • Stop Token vs Stop Sequence
  • What happens if the model never stops?
  • Stop Tokens in Chat Models
  • Common mistakes with Stop Tokens

Let’s get started: Stop Tokens in LLMs (https://outcomeschool.com/blog/stop-tokens-in-llms)


Math behind Attention - Q, K, and V

In this blog, we will learn about the math behind Attention: Query(Q), Key(K), and Value(V) with a step-by-step numeric example. We will cover the following:

  • The Attention Formula
  • Setting Up: From Words to Vectors
  • Creating Q, K, and V Matrices
  • Computing Attention Scores (Q x K^T)
  • Scaling the Scores
  • Applying Softmax
  • Computing the Final Output (Attention Weights x V)
  • Putting It All Together

Let’s get started: Math behind Attention - Q, K, and V (https://outcomeschool.com/blog/math-behind-attention-qkv)


Math behind √dk Scaling Factor in Attention

In this blog, we will learn about why we scale the dot product attention by √dk in the Transformer architecture with a step-by-step numeric example. We will cover the following:

  • The Attention Formula (Quick Recap)
  • What Happens Without Scaling?
  • Why Do Dot Products Grow with dk?
  • Understanding Variance of the Dot Product
  • Proving It Step by Step: Variance of the Dot Product is dk
  • What Large Dot Products Do to Softmax
  • Why √dk is the Right Scaling Factor
  • Seeing It with Real Numbers
  • Putting It All Together

Let’s get started: Math behind √dk Scaling Factor in Attention (https://outcomeschool.com/blog/scaling-dot-product-attention)


Causal Masking in Attention

In this blog, we will learn about causal masking in attention. We will start with the introduction of causal masking, understand the problem of seeing future tokens through an example, and then walk through its implementation to see how masked attention prevents the model from accessing future tokens. We will cover the following:

  • Without Causal Masking
  • With Causal Masking
  • Implementation of Causal Masking
  • The Causal Mask Matrix

Let’s get started: Causal Masking in Attention (https://outcomeschool.com/blog/causal-masking-in-attention)


Math Behind Backpropagation

In this blog, we will learn about the math behind backpropagation in neural networks. Backpropagation is the core algorithm that allows neural networks to learn from their mistakes. Without it, training neural networks efficiently would not be possible. Understanding the math behind it gives us a deeper understanding of how neural networks actually learn. Do not worry, we will learn about each concept step by step so that everything is clear. We will cover the following:

  • What is backpropagation?
  • The chain rule of calculus
  • Forward pass
  • Loss calculation
  • Backward pass (backpropagation)
  • Step-by-step numeric example
  • Weight update using gradient descent
  • Backpropagation in Python

Let’s get started: Math Behind Backpropagation (https://outcomeschool.com/blog/math-behind-backpropagation)


Math Behind Cross-Entropy Loss

In this blog, we will learn about the math behind Cross-Entropy Loss with a step-by-step numeric example. When we train a classification model in machine learning, the model predicts probabilities for each class. For example, given an image, the model outputs something like: “I am 70% sure this is a cat, 20% sure it is a dog, and 10% sure it is a rabbit.” To train the model, we need a way to measure how wrong these predictions are compared to the true answer. This is exactly what Cross-Entropy Loss does. It is the most widely used loss function in classification tasks, and it powers the training of almost every modern AI model, including GPT, BERT, and image classifiers. We will cover the following:

  • The Big Picture
  • What is Cross-Entropy
  • The Cross-Entropy Loss Formula
  • Why We Take the Negative Log
  • Binary Cross-Entropy Loss
  • Categorical Cross-Entropy Loss
  • Step-by-Step Numeric Example
  • Cross-Entropy Loss for Language Models
  • The Gradient of Cross-Entropy Loss
  • Quick Summary

Let’s get started: Math Behind Cross-Entropy Loss (https://outcomeschool.com/blog/math-behind-cross-entropy-loss)


What are Log Probabilities (Logprobs) in LLMs?

In this blog, we will learn about Log Probabilities (Logprobs) in LLMs, the log of the probability that the model gives to each token it can write next. They tell us how sure the LLM was about every token it picked. We will cover the following:

  • How an LLM picks the next token
  • What is a log?
  • What are Log Probabilities (Logprobs)?
  • Why do we use logprobs?
  • Probability of a full sentence
  • Top logprobs
  • Where are logprobs used?

Let’s get started: What are Log Probabilities (Logprobs) in LLMs? (https://outcomeschool.com/blog/logprobs-in-llms)


How does Constrained Decoding work?

In this blog, we will learn about how Constrained Decoding works, a way of forcing an LLM to only pick tokens that follow a fixed set of rules, like a valid JSON format. We will also see how a mask blocks the wrong tokens at every step and how rules like JSON and regex are turned into a small state machine. We will cover the following:

  • What is decoding in an LLM?
  • The problem: LLMs do not always follow the format
  • What is Constrained Decoding?
  • The core idea: masking the wrong tokens
  • A step-by-step example
  • How do the rules become a state machine?
  • Constrained Decoding for JSON
  • The tricky part: tokens are not characters
  • Constrained Decoding in code
  • Constrained Decoding vs asking in the prompt
  • Where it works well and where it fails

Let’s get started: How does Constrained Decoding work? (https://outcomeschool.com/blog/constrained-decoding)


Decoding Transformer Architecture

In this blog, we will learn about the Transformer architecture by decoding it piece by piece - understanding what each component does, how they work together, and why this architecture powers every modern Large Language Model (LLM). We will cover the following:

  • Why the Transformer was needed
  • The two halves of the architecture
  • Tokenization, Embedding, and Positional Encoding
  • The Attention Mechanism and Multi-Head Attention
  • Feed-Forward Networks, Residual Connections, and Layer Normalization
  • How the Encoder and Decoder work
  • How data flows through the entire architecture
  • The three variants of the Transformer
  • Why the Transformer is so powerful

Let’s get started: Decoding Transformer Architecture (https://outcomeschool.com/blog/decoding-transformer-architecture)


Feed-Forward Networks in LLMs

In this blog, we will learn about Feed-Forward Networks in LLMs - understanding what they are, how they work inside the Transformer architecture, why every Transformer layer needs one, and what role they play in making Large Language Models so powerful. We will cover the following:

  • What is a Feed-Forward Network?
  • Understanding Feed-Forward Networks with a Real-World Analogy
  • Where Does the Feed-Forward Network Sit in a Transformer?
  • How Does a Feed-Forward Network Work - Step by Step
  • The Expand-then-Contract Pattern
  • Why Does the FFN Expand and Then Contract?
  • ReLU and Activation Functions
  • What Does the Feed-Forward Network Actually Learn?
  • How Much of the Model is the Feed-Forward Network?
  • Feed-Forward Networks in Mixture of Experts
  • Why Feed-Forward Networks Are So Important

Let’s get started: Feed-Forward Networks in LLMs (https://outcomeschool.com/blog/feed-forward-networks-in-llms)


Batch Normalization vs Layer Normalization

In this blog, we are going to learn about Batch Normalization vs Layer Normalization. We will also see how Batch Normalization and Layer Normalization differ from each other and when to use which one. We will cover the following:

  • What is Normalization?
  • Why do we need Normalization?
  • What is Batch Normalization?
  • What is Layer Normalization?
  • Batch Normalization vs Layer Normalization
  • When to use which one?

Let’s get started: Batch Normalization vs Layer Normalization (https://outcomeschool.com/blog/batch-normalization-vs-layer-normalization)


KV Cache in LLMs

In this blog, we will learn about KV Cache - where K stands for Key and V stands for Value - and why it is used in Large Language Models (LLMs) to speed up text generation. We will start with how LLMs generate text one token at a time, understand the role of Key, Value, and Query inside the model, see the problem of repeated computation through an example, and then walk through how KV Cache solves this problem by storing and reusing past results. We will cover the following:

  • How LLMs Generate Text
  • What Happens Inside the Model
  • The Problem: Repeated Computation
  • The Solution: KV Cache
  • Why Only Key and Value Are Cached, Not Query
  • How Much Faster Does It Get
  • The Trade-Off: Speed vs Memory

Let’s get started: KV Cache in LLMs (https://outcomeschool.com/blog/kv-cache-in-llms)


Paged Attention in LLMs

In this blog, we will learn about Paged Attention, a technique that solves the memory waste problem of KV Cache, allowing LLMs to serve many more users at the same time. We will start with a quick recap of KV Cache, understand the memory problem it creates, see how traditional memory allocation wastes space through an example, and then walk through how Paged Attention solves this problem by borrowing an idea from how computers manage memory. We will cover the following:

  • Quick Recap: KV Cache
  • The Problem: Memory Waste in KV Cache
  • What is Paged Attention?
  • How Paged Attention Works
  • Why Paged Attention Is So Effective
  • Memory Sharing Across Requests

Let’s get started: Paged Attention in LLMs (https://outcomeschool.com/blog/paged-attention-in-llms)


Decoding Flash Attention in LLMs

In this blog, we will learn about Flash Attention by decoding it piece by piece - understanding why standard attention is slow, what makes Flash Attention fast, how it uses GPU memory cleverly, and why it is used in almost every modern Large Language Model (LLM). We will cover the following:

  • A quick recap of standard attention
  • Why standard attention is slow
  • How GPU memory actually works (HBM vs SRAM)
  • The core idea behind Flash Attention
  • Tiling: breaking the work into small blocks
  • Online softmax: computing softmax without the full matrix
  • Recomputation in the backward pass
  • Flash Attention 2
  • Flash Attention 3
  • Advantages and impact of Flash Attention

Let’s get started: Decoding Flash Attention in LLMs (https://outcomeschool.com/blog/decoding-flash-attention)


Speculative Decoding

In this blog, we will learn about Speculative Decoding - what it is, why LLM generation is slow without it, how a small draft model and a big target model work together to produce tokens faster, the rejection sampling math that guarantees no quality loss, real numbers showing the 2x to 3x speedup, where it is used in production, and the trade-offs to watch out for. We will cover the following:

  • What problem does Speculative Decoding solve?
  • The Big Picture
  • Why is LLM generation slow?
  • The core idea behind Speculative Decoding
  • Step-by-step walkthrough
  • The verification step
  • Real numbers and speedup
  • Where it is used
  • Trade-offs
  • Quick Summary

Let’s get started: Speculative Decoding (https://outcomeschool.com/blog/speculative-decoding)


Decoding Medusa

In this blog, we will learn about Medusa, a simple way to make a language model generate text 2 to 3 times faster by giving it several extra heads that guess multiple future tokens at once. We will cover the following:

  • What is Medusa
  • Why text generation is slow
  • A quick recap of speculative decoding
  • The problem with needing a draft model

Similar Articles

@wangxiaoxin88: If you want to truly master LLM inference, this is worth studying closely. Someone put together an LLM Engineer's Practical Handbook — time-to-first-token. Half an hour a day, 10 weeks, 50 lessons total, building a complete production-ready tech stack from scratch: start with a mental model, understand why Decode blows up GPU memory and why Prefill saturates compute...

X AI KOLs Timeline

An open-source LLM engineer's practical handbook called time-to-first-token, offering a 10-week, 50-lesson roadmap to build a production-ready, OpenAI-compatible inference service from scratch — covering vLLM source code, PagedAttention, monitoring, 1000+ concurrency load testing, and quantization optimization.

@Chenfacai0: I've watched quite a few LLM courses — attention mechanisms, fine-tuning, Agents all sound familiar — but only when I actually tried using them did I realize I didn't really understand many parts. llm_course is an open-source Chinese course aimed at algorithm engineers, with 34 lessons and 204 cards, covering content from Transforme…

X AI KOLs Timeline

llm_course is an open-source Chinese LLM course for algorithm engineers, with 40+ lessons of 6 cards each, covering everything from Transformer, training and inference to Agents and post-training paradigms. It uses a problem-driven approach with computational walkthroughs, runs as a single webpage with no login required, and supports offline reading.

@grapeot: How does the LLM inference system actually work? The SGLang Omni team recently published a rare article that lays out the complete decision-making chain of a top inference system team. I followed the original text and organized a popular science post, starting from autoregressive decoding, KV cache, continuous batching...

X AI KOLs Timeline

Based on the SGLang Omni team's internal decision-making article, this post introduces the operating principles of LLM inference systems in an accessible way, starting from basic concepts such as autoregressive decoding, KV cache, and continuous batching.

@vintcessun: 3 courses updated in 3 days: Day00 Learning Map, Day01 Transformer Overview, Day02 Input Layer. One course each morning, with illustrations, tables, formulas, and checklists. The greatest value of this path is letting beginners build understanding starting from the input layer, rather than diving directly into papers. What you learn is—understanding tok…

X AI KOLs Timeline

Published a GitHub repository with an LLM learning path for beginners, covering course content from Transformer basics to LLM techniques, with one course updated daily.

@AYi_AInotes: Fellow developers working on LLM production deployment, check out Andrew Ng's new course. The free version gives you access to all videos and base code. This course is not another rerun of the 'Attention is All You Need' math derivation, nor another set of mystical prompt-tuning tricks, nor yet another toy...

X AI KOLs Timeline

Andrew Ng has launched a new course on LLM production deployment. The free version provides access to all videos and base code. The course dives deep into LLM internals, inference optimization (such as quantization, KV Cache, Flash Attention, speculative decoding), and hardware-aware optimization. Taught by AMD's VP of Engineering, it aims to help developers transform Transformer from an academic concept into a debuggable, optimizable engineering tool.