# Ishwar Jangid > Ishwar Jangid writes long-form, first-principles guides and books on LLM inference, retrieval-augmented generation, GPU programming and ML systems, with code you can run and numbers you can measure. Original explanations by Ishwar Jangid. Research paper authors are credited separately on the relevant pages. Canonical HTML pages contain the full readable text and stable section anchors. Each article also has a Markdown alternative. Cite the canonical page or the relevant section, and preserve the scope of experiments and measurements. [Sitemap](https://ishwarj.com/sitemap.xml) · [RSS](https://ishwarj.com/rss.xml) ## Start here - [Ishwar Jangid: LLM inference, RAG and GPUs, from first principles](https://ishwarj.com/): Ishwar Jangid writes long-form, first-principles guides and books on LLM inference, retrieval-augmented generation, GPU programming and ML systems, with code you can run and numbers you can measure. - [Writings · Ishwar Jangid](https://ishwarj.com/writings/): Long-form essays and deep dives on LLM inference, vLLM, the KV cache, speculative decoding, vector search and HNSW, written from first principles with real measurements. - [Books · Ishwar Jangid](https://ishwarj.com/books/): Free online books written from first principles: RAG, GPU programming, LLMs from scratch and LangGraph, with runnable code in every chapter. - [Topic map · Ishwar Jangid](https://ishwarj.com/map/): Find a learning path through attention, LLM inference, RAG, agents and GPUs. Search topics, explore their connections, and jump to the exact explanation. - [About Ishwar Jangid](https://ishwarj.com/about/): Ishwar Jangid is a software engineer in Delhi, India who builds production AI systems and writes first-principles guides to LLM inference, RAG and GPU programming. - [Research papers · Ishwar Jangid](https://ishwarj.com/papers/): Landmark research papers read slowly, section by section: highlighted excerpts of the paper, clear explanations, definitions, figures, code you can run, and a reader that shows the paper and its explanation side by side. - [Interactive demos · Ishwar Jangid](https://ishwarj.com/demos/): Explore Transformers, Vision Transformers and Segment Anything with interactive browser demos, runnable models, attention visualizations and step-by-step explanations. - [Videos · Ishwar Jangid](https://ishwarj.com/videos/): Animated explainers on vector databases, search and AI systems, each with a written companion, the key numbers and the full transcript. ## Writings - [Every DeepSeek Model, and What Is Really Open · Ishwar Jangid](https://ishwarj.com/writings/deepseek-1-every-model-and-what-is-open/): Every DeepSeek model from 2023 to 2026 with its size, context and license, and exactly what you can download, run or rebuild yourself. [Markdown](https://ishwarj.com/_content/writings/deepseek-1-every-model-and-what-is-open.md) - [The DeepSeek-V3 Architecture, Piece by Piece · Ishwar Jangid](https://ishwarj.com/writings/deepseek-2-the-v3-architecture/): How DeepSeek-V3 holds 671 billion parameters but uses 37 billion per token: many small experts, a fair router, a compressed memory and a second prediction head. [Markdown](https://ishwarj.com/_content/writings/deepseek-2-the-v3-architecture.md) - [How DeepSeek-V3 Was Trained on 2,048 GPUs · Ishwar Jangid](https://ishwarj.com/writings/deepseek-3-training-v3/): How DeepSeek-V3 was trained: 14.8T tokens on 2,048 GPUs, a schedule that hides network time, 8-bit numbers, and what the $5.576M covers. [Markdown](https://ishwarj.com/_content/writings/deepseek-3-training-v3.md) - [DeepSeek-R1 and Reasoning by Reinforcement Learning · Ishwar Jangid](https://ishwarj.com/writings/deepseek-4-r1-and-reasoning-by-rl/): How DeepSeek taught models to reason with rewards a program can check: GRPO by hand, R1-Zero, the four-stage R1 recipe, distillation, costs, and what came after. [Markdown](https://ishwarj.com/_content/writings/deepseek-4-r1-and-reasoning-by-rl.md) - [Sparse Attention in DeepSeek: NSA, DSA and V3.2 · Ishwar Jangid](https://ishwarj.com/writings/deepseek-5-sparse-attention-and-v3-2/): How DeepSeek stopped each new token from reading the whole conversation: NSA, the token scorer of V3.2, its measured costs and the price cut. [Markdown](https://ishwarj.com/_content/writings/deepseek-5-sparse-attention-and-v3-2.md) - [DeepSeek-V4 and V4.1: A Million Tokens of Context · Ishwar Jangid](https://ishwarj.com/writings/deepseek-6-v4-and-v4-1/): How DeepSeek cut the memory per token of context from 389,120 bytes to 890: compressed attention, stable wide residuals, FP4 weights and hashed n-gram memory. [Markdown](https://ishwarj.com/_content/writings/deepseek-6-v4-and-v4-1.md) - [Running DeepSeek on Your Own Hardware, and How DeepSeek Serves It · Ishwar Jangid](https://ishwarj.com/writings/deepseek-7-running-deepseek/): How much memory each DeepSeek model needs, which GPUs, Macs and CPU servers run it at what reported speed, and how DeepSeek serves it at scale. [Markdown](https://ishwarj.com/_content/writings/deepseek-7-running-deepseek.md) - [DeepSeek's Specialised Models: Code, Maths, Proofs, Vision and OCR · Ishwar Jangid](https://ishwarj.com/writings/deepseek-8-the-specialised-models/): The side models behind DeepSeek's main line: Coder, DeepSeekMath and GRPO, the Lean provers, VL2, Janus and DeepSeek-OCR, built up from zero with small experiments. [Markdown](https://ishwarj.com/_content/writings/deepseek-8-the-specialised-models.md) - [vLLM on a Free GPU: Run It, Load It, Break It · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-8-vllm-on-colab/): A real vLLM server on a free Colab T4, measured like a production service: KV cache, batching, the latency knee, prefix caching, preemption, failures. [Markdown](https://ishwarj.com/_content/writings/llm-inference-8-vllm-on-colab.md) - [DeepInfer: How DeepSeek Serves Its Models, and How It Differs from vLLM and SGLang · Ishwar Jangid](https://ishwarj.com/writings/deepseek-9-deepinfer/): A code-level tour of DeepSeek's open-sourced production inference engine: its scheduler, 890-byte KV blocks, expert balancing and DSpark, next to vLLM and SGLang. [Markdown](https://ishwarj.com/_content/writings/deepseek-9-deepinfer.md) - [How Ray-Ban Display Glasses Put a Screen in a Lens · Ishwar Jangid](https://ishwarj.com/writings/how-ray-ban-display-glasses-work/): How a picture appears inside a clear glasses lens: light, a tiny projector, mirrors hidden in glass, a wristband that reads muscles, and the whole system. [Markdown](https://ishwarj.com/_content/writings/how-ray-ban-display-glasses-work.md) - [Reinforcement Learning: From Trial and Error to AlphaZero · Ishwar Jangid](https://ishwarj.com/writings/reinforcement-learning-history/): How machines learned from reward alone: cats in puzzle boxes, Bellman's equation, backgammon, Atari, AlphaGo and the methods later used to train chat models. [Markdown](https://ishwarj.com/_content/writings/reinforcement-learning-history.md) - [From RLHF to Reasoning: How Language Models Are Trained Today · Ishwar Jangid](https://ishwarj.com/writings/how-models-are-trained-today/): How chat and reasoning models are taught after pre-training: human preference labels, AI feedback, answers a program can check, and how we test the result. [Markdown](https://ishwarj.com/_content/writings/how-models-are-trained-today.md) - [Inside a Modern Language Model: Data, Scale and Architecture · Ishwar Jangid](https://ishwarj.com/writings/inside-a-modern-language-model/): How a frontier language model is built before any chat training: the web data, the scaling rules, the layer design, experts, and the machines that train it. [Markdown](https://ishwarj.com/_content/writings/inside-a-modern-language-model.md) - [From One Neuron to Opus: How AI Got Here · Ishwar Jangid](https://ishwarj.com/writings/from-neuron-to-opus/): Eighty years of AI in one story: the first artificial neuron, the AI winters, deep learning, the Transformer, and the road to today's Claude models. [Markdown](https://ishwarj.com/_content/writings/from-neuron-to-opus.md) - [Classical Machine Learning: From Least Squares to XGBoost · Ishwar Jangid](https://ishwarj.com/writings/classical-machine-learning/): The other branch of AI's history: regression, nearest neighbours, Naive Bayes, decision trees, SVMs, random forests and boosting, and why trees still win on tables. [Markdown](https://ishwarj.com/_content/writings/classical-machine-learning.md) - [Serving LLMs in Production: Latency, Capacity, Cost, and What Breaks · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-6-serving-in-production/): TTFT, goodput and honest benchmarks; queueing maths and capacity planning for an 8B model on an H100; cost per million tokens; quantization measured on a real model; routing, multi-LoRA, autoscaling and the failures to watch for. [Markdown](https://ishwarj.com/_content/writings/llm-inference-6-serving-in-production.md) - [Beyond One GPU: Tensor, Pipeline and Expert Parallelism, and Split Prefill and Decode · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-7-beyond-one-gpu/): Why big models need many GPUs, what the wires between them cost, and how tensor, pipeline and expert parallelism and disaggregated serving split the work: a real two-process tensor-parallel run, measured MoE routing, and worked arithmetic. [Markdown](https://ishwarj.com/_content/writings/llm-inference-7-beyond-one-gpu.md) - [SGLang Explained: How It Reuses Work, and How It Differs from vLLM · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-5-sglang-vs-vllm/): RadixAttention from a handbook example: KV reuse maths, real prefill timings, cache and scheduling simulations, and a fair comparison with today's vLLM. [Markdown](https://ishwarj.com/_content/writings/llm-inference-5-sglang-vs-vllm.md) - [Attention, Part 1: Self-Attention and Multi-Head Attention · Ishwar Jangid](https://ishwarj.com/writings/attention-1-self-attention/): The one idea every modern AI language model is built on, explained from zero: why attention was invented, how a word decides which other words to look at, why the scores are divided by √d, how several heads work together, and what real attention heads inside Qwen2.5 actually learn. Every claim checked in code. [Markdown](https://ishwarj.com/_content/writings/attention-1-self-attention.md) - [Attention, Part 2: MQA, GQA and MLA · Ishwar Jangid](https://ishwarj.com/writings/attention-2-mqa-gqa-mla/): Every token leaves its keys and values behind in memory (the KV cache), and plain multi-head attention leaves a lot. How multi-query, grouped-query and multi-head latent attention shrink it, explained from zero, built from scratch, checked against a real model's layer, and measured: DeepSeek-V3 stores 68.6 KiB per token where plain attention would need 4,880. [Markdown](https://ishwarj.com/_content/writings/attention-2-mqa-gqa-mla.md) - [Attention, Part 3: Sliding-Window and Sparse Attention · Ishwar Jangid](https://ishwarj.com/writings/attention-3-sliding-window-sparse/): Why looking at every earlier token gets too expensive, and the three ways today's models avoid it: sliding windows (Mistral), mixing local and global layers (Gemma 2, Gemma 3, gpt-oss), and letting the model pick its own tokens (DeepSeek Sparse Attention). Explained from zero, with equations, quotes from the papers, and real experiments: a lightning indexer trained on Qwen2.5-0.5B keeps quality close to full attention while each token reads only 64 of up to 2,048 earlier tokens. [Markdown](https://ishwarj.com/_content/writings/attention-3-sliding-window-sparse.md) - [Attention, Part 4: Linear Attention, Gated DeltaNet and Hybrid Models · Ishwar Jangid](https://ishwarj.com/writings/attention-4-linear-hybrid/): The newest idea in attention: replace the ever-growing KV cache with a fixed-size memory. Linear attention, the delta rule, forget gates, Gated DeltaNet, Kimi Delta Attention, gated attention, and the hybrid models built from them (Qwen3-Next, Kimi Linear, Nemotron-H). Explained from zero with equations, paper screenshots and real runs, including three small models trained side by side. [Markdown](https://ishwarj.com/_content/writings/attention-4-linear-hybrid.md) - [How an LLM Writes: Prefill and Decode · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-1-prefill-and-decode/): Why the first word takes a moment and the rest stream steadily. Prefill, decode, the GPU's two speeds, the roofline and batching, measured on a real model: reading 512 tokens takes 27 ms, writing 512 takes 5.2 s. [Markdown](https://ishwarj.com/_content/writings/llm-inference-1-prefill-and-decode.md) - [The KV Cache: An LLM's Short-Term Memory, and Its Bill · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-2-kv-cache/): Why an LLM keeps notes on every token, how big they get (16 GiB for one 128K-token Llama 3.1 8B chat), and why the old way of storing them wasted most of the memory. [Markdown](https://ishwarj.com/_content/writings/llm-inference-2-kv-cache.md) - [How vLLM Serves Thousands: Paging, Batching and Caching · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-3-vllm/): How vLLM stores the KV cache in small pages, shares and reuses them, and schedules every step: from 48 to 415 requests on one GPU, pauses cut from 463 ms to 40 ms, a 7x faster first token. [Markdown](https://ishwarj.com/_content/writings/llm-inference-3-vllm.md) - [Speculative Decoding: Several Tokens per Step, Not One Word Changed · Ishwar Jangid](https://ishwarj.com/writings/llm-inference-4-speculative-decoding/): How a small model can guess ahead and a big model can check all the guesses at once, why the output stays exactly the same, and what it really buys on real hardware: speculative decoding built from scratch and measured, from 1.16x on prose to 1.89x on code and 3.49x when the answer copies the prompt. [Markdown](https://ishwarj.com/_content/writings/llm-inference-4-speculative-decoding.md) - [HNSW, From the Ground Up · Ishwar Jangid](https://ishwarj.com/writings/hnsw-from-the-ground-up/): How Hierarchical Navigable Small World graphs find nearest neighbours in microseconds: the two ideas they combine, how the graph is built, what M, efConstruction and efSearch really cost, and measured numbers from a 200,000-vector index. [Markdown](https://ishwarj.com/_content/writings/hnsw-from-the-ground-up.md) ## GPU Programming - [GPU Programming: From zero to kernel engineer · Ishwar Jangid](https://ishwarj.com/books/gpu-programming/): A complete course that teaches you to predict how fast a kernel can go, measure how fast it does go, and close the gap. From CPU parallelism to Hopper, Blackwell, FlashAttention and multi-GPU inference. [Markdown](https://ishwarj.com/_content/books/gpu-programming.md) - [Chapter 1 · CPU Parallelism: What GPUs Are Reacting Against · GPU Programming](https://ishwarj.com/books/gpu-programming/01-cpu-parallelism/): The reference machine for this chapter is an Apple M5 Pro (MacBook Pro, Mac17,8, macOS 26.5.1, 64 GB). Apple's published facts: an 18-core CPU made of 6 "super" cores and 12 "performance" cores, up to 307 GB/s… [Markdown](https://ishwarj.com/_content/books/gpu-programming/01-cpu-parallelism.md) - [Chapter 2 · Why GPUs Exist · GPU Programming](https://ishwarj.com/books/gpu-programming/02-why-gpus/): GPUs were built to color pixels. Each pixel is independent of the others: thousands of identical tiny programs. In the mid-2000s people noticed that a matrix multiply looks the same: thousands of independent dot… [Markdown](https://ishwarj.com/_content/books/gpu-programming/02-why-gpus.md) - [Chapter 3 · The Hardware · GPU Programming](https://ishwarj.com/books/gpu-programming/03-hardware/): You can ignore GPCs and TPCs: they're a graphics-era grouping (and the number of SMs per TPC is not always 2). The SM is the unit you program against. [Markdown](https://ishwarj.com/_content/books/gpu-programming/03-hardware.md) - [Chapter 4 · The Programming Model · GPU Programming](https://ishwarj.com/books/gpu-programming/04-programming-model/): You write a function, called a kernel, that describes the work of one thread. You then launch many thousands of copies of it. [Markdown](https://ishwarj.com/_content/books/gpu-programming/04-programming-model.md) - [Chapter 5 · The Toolchain · GPU Programming](https://ishwarj.com/books/gpu-programming/05-toolchain/): nvcc is not a compiler. It's a driver that splits your .cu file in two and hands each half to a different compiler. [Markdown](https://ishwarj.com/_content/books/gpu-programming/05-toolchain.md) ## RAG: From First Principles - [RAG: From First Principles: To terabyte-scale agentic systems · Ishwar Jangid](https://ishwarj.com/books/rag-first-principles/): Retrieval-augmented generation built and measured step by step. Embeddings, chunking, hybrid search, reranking, evaluation, hallucination, agentic RAG with LangGraph, and ingesting a million PDFs. [Markdown](https://ishwarj.com/_content/books/rag-first-principles.md) - [Setup · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/01-setup/): Five minutes. You need Python 3.12+ via uv, and an OpenAI API key. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/01-setup.md) - [Study Plan · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/02-study-plan/): Three versions. Pick one and put it in your calendar. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/02-study-plan.md) - [The Corpus and the Golden Set · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/03-the-corpus/): Fourteen markdown documents making up the internal handbook of Lumora Robotics, a fictional company that builds warehouse robots (Atlas), fleet software (Beacon) and analytics (Compass). About 5,200 words. Written so… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/03-the-corpus.md) - [Chapter 1 · Why RAG Exists · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/01-why-rag/): A large language model (LLM) answering a question draws on two different sources of information, and it helps to keep them apart from the first page: [Markdown](https://ishwarj.com/_content/books/rag-first-principles/01-why-rag.md) - [Chapter 2 · Embeddings: Meaning as Geometry · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/02-embeddings/): Code for this chapter: code/ch02/embeddingsplayground.py. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/02-embeddings.md) - [Chapter 3 · Your First RAG (LangChain Only) · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/03-first-rag/): Code: code/ch03/firstrag.py. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/03-first-rag.md) - [Chapter 4 · Qdrant: A Real Vector Database · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/04-qdrant/): Code: code/ch04/qdrantrawclient.py, code/ch04/qdrantlangchain.py. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/04-qdrant.md) - [Chapter 5 · Chunking, Measured · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/05-chunking/): Code: code/ch05/chunkinglab.py, code/ch05/semanticchunker.py. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/05-chunking.md) - [Chapter 6 · A Generic, Reusable RAG Pipeline · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/06-generic-rag/): Code: code/ch06/ingest.py, code/ch06/retrieve.py, code/ch06/generate.py, code/ch06/ragcli.py. The finished pipeline is also packaged as ragbook/index.py, which every later chapter calls. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/06-generic-rag.md) - [Chapter 7 · More Data: Growing and Maintaining the Corpus · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/07-more-data/): Code: code/ch07/downloadgutenberg.py, code/ch07/synthesizedocs.py, code/ch07/ingestbatch.py. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/07-more-data.md) - [Chapter 8 · BM25 and Hybrid Search · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/08-bm25-and-hybrid/): Chapters 2–7 built a dense retriever: every chunk becomes one vector, the query becomes one vector, and we return the nearest ones by cosine similarity. It is excellent at meaning: "how fast can the robot move" finds the… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/08-bm25-and-hybrid.md) - [Chapter 9 · Advanced Retrieval: Re-ranking, Query Transforms, Parent/Child, Metadata · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/09-advanced-retrieval/): Chapter 6's retriever was one step: embed → nearest-k. Every production system ends up as a funnel: [Markdown](https://ishwarj.com/_content/books/rag-first-principles/09-advanced-retrieval.md) - [Chapter 10 · Evaluating RAG: Every Metric, How to Compute It, How to Move It · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/10-evaluation/): Every chapter so far ended with "measure it". Here is why: a RAG system has at least eight knobs (chunk size, overlap, k, embedding model, hybrid on/off, re-ranker, prompt, LLM) and every knob interacts with every other… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/10-evaluation.md) - [Chapter 11 · Stopping Hallucination · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/11-hallucination/): The pitch for RAG is "the model answers from your documents, so it cannot make things up." That is half true. Retrieval fixes the knowledge problem: the model no longer has to remember your PTO policy. It does not fix… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/11-hallucination.md) - [Chapter 12 · When the Data Isn't There · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/12-not-enough-data/): Every RAG demo is built on questions the corpus can answer. Every RAG product gets questions it cannot: the policy that was never written down, the product that does not exist, the thing that lives in a different system… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/12-not-enough-data.md) - [Chapter 13 · Observability: Logging, Tracing, Cost and Latency · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/13-observability/): "Why did it answer that?" A RAG answer depends on a query embedding, a nearest-neighbour search, a prompt template, a stochastic model and whatever was in the index at that second. If you did not record those, you cannot… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/13-observability.md) - [Chapter 14 · LangGraph Basics: RAG as a State Machine · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/14-langgraph-basics/): Everything before this chapter used LangChain alone: a retriever, a prompt, a model, glued together with Python. That is enough for "2-step RAG": retrieve, then generate. It stops being enough the moment you want the… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/14-langgraph-basics.md) - [Chapter 15 · Agentic RAG · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/15-agentic-rag/): The interviewer asked: "What is the difference between agentic RAG and generative RAG?" The candidate said "agentic can reason and decide how to retrieve." True, but here is the version that shows you have built one: [Markdown](https://ishwarj.com/_content/books/rag-first-principles/15-agentic-rag.md) - [Chapter 16 · Multi-Agent Systems and Guard Rails · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/16-multi-agent-and-guardrails/): Why it happens. Nobody owns termination. Each agent's job is phrased as "find what is missing": the planner always proposes one more search, the analyst always finds one more gap, and the graph has a cycle with no exit… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/16-multi-agent-and-guardrails.md) - [Chapter 17 · Production: FastAPI, Async, Docker · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/17-production/): New libraries in this chapter: FastAPI (web framework), uvicorn (the ASGI server), httpx (async HTTP client), Docker. Everything RAG-related is unchanged from Chapter 6. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/17-production.md) - [Chapter 18 · Terabyte Scale · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/18-terabyte-scale/): Assumptions (state them, then change them): ~4 characters per token, 800-character chunks with 120 overlap (what ragbook.index uses), text-embedding-3-small at 1536 dims and $0.02 per 1M tokens, a sustained embedding… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/18-terabyte-scale.md) - [Chapter 19 · What's New in RAG, and Is RAG Dead? · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/19-whats-new-in-rag/): This chapter is prose with pointers. Written September 2026; facts are cited inline. Where something is a vendor claim rather than an independent result, it says so. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/19-whats-new-in-rag.md) - [Chapter 20 · The Interview Question Bank · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/20-interview-question-bank/): Answer shape that works in interviews: definition in one sentence → how it works → the trade-off → a number or name → what you would do in production. Most answers below follow it. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/20-interview-question-bank.md) - [Chapter 21 · Retrieval Metrics Under the Microscope · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/21-retrieval-metrics-deep/): No. It means that for 95% of the questions in that evaluation set, under that definition of relevance, at least the labelled evidence appeared somewhere in the top 5 results. It is a claim about one stage of a four-stage… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/21-retrieval-metrics-deep.md) - [Chapter 22 · Vector Search Internals: HNSW, IVF and Quantization · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/22-vector-search-internals/): Chapter 4 gave you HNSW in one page and a table of three knobs: enough to configure a collection. That is the API layer. This chapter is underneath it: we build the graph, break it deliberately, and measure what each… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/22-vector-search-internals.md) - [Chapter 23 · Fusion: Score Distributions, RRF, and Learned Sparse Retrieval · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/23-fusion-and-sparse/): Chapter 8 built BM25, showed the RRF formula, and wired up hybrid search three ways. It asserted that "dense scores are cosines in ~[0.2, 0.8]; BM25 scores are unbounded: you cannot add them." This chapter proves it… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/23-fusion-and-sparse.md) - [Chapter 24 · Rerankers: Bi-encoders, Cross-encoders and Late Interaction · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/24-rerankers/): Here is the whole argument in one sentence: a bi-encoder must decide what a chunk means before it has seen your question. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/24-rerankers.md) - [Chapter 25 · Choosing and Evaluating an Embedding Model · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/25-choosing-an-embedding-model/): The interview question is "how do you choose an embedding model?" The weak answer lists properties: cost, dimensions, multimodality, whether it is open source. Those are inputs. The strong answer is a procedure that ends… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/25-choosing-an-embedding-model.md) - [Chapter 26 · Generation Evaluation and Hallucination Forensics · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/26-hallucination-forensics/): The question is: the retrieved chunks are correct, but the model still hallucinates: what do you do? The tempting answer is "lower the temperature". [Markdown](https://ishwarj.com/_content/books/rag-first-principles/26-hallucination-forensics.md) - [Chapter 27 · Retrieval Debugging: the Rank-17 Playbook · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/27-retrieval-debugging/): The instinct is understandable. The document is at rank 17, k is 5, so make k 20 and the bug is gone. Here is what you actually bought: [Markdown](https://ishwarj.com/_content/books/rag-first-principles/27-retrieval-debugging.md) - [Chapter 28 · Documents in the Real World: PDFs, Tables, Diagrams · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/28-documents-in-the-real-world/): Chapter 5 gave this one section and the honest summary "parsing is where the battle is". This chapter fights the battle. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/28-documents-in-the-real-world.md) - [Chapter 29 · Context Construction: What Actually Reaches the Model · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/29-context-construction/): A million-token context window is not a licence to use it. Four reasons, in order of how often they bite: [Markdown](https://ishwarj.com/_content/books/rag-first-principles/29-context-construction.md) - [Chapter 30 · Ingesting a Million PDFs · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/30-ingesting-a-million-pdfs/): Chapter 18 sized the index: vectors, RAM, quantization. This chapter is about getting the documents into it, which is where the actual engineering time goes. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/30-ingesting-a-million-pdfs.md) - [Appendix A · The Research Papers, in the Order to Learn Them · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/a-research-papers/): Time budget if you read only this appendix: about 3 hours. The two-week plan and the "only 10" list are at the end. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/a-research-papers.md) - [Appendix B · Every Metric on One Sheet · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/b-metrics-cheatsheet/): Notation: for one question, R = set of relevant chunk ids (from the golden set's sources, mapped to chunk ids), L = [l₁, l₂, …] = retrieved chunk ids in rank order, L@k = first k of them, rel(i) = 1 if lᵢ ∈ R else 0. All… [Markdown](https://ishwarj.com/_content/books/rag-first-principles/b-metrics-cheatsheet.md) - [Appendix C · Glossary · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/c-glossary/): One or two lines per term. Chapter numbers point to where the term is used in earnest. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/c-glossary.md) - [Appendix D · API Cheatsheet (LangChain 1.x · LangGraph 1.x · langchain-qdrant · qdrant-client) · RAG: From First Principles](https://ishwarj.com/books/rag-first-principles/d-api-cheatsheet/): Keep this open while coding. Section D.1 is the 90% you use every day. [Markdown](https://ishwarj.com/_content/books/rag-first-principles/d-api-cheatsheet.md) ## Agentic Systems - [Agentic Systems: Patterns, evals and production, from first principles · Ishwar Jangid](https://ishwarj.com/books/agentic-systems/): How real AI agents are designed, measured and run in production: the agent loop, tools and memory, the reasoning and workflow patterns from the research papers, multi-agent systems, evals that actually catch regressions, tracing, guardrails, and what companies like Uber, DoorDash and Anthropic learned the hard way. Written for engineers who know what an LLM call is and want to build systems around it. [Markdown](https://ishwarj.com/_content/books/agentic-systems.md) - [Chapter 1 · What an agent is, and when not to build one · Agentic Systems](https://ishwarj.com/books/agentic-systems/01-what-an-agent-is/): What an agent is and when not to build one: the perceive-reason-act loop, levels of autonomy, reliability arithmetic, and what three companies learned. [Markdown](https://ishwarj.com/_content/books/agentic-systems/01-what-an-agent-is.md) - [Chapter 2 · The building blocks: model, tools, instructions, memory and state · Agentic Systems](https://ishwarj.com/books/agentic-systems/02-the-building-blocks/): The five building blocks of an agent: model, tools, instructions, memory and state, how to design tools a model can call, and context engineering. [Markdown](https://ishwarj.com/_content/books/agentic-systems/02-the-building-blocks.md) - [Chapter 3 · Reasoning patterns: how one agent thinks, acts and corrects itself · Agentic Systems](https://ishwarj.com/books/agentic-systems/03-reasoning-patterns/): Reasoning patterns for one agent: chain of thought, ReAct, plan-and-execute, reflection with an external check, tree search and code as action. [Markdown](https://ishwarj.com/_content/books/agentic-systems/03-reasoning-patterns.md) - [Chapter 4 · Workflow patterns: chaining, routing, parallel work, orchestrators and evaluators · Agentic Systems](https://ishwarj.com/books/agentic-systems/04-workflow-patterns/): Workflow patterns: prompt chains, routers, parallel calls, orchestrators and evaluators; what each costs, how each fails and how to test it. [Markdown](https://ishwarj.com/_content/books/agentic-systems/04-workflow-patterns.md) ## LLM from Scratch - [LLM from Scratch: Tokenizer to GRPO, one working model · Ishwar Jangid](https://ishwarj.com/books/llm-from-scratch/): Build a language model end to end (tokenizer, data pipeline, architecture, pretraining, fine-tuning, mixture of experts, reasoning and RL with GRPO), then learn how frontier labs do the same thing at scale. [Markdown](https://ishwarj.com/_content/books/llm-from-scratch.md) ## How Models Are Trained - [How Models Are Trained: From next-word predictor to assistant: pretraining, SFT, RLHF, DPO and RL for reasoning · Ishwar Jangid](https://ishwarj.com/books/how-models-are-trained/): How a language model goes from predicting the next word to following instructions, holding a conversation and reasoning step by step. The history from 2017 to today, the research papers as highlighted screenshots, every equation explained symbol by symbol, and real code run on real models, in plain English for beginners. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained.md) - [Chapter 1 · From next word to assistant · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/01-from-next-word-to-assistant/): What a language model computes (tokens, next-token probabilities, the chain rule, softmax, cross-entropy, perplexity), the full training pipeline from pretraining to RL with verifiable rewards, and hands-on experiments with Qwen2.5-0.5B base and instruct: the chat template, how few tokens post-training really changes, and a tiny SFT loop. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/01-from-next-word-to-assistant.md) - [Chapter 2 · How it started, and how it evolved · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/02-how-it-started/): The history of how language models learned to follow instructions, told as one story where each step fixes a problem left by the step before: from Shannon's n-grams and the Transformer, through pretraining, learning from human preferences and instruction tuning, to InstructGPT, ChatGPT, DPO, GRPO and DeepSeek-R1. With the papers' own figures, the four key equations worked on real numbers, and small experiments you can run. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/02-how-it-started.md) - [Chapter 3 · How we measure a model · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/03-how-we-measure-a-model/): How language models are measured, and how far to trust the numbers: held-out loss, perplexity and bits per byte; the history of benchmarks from GLUE to GPQA; how a multiple-choice question is really scored; confidence intervals; pass@k; contamination; human preference, Elo and Bradley-Terry ratings; model judges and their biases; reward-model evaluation and reward hacking. With real evaluations of Qwen2.5-0.5B base and Instruct, and the papers' own tables and figures. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/03-how-we-measure-a-model.md) - [Chapter 4 · Pretraining: learning from the whole internet · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/04-pretraining/): Pretraining from the inside: how web text is collected, filtered and deduplicated, how it is tokenized, what training costs (C = 6ND), what scaling laws say about model size and data, the learning-rate schedule, batch size and mixed precision, and a real 12M-parameter GPT pretrained from random weights. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/04-pretraining.md) - [Chapter 5 · Supervised fine-tuning: teaching it to follow instructions · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/05-supervised-fine-tuning/): Supervised fine-tuning from the inside: the same loss on different data with the prompt masked out, the history of instruction datasets from FLAN to Tulu 3, chat templates, a worked masked loss on real tokens, hyperparameters and packing, LoRA and QLoRA with their maths, catastrophic forgetting, and a real LoRA fine-tune of Qwen2.5-0.5B. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/05-supervised-fine-tuning.md) - [Chapter 6 · Reinforcement learning, from scratch · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/06-reinforcement-learning-basics/): Reinforcement learning built up from nothing for language models: the vocabulary mapped onto text, return and discount, the policy gradient derived step by step with the log-derivative trick, REINFORCE, why variance is the enemy, baselines with a proof that they cost no bias, value functions, advantages, TD errors and GAE with its lambda trade-off, and the per-token KL penalty as reward shaping. Hands-on: a bandit over 200 seeds, a token world where every value is exact, and REINFORCE on GPT-2 with and without a KL penalty. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/06-reinforcement-learning-basics.md) - [Chapter 7 · Reward models: turning preferences into a number · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/07-reward-models/): Reward models from the inside: why RLHF learns a reward instead of asking people every time, ratings against comparisons, the Bradley-Terry model derived from a noisy-judge story, the reward model loss and its gradient worked by hand, rankings, label noise and normalisation, the architecture (a language model with a one-number head), a real LoRA reward model trained on UltraFeedback, its accuracy, calibration and length bias, best-of-n overoptimisation against a stronger gold reward model, margins and ensembles, and process rewards. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/07-reward-models.md) - [Chapter 8 · RLHF with PPO: the full loop · How Models Are Trained](https://ishwarj.com/books/how-models-are-trained/08-rlhf-with-ppo/): RLHF with PPO from the inside: why plain REINFORCE wastes samples and takes unsafe steps, trust regions in plain words, the probability ratio and PPO's clipped objective worked by hand, the value loss and the entropy bonus, GAE on a real reply, the four models of RLHF and what they cost in memory, the implementation details that make PPO work for language models, and a from-scratch PPO run on Qwen2.5-0.5B-Instruct against the Chapter 7 reward model, checked by a stronger gold judge. [Markdown](https://ishwarj.com/_content/books/how-models-are-trained/08-rlhf-with-ppo.md) ## LangGraph & LangChain - [LangGraph & LangChain: From zero to production agents · Ishwar Jangid](https://ishwarj.com/books/langgraph-deep-dive/): A doc-verified, code-first book on LangGraph 1.2 and LangChain 1.4: models, messages, graphs, checkpointers, middleware, multi-agent systems and a production architecture review. [Markdown](https://ishwarj.com/_content/books/langgraph-deep-dive.md) ## Research paper explanations and demos - [DeepSeek-R1, explained: DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/): The January 2025 paper that taught a language model to reason with reinforcement learning and two simple rules for reward. Eight parts, with the paper's own text, worked equations, GRPO written from scratch in Python, and real runs on the released distilled model. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1.md) - [DeepSeek-R1, Background: The Road to R1 · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/background-the-road-to-r1/): How a language model learns, how it was taught to show its steps, and how reinforcement learning with human feedback works. The ideas the R1 paper assumes, with small runs you can check. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/background-the-road-to-r1.md) - [DeepSeek-R1, Part 1: The Big Idea: Reasoning from a Reward · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-1-the-big-idea/): A model that learned to think step by step from one signal: was the final answer right. We read the title, the abstract, Figure 1 and §1, and run the released 1.5B model next to its base model. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-1-the-big-idea.md) - [DeepSeek-R1, Part 2: GRPO: Learning from a Group of Answers · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-2-grpo/): The learning rule behind DeepSeek-R1, term by term: sample a group of answers, score them, and push the model toward the better ones without a critic. We write GRPO from scratch, match it with TRL, and run one real step on a small model. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-2-grpo.md) - [DeepSeek-R1, Part 3: Rewards and the Template · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-3-rewards-and-the-template/): How R1-Zero scores its own answers with two simple rules, why the authors refused a learned reward model, and the one-paragraph prompt that starts training. We write each reward two ways, game a weak reward on purpose, and test two base models in the real template. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-3-rewards-and-the-template.md) - [DeepSeek-R1, Part 4: R1-Zero and the Aha Moment · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-4-r1-zero-and-the-aha-moment/): What pure RL gave DeepSeek-R1-Zero, why its answers grew from hundreds to thousands of tokens, and the moment it wrote Wait. We test the released 1.5B distill. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-4-r1-zero-and-the-aha-moment.md) - [DeepSeek-R1, Part 5: The R1 Pipeline: Four Stages · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-5-the-r1-pipeline/): How R1-Zero's raw skill became DeepSeek-R1: a cold start, reasoning RL with a language reward, rejection sampling into 800k examples, and a last RL stage. We run each idea in Python. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-5-the-r1-pipeline.md) - [DeepSeek-R1, Part 6: Distillation: Small Models That Reason · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-6-distillation/): How 800k answers written by R1 teach six small open models to reason with plain fine-tuning, and why this beat RL on the same model. We write the loss by hand and test a distilled 1.5B model. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-6-distillation.md) - [DeepSeek-R1, Part 7: Results, Failures and Limits · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-7-results-failures-and-limits/): How R1 is scored, where it wins and where it loses, the two ideas that failed, and what R1 still cannot do. We write pass@k and majority voting in Python, and test greedy decoding and few-shot prompts on the 1.5B model. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-7-results-failures-and-limits.md) - [DeepSeek-R1, Part 8: Train a Reasoner from Scratch: R1-Zero's Recipe in 330 Lines · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/part-8-train-a-reasoner-from-scratch/): We write the whole DeepSeek-R1-Zero method in a small Python package: the template, the two reward rules and GRPO. We check it against TRL and train a 0.5B model on a laptop. [Markdown](https://ishwarj.com/_content/papers/deepseek-r1/part-8-train-a-reasoner-from-scratch.md) - [DeepSeek-R1, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/deepseek-r1/read/): Read the DeepSeek-R1 paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [vLLM, explained: Efficient Memory Management for Large Language Model Serving with PagedAttention · Ishwar Jangid](https://ishwarj.com/papers/vllm/): The 2023 paper behind vLLM: it stores the memory of each chat request in small blocks, the way an operating system stores memory in pages, and serves 2 to 4 times more requests on the same GPU. Read with the paper's own text and real code. [Markdown](https://ishwarj.com/_content/papers/vllm.md) - [vLLM, Background: The KV Cache and Paging · Ishwar Jangid](https://ishwarj.com/papers/vllm/background-the-kv-cache-and-paging/): The two ideas the paper joins: the cache of keys and values that a language model keeps while it writes, and the pages an operating system uses to hand out memory. With small runs you can check. [Markdown](https://ishwarj.com/_content/papers/vllm/background-the-kv-cache-and-paging.md) - [vLLM, Part 1: The Big Idea: Memory, Not Arithmetic, Limits LLM Serving · Ishwar Jangid](https://ishwarj.com/papers/vllm/part-1-the-big-idea/): How a chat server answers many users at once, why its GPU runs out of memory before it runs out of speed, and the paper's fix: store each request's memory in small pages. We read the title, the abstract, Figures 1 and 2 and §1, and we measure the KV cache of a real model. [Markdown](https://ishwarj.com/_content/papers/vllm/part-1-the-big-idea.md) - [vLLM, Part 2: Why Memory Is the Bottleneck · Ishwar Jangid](https://ishwarj.com/papers/vllm/part-2-why-memory-is-the-bottleneck/): How a language model writes text, why one GPU must serve many requests at once, and where the memory for those requests goes. We read §2, §3 and Figure 3, with runs on a real model. [Markdown](https://ishwarj.com/_content/papers/vllm/part-2-why-memory-is-the-bottleneck.md) - [vLLM, Part 3: PagedAttention · Ishwar Jangid](https://ishwarj.com/papers/vllm/part-3-pagedattention/): How vLLM stores each request's keys and values in small blocks that can sit anywhere in memory, and still computes the same attention. We read §4.1 to §4.3 and build a block table that drives a real model. [Markdown](https://ishwarj.com/_content/papers/vllm/part-3-pagedattention.md) - [vLLM, Part 4: Sharing, Scheduling and Many GPUs · Ishwar Jangid](https://ishwarj.com/papers/vllm/part-4-sharing-scheduling-and-many-gpus/): How vLLM lets several answers share one prompt's memory, what it does when memory runs out, and how it runs one model on many GPUs. We read §4.4 to §4.6 and §5, and build each piece in Python. [Markdown](https://ishwarj.com/_content/papers/vllm/part-4-sharing-scheduling-and-many-gpus.md) - [vLLM, Part 5: The Experiments · Ishwar Jangid](https://ishwarj.com/papers/vllm/part-5-the-experiments/): How the paper tests vLLM against FasterTransformer and three versions of Orca, how to read its latency plots, and what the ablations show. We rebuild the main experiments as a small serving simulation on real request lengths. [Markdown](https://ishwarj.com/_content/papers/vllm/part-5-the-experiments.md) - [vLLM, Part 6: Build It from Scratch · Ishwar Jangid](https://ishwarj.com/papers/vllm/part-6-build-it-from-scratch/): We write a small vLLM in about 500 lines of Python: blocks, block tables, PagedAttention, a scheduler and parallel sampling. It runs the real OPT-125M, matches the transformers library and serves real requests. [Markdown](https://ishwarj.com/_content/papers/vllm/part-6-build-it-from-scratch.md) - [vLLM, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/vllm/read/): Read the vLLM paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [Meta-Harness, explained: Meta-Harness: End-to-End Optimization of Model Harnesses · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/): The 2026 paper that lets a coding agent write the code around a language model, by reading every earlier attempt's code, scores and traces. Six parts, with the paper's own text, worked examples, and a small Meta-Harness loop built from scratch in Python. [Markdown](https://ishwarj.com/_content/papers/meta-harness.md) - [Meta-Harness, Background: What a Harness Is · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/background-what-a-harness-is/): The code around a language model decides what it remembers, looks up and sees. This page shows that code, the agent loop, and the earlier methods that tried to improve prompts and programs automatically. With a small model on a real banking task. [Markdown](https://ishwarj.com/_content/papers/meta-harness/background-what-a-harness-is.md) - [Meta-Harness, Part 1: The Big Idea: Let an Agent Write the Harness · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/part-1-the-big-idea/): Why the code around a language model can matter as much as the model, and the paper's proposal: a coding agent that reads every earlier attempt and writes a better one. We read the title, Figure 1, the abstract and §1, and we run one small model with four different harnesses. [Markdown](https://ishwarj.com/_content/papers/meta-harness/part-1-the-big-idea.md) - [Meta-Harness, Part 2: The Method: A Loop That Reads Every Earlier Attempt · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/part-2-the-method/): How Meta-Harness searches for better harness code: the goal written as one formula, the loop of Figure 2 and Algorithm 1, and the folder of past attempts that the proposer reads. We run the whole loop in Python with a small local model and a scripted proposer. [Markdown](https://ishwarj.com/_content/papers/meta-harness/part-2-the-method.md) - [Meta-Harness, Part 3: Text Classification: What the Search Found · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/part-3-text-classification/): The first test of Meta-Harness: a model sorts short texts into classes, and the search writes the code that picks its examples. We read the tables, the accuracy and context trade-off, and the two discovered harnesses, then rebuild both around a small local model. [Markdown](https://ishwarj.com/_content/papers/meta-harness/part-3-text-classification.md) - [Meta-Harness, Part 4: Math Retrieval and TerminalBench-2 · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/part-4-math-and-terminalbench/): How Meta-Harness found a way to look up solved problems for olympiad math, and a better harness for an agent that works in a terminal. We build the search engine and the discovered retriever in Python, test them with a small local model, and run two key pieces of the released agent code. [Markdown](https://ishwarj.com/_content/papers/meta-harness/part-4-math-and-terminalbench.md) - [Meta-Harness, Part 5: Limits, and What Came After · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/part-5-limits-and-what-came-after/): Where Meta-Harness can fool itself, what a search costs, and why it rests on one strong proposer. Then five later papers that changed the loop, each read from its own PDF, and a small run on a laptop that shows how a search score can look better than it is. [Markdown](https://ishwarj.com/_content/papers/meta-harness/part-5-limits-and-what-came-after.md) - [Meta-Harness, Part 6: Build It from Scratch: A Small Meta-Harness in Python · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/part-6-build-it-from-scratch/): We build the whole Meta-Harness loop in about a thousand lines of Python: a task, harness files, an evaluator that logs every prompt, a folder per candidate, and two proposers. Then we run it on a laptop with small local models and measure the gap between the search set and the test set. [Markdown](https://ishwarj.com/_content/papers/meta-harness/part-6-build-it-from-scratch.md) - [Meta-Harness, the search loop · Meta-Harness · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/demo/): Open a real harness search: every candidate's code, traces and score, as the proposer sees them, and the gap between the search set and the held-out test set. Then choose what a proposer may read, and explore the paper's own results. - [Meta-Harness, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/meta-harness/read/): Read the Meta-Harness paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [Transformer, explained: Attention Is All You Need · Ishwar Jangid](https://ishwarj.com/papers/transformer/): The 2017 paper that replaced recurrence with attention and gave us the Transformer, the design behind every large language model today. Seven parts, with the paper's own text, worked equations, the whole model written from scratch in Python, and real code on a released translation model. [Markdown](https://ishwarj.com/_content/papers/transformer.md) - [Transformer, Background: The Road to the Transformer · Ishwar Jangid](https://ishwarj.com/papers/transformer/background-the-road-to-the-transformer/): How machines translated sentences before 2017: recurrent networks, LSTMs, sequence to sequence and the first attention. Each idea fixed a problem, and each one left the problem that the Transformer solves. With small runs you can check. [Markdown](https://ishwarj.com/_content/papers/transformer/background-the-road-to-the-transformer.md) - [Transformer, Part 1: The Big Idea: Attention Is All You Need · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-1-the-big-idea/): Why the best translation models of 2016 were slow to train, and the claim that attention alone can replace them. We read the title, the abstract and the first two sections, and we run a released Transformer that translates English into German. [Markdown](https://ishwarj.com/_content/papers/transformer/part-1-the-big-idea.md) - [Transformer, Part 2: The Architecture: Stacks, Feed-Forward Layers and Positions · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-2-the-architecture/): How the Transformer is built, block by block: the encoder and decoder stacks, the add and norm step, the feed-forward layer, the embeddings and the sine waves that give each word its place. We open a released English to German model, rebuild each piece in our own Python code and check it against the model. [Markdown](https://ishwarj.com/_content/papers/transformer/part-2-the-architecture.md) - [Transformer, Part 3: Attention: Queries, Keys and Values · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-3-attention/): How one attention step works, why the scores are divided by the square root of the key size, and why the model runs eight heads side by side. We write attention and multi-head attention from scratch in Python, match them with the PyTorch library and with a released translation model, and show three common bugs. [Markdown](https://ishwarj.com/_content/papers/transformer/part-3-attention.md) - [Transformer, Part 4: Why Self-Attention: Cost, Steps and Paths · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-4-why-self-attention/): Section 4 compares self-attention with recurrent and convolutional layers on three measures: work per layer, steps that must wait for each other, and the distance a signal must travel. We compute every column of Table 1 in Python, check the counts with a FLOP counter, and build the restricted attention window in code. [Markdown](https://ishwarj.com/_content/papers/transformer/part-4-why-self-attention.md) - [Transformer, Part 5: Training: Data, Schedule, Adam and Regularization · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-5-training/): How the Transformer was trained: the data, the batches, eight GPUs for twelve hours, Adam with a warm-up learning rate, dropout and label smoothing. We write each rule in Python, check it against PyTorch, and train a tiny Transformer step by step. [Markdown](https://ishwarj.com/_content/papers/transformer/part-5-training.md) - [Transformer, Part 6: Results, Variations and Impact · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-6-results-and-impact/): What the Transformer scored, what it cost to train, which parts of it matter, and how it did on a second task. We write BLEU, beam search, checkpoint averaging and the size count in Python, and check each one against a library. [Markdown](https://ishwarj.com/_content/papers/transformer/part-6-results-and-impact.md) - [Transformer, Part 7: Build It from Scratch: The Whole Transformer in PyTorch · Ishwar Jangid](https://ishwarj.com/papers/transformer/part-7-build-it-from-scratch/): We write the whole Transformer of the paper in readable PyTorch, one small class per block, and check each block against PyTorch's own layers. Then we load a released translation model into our code, get the same translations, and train a small model on a laptop. [Markdown](https://ishwarj.com/_content/papers/transformer/part-7-build-it-from-scratch.md) - [The Transformer, step by step · Transformer · Ishwar Jangid](https://ishwarj.com/papers/transformer/demo/): Type a date and follow it through our own small Transformer, live in your browser: tokens, positions, every attention head, and the decoder writing one token at a time. Then look inside a real English to German translator, and work Equation 1 by hand. - [Transformer, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/transformer/read/): Read the Transformer paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [SAM, explained: Segment Anything · Ishwar Jangid](https://ishwarj.com/papers/sam/): The 2023 paper that made one model cut out any object in any picture from a click, a box or a rough mask. It shows a new task, the model SAM and a dataset of 1.1 billion masks. Six parts, with the paper's own text, pictures, worked equations and real code on the released models. [Markdown](https://ishwarj.com/_content/papers/sam.md) - [SAM, Background: The Road to SAM · Ishwar Jangid](https://ishwarj.com/papers/sam/background-the-road-to-sam/): Before SAM, each segmentation model knew a fixed list of objects. How FCN, YOLO and Mask R-CNN got there, how GPT-3 and CLIP brought the prompt, and how SAM joins the two roads. With YOLO and SAM on the same photo. [Markdown](https://ishwarj.com/_content/papers/sam/background-the-road-to-sam.md) - [SAM, Part 1: The Big Idea: Segment Anything · Ishwar Jangid](https://ishwarj.com/papers/sam/part-1-the-big-idea/): Meet SAM, a model that cuts one object out of a photo after one click. We read the first two pages of the paper, and we run SAM on a photo of two cats. [Markdown](https://ishwarj.com/_content/papers/sam/part-1-the-big-idea.md) - [SAM, Part 2: The Task: Promptable Segmentation · Ishwar Jangid](https://ishwarj.com/papers/sam/part-2-the-task/): What SAM must learn: a valid mask for any prompt. We read §2 and Figure 3 of the paper, and we test ambiguous clicks, extra points, boxes and the paper's training game on the cat photo. [Markdown](https://ishwarj.com/_content/papers/sam/part-2-the-task.md) - [SAM, Part 3: The Model: Encoder, Prompts and Decoder · Ishwar Jangid](https://ishwarj.com/papers/sam/part-3-the-model/): How SAM turns a photo and a click into three masks and three scores. We open the released model, follow each tensor through it, and compute its training loss by hand. [Markdown](https://ishwarj.com/_content/papers/sam/part-3-the-model.md) - [SAM, Part 4: The Data Engine and SA-1B · Ishwar Jangid](https://ishwarj.com/papers/sam/part-4-data-engine-and-sa-1b/): How SAM first helped people draw masks, and then drew 1.1 billion masks by itself. We rebuild its automatic step on two photos and check each filter. [Markdown](https://ishwarj.com/_content/papers/sam/part-4-data-engine-and-sa-1b.md) - [SAM, Part 5: Zero-Shot Experiments: One Model, Five Tasks · Ishwar Jangid](https://ishwarj.com/papers/sam/part-5-zero-shot-experiments/): The paper tests SAM on pictures and jobs that it never saw in training. We explain each score, and we repeat the tests in small on 40 objects drawn by people. [Markdown](https://ishwarj.com/_content/papers/sam/part-5-zero-shot-experiments.md) - [SAM, Part 6: After SAM: Impact, Limits and Summary · Ishwar Jangid](https://ishwarj.com/papers/sam/part-6-impact-and-summary/): Where SAM fails, measured with the released model on a bicycle, a drawn wheel and an edge with teeth. Then five later papers that fixed those limits, and the whole paper in one page. [Markdown](https://ishwarj.com/_content/papers/sam/part-6-impact-and-summary.md) - [Segment Anything, live · SAM · Ishwar Jangid](https://ishwarj.com/papers/sam/demo/): Click on a photo and watch the real SAM ViT-H answer with three masks and three scores. The mask decoder runs in your browser for every click. - [SAM, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/sam/read/): Read the SAM paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [Circuits, explained: A Mathematical Framework for Transformer Circuits · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/): The 2021 paper that started reverse-engineering transformers by hand. It writes a small attention-only model as a sum of simple pieces you can read straight from the weights: bigram tables, skip-trigrams and induction heads. Every equation is derived step by step, next to the paper's own figures and real code on small open models. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits.md) - [Circuits, Part 1: The Big Idea and the Residual Stream · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-1-the-residual-stream/): The opening of A Mathematical Framework for Transformer Circuits, read slowly: what mechanistic interpretability is, why the paper studies tiny attention-only models, the whole model written as four equations with every symbol and shape, the residual stream as a shared channel that layers read from and write to, virtual weights, the bandwidth problem, and why a zero-layer transformer can only learn bigrams. Every equation derived by hand, then checked on real models. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-1-the-residual-stream.md) - [Circuits, Part 2: One Attention Head, Taken Apart: the QK and OV Circuits · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-2-one-attention-head/): The attention-head sections of A Mathematical Framework for Transformer Circuits, read slowly: why heads are independent and simply add, how a head moves information between tokens, the tensor-product form h(x) = (A ⊗ W_O W_V) x explained with a tiny example, why the four matrices of a head collapse into two low-rank ones, and the QK and OV circuits read straight from the weights of a real model. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-2-one-attention-head.md) - [Circuits, Part 3: Paths Through the Model: the Path Expansion Trick · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-3-paths-through-the-model/): How the paper turns a one-layer model into a sum of end-to-end paths, one for the token itself and one for each head. We expand the real model, freeze its attention, and check every term. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-3-paths-through-the-model.md) - [Circuits, Part 4: One-Layer Models: Skip-Trigrams, Copying and Their Bugs · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-4-one-layer-models/): What a one-layer attention-only model really learns, read from its weights: skip-trigrams, copying, heads that only look at position, the bugs of a factored form, and eigenvalues as a test for copying. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-4-one-layer-models.md) - [Circuits, Part 5: Two-Layer Models: How Heads Compose · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-5-two-layer-models/): With a second layer, one head can read what an earlier head wrote. We follow the paper's three kinds of composition, expand the logits and the attention scores into paths, and measure which paths matter in a real two-layer model. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-5-two-layer-models.md) - [Circuits, Part 6: Induction Heads · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-6-induction-heads/): How a two-layer model learns to continue a pattern it saw earlier in the text. We find the two heads that do it in a real model, test them on random tokens, and break them on purpose. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-6-induction-heads.md) - [Circuits, Part 7: What the Paper Left Out, and What Came After · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/part-7-after-the-paper/): The paper's own view of its limits, the MLP layers it could not read, and the later papers that grew from it. We train a tiny model that packs five features into two numbers, and read real MLP neurons. [Markdown](https://ishwarj.com/_content/papers/transformer-circuits/part-7-after-the-paper.md) - [Circuits, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/transformer-circuits/read/): Read the Circuits paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [ViT, explained: An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale · Ishwar Jangid](https://ishwarj.com/papers/vit/): The 2020 paper that cut an image into 16×16 patches, fed them to an unchanged Transformer, and beat the best convolutional networks once it was given enough data. Explained line by line in six parts, with the paper's own text, pictures, worked equations and real code on the released models. [Markdown](https://ishwarj.com/_content/papers/vit.md) - [ViT, Part 1: The Big Idea: An Image Is Worth 16×16 Words · Ishwar Jangid](https://ishwarj.com/papers/vit/part-1-the-big-idea/): The title, the abstract and the introduction of the Vision Transformer paper, line by line: what it means to cut a picture into 16×16 patches and read them like words, why convolutional networks ruled computer vision, what inductive bias, locality and translation equivariance are, and the claim that enough data beats built-in assumptions. With a real run of ViT-B/16 and ResNet-50 on the same picture and the quadratic cost of attention worked out by hand. [Markdown](https://ishwarj.com/_content/papers/vit/part-1-the-big-idea.md) - [ViT, Part 2: Inside ViT: Patches, Embeddings and the Encoder · Ishwar Jangid](https://ishwarj.com/papers/vit/part-2-the-model/): Section 2, Figure 1, Section 3.1 and Appendix A, line by line: the earlier attempts to put attention on images, then every step from a 224×224 picture to a class label, with Equations 1 to 8 recomputed by hand on the released ViT-B/16 and matched against the library at every stage, the 86,567,656 parameters counted exactly, and a four-token attention example small enough to check with a pencil. [Markdown](https://ishwarj.com/_content/papers/vit/part-2-the-model.md) - [ViT, Part 3: Fine-tuning, Higher Resolution and the Setup · Ishwar Jangid](https://ishwarj.com/papers/vit/part-3-fine-tuning-and-setup/): How a pre-trained ViT is adapted to a new task, why it is fine-tuned on bigger pictures, and the full training recipe behind every result. We swap the head, stretch the position embeddings, fine-tune on ten classes and solve the few-shot metric by hand. [Markdown](https://ishwarj.com/_content/papers/vit/part-3-fine-tuning-and-setup.md) - [ViT, Part 4: Results: Beating Big CNNs, and How Much Data It Takes · Ishwar Jangid](https://ishwarj.com/papers/vit/part-4-results/): Sections 4.2 and 4.3 with their tables and appendix: how ViT compares with the best convolutional networks of 2020, and how much pre-training data it needs before it wins. We recompute every table and test seven released models on two of the paper's datasets. [Markdown](https://ishwarj.com/_content/papers/vit/part-4-results.md) - [Vision Transformer, step by step · ViT · Ishwar Jangid](https://ishwarj.com/papers/vit/demo/): Pick a picture or use your own photo, and follow a real ViT from pixels to a class: the patches, the embeddings, the position embeddings, every attention map and the answer. - [ViT, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/vit/read/): Read the ViT paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. - [BERT, explained: BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding · Ishwar Jangid](https://ishwarj.com/papers/bert/): The 2018 paper that taught one model to read text in both directions at once, then reuse that skill for almost any language task. Explained line by line in six parts, with the paper's own text, pictures and real code. [Markdown](https://ishwarj.com/_content/papers/bert.md) - [BERT, Background: Before and After BERT · Ishwar Jangid](https://ishwarj.com/papers/bert/background-before-and-after-bert/): How machines learned to read: from counting word pairs to word vectors, recurrent networks, attention and pre-training, then BERT and everything after it, up to 2026. With the maths of each step and small runs you can check. [Markdown](https://ishwarj.com/_content/papers/bert/background-before-and-after-bert.md) - [BERT, Part 1: The Big Idea: Reading in Both Directions · Ishwar Jangid](https://ishwarj.com/papers/bert/part-1-the-big-idea/): The title, the abstract and the introduction of the BERT paper, line by line: what pre-training is, the two ways to reuse a pre-trained model, why reading only left to right is a real limit, and BERT's fix of filling in blanks. With a real run of GPT-2 and BERT on the same sentences. [Markdown](https://ishwarj.com/_content/papers/bert/part-1-the-big-idea.md) - [BERT, Part 2: Inside BERT: Architecture and Input · Ishwar Jangid](https://ishwarj.com/papers/bert/part-2-architecture-and-input/): Section 2 and the model half of Section 3, line by line: the ideas BERT builds on, the stack of Transformer layers, where the 110 million parameters come from (counted in the real model), WordPiece tokens, [CLS], [SEP], and the three embeddings that are added together for every token. [Markdown](https://ishwarj.com/_content/papers/bert/part-2-architecture-and-input.md) - [BERT, Part 3: Pre-training: Masked LM and Next Sentence Prediction · Ishwar Jangid](https://ishwarj.com/papers/bert/part-3-pre-training/): Section 3.1 and Appendices A.1 and A.2 of the BERT paper, line by line: why a normal language model cannot look both ways, the masked language model and its 80/10/10 rule, next sentence prediction, the training data and the full training recipe. Every claim run on the real model or measured in code. [Markdown](https://ishwarj.com/_content/papers/bert/part-3-pre-training.md) - [BERT, Part 4: Fine-tuning and Results: GLUE, SQuAD and SWAG · Ishwar Jangid](https://ishwarj.com/papers/bert/part-4-fine-tuning-and-results/): Sections 3.2 and 4 of the BERT paper, line by line: how one pre-trained model becomes a classifier, a question answerer and a multiple-choice solver by adding a tiny output layer, and what the results tables really say. With a real fine-tune of BERT-base on SST-2 and MRPC, and our own span search scored on the full SQuAD dev sets. [Markdown](https://ishwarj.com/_content/papers/bert/part-4-fine-tuning-and-results.md) - [BERT, Part 5: Ablations: What Really Matters · Ishwar Jangid](https://ishwarj.com/papers/bert/part-5-ablations/): Section 5 and Appendix C of the BERT paper, line by line: which parts of BERT actually cause its gains. Next sentence prediction, bidirectionality, model size, frozen features versus fine-tuning, training length and the 80/10/10 masking recipe, every table row explained, with real parameter counts, a real perplexity and a real re-run of the feature-based NER experiment. [Markdown](https://ishwarj.com/_content/papers/bert/part-5-ablations.md) - [BERT, Part 6: After BERT: Impact, Limits and Summary · Ishwar Jangid](https://ishwarj.com/papers/bert/part-6-impact-and-summary/): The paper's conclusion, what came next (RoBERTa, ALBERT, DistilBERT, ELECTRA, Sentence-BERT and more), BERT's real limits measured on real models, how BERT-style models are used today, and the whole paper summarised on one page. [Markdown](https://ishwarj.com/_content/papers/bert/part-6-impact-and-summary.md) - [BERT, read beside the paper · Ishwar Jangid](https://ishwarj.com/papers/bert/read/): Read the BERT paper with its explanation beside it: scroll the paper, and the explanation of each highlighted passage follows. ## Videos and transcripts - [Jev: The AI Model That Doesn't Talk. It Decides. · Ishwar Jangid](https://ishwarj.com/videos/jev-decision-model/): What Jev, TypeSafe's decision model, actually is, where it fits next to plain code, a classifier and an LLM, and three real uses: an agent router that makes four decisions in one call, a cheap gate before a big model, and a guardrail around an LLM. Every number from real API runs. [Markdown](https://ishwarj.com/_content/videos/jev-decision-model.md) - [How Vector Search Really Works: HNSW, Filters and Qdrant · Ishwar Jangid](https://ishwarj.com/videos/vectors-in-depth-1/): Vectors in Depth, Part 1. How a vector database finds the nearest meaning among millions of points in a fraction of a millisecond: embeddings, the HNSW graph and its three knobs, and the hard part, making approximate geometry obey exact filters. Every number from real Qdrant runs. [Markdown](https://ishwarj.com/_content/videos/vectors-in-depth-1.md)