Skip to content

About

Master curriculum for Forward Deployed Engineering (FDE) & Production Generative AI Systems. Covers enterprise AI architecture, mathematical foundations of Transformers & Attention, RAG systems, and production AI stack design.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸš€ Forward Deployed Engineer (FDE) & Generative AI Systems

🧠 Master Curriculum & Engineering Reference for Building Production-Grade Enterprise AI

Lecture notes Β· System architectures Β· Mathematical foundations Β· Paper deep-dives Β· Production blueprints

Lectures Chapter Notes Notes Volume Code

Paper Deep-Dives Runnable Code Status PRs Welcome

πŸ“– Start the Curriculum Β· πŸ—ΊοΈ Learning Path Β· πŸš€ Quick Start Β· πŸ“‘ Master Index


🧭 Table of Contents

Section What's inside
🎯 Repository Overview What this repository is and who it is for
πŸ“Š Repository at a Glance Hard numbers: lectures, chapters, lines of notes, lines of code
πŸ—ΊοΈ Learning Path The five-phase route through the curriculum
πŸ“š Curriculum Navigation Every lecture, note set, codebase and implementation guide
πŸ“– Lecture Highlights Deep-dive summaries of all 12 lectures
🧰 Technology Stack Languages, frameworks, services and SDKs used
πŸš€ Quick Start How to read the notes and run the code
πŸ—‚οΈ Repository Structure Directory map
πŸ“ Conventions How every note set, codebase and guide is organised
πŸ›£οΈ Roadmap Where the curriculum is heading
🀝 Contributing How to add or improve a lecture
πŸ“„ License & Attribution Usage terms

🎯 Repository Overview

The thesis of this repository: a Forward Deployed Engineer is not the person who ships the requested chatbot β€” it is the person who discovers the real business problem and then proves the fix with a measurable system.

This repository contains structured lecture notes, system architectures, mathematical foundations, paper deep-dives, and production blueprints for Forward Deployed Engineers (FDEs) and Generative AI Systems Architects.

Theme What it covers
🧭 Role & Mindset Moving from client-requested "chatbots" (proposed solutions) to true enterprise business problem discovery and resolution.
πŸ“ Mathematical & Theoretical Depth Step-by-step proofs β€” e.g. the Attention variance scaling factor $\frac{1}{\sqrt{d_k}}$, sinusoidal positional relative offsets, $O(1)$ path length complexity.
πŸ“‘ Paper Deep-Dives Comprehensive breakdowns of seminal research, including "Attention Is All You Need" (Vaswani et al., 2017).
🏭 Production Architecture Design criteria for Grounded, Observable, Secure and Actionable enterprise AI systems.
πŸ’» Hands-on Implementation Production microservices built with Node.js, Express, TypeScript and modern AI SDKs.

πŸ“Š Repository at a Glance

Metric Value
πŸŽ“ Lectures 12
πŸ““ Chapter note files 88
πŸ“„ Consolidated note documents 12
πŸ—‚οΈ Tracked markdown files 260
✍️ Lines of notes & guides 112,000+
πŸ’» TypeScript / JavaScript files 198
🧾 Lines of code 22,600+
🏭 Lectures shipping runnable code 8 (03 · 04 · 05 · 06 · 08 · 10 · 11 · 12)
🧩 Runnable codebases 9
🎞️ Source slide decks & Excalidraw diagrams 12 PDF · 11 SVG

πŸ’‘ Every number above is derived from the repository contents β€” notes are Markdown, code is strict TypeScript or plain JavaScript, and each codebase ships with a chapter-by-chapter implementation guide.


πŸ—ΊοΈ Learning Path

Follow the phases in order β€” each one assumes only the phase before it.

Phase Lectures Colour You leave able to…
1 Β· Foundations 01 Β· 02 🟦 Explain how an LLM actually produces a token, and why rules β†’ ML β†’ Transformers happened
2 · Application Layer 03 · 04 🟩 Call a model from a real service, budget tokens, and fix statelessness, memory and streaming
3 · Agency & Streaming 05 · 06 🟨 Give a model tools, sandbox it, add human-in-the-loop, and stream tokens to a browser correctly
4 · Embeddings & Retrieval 07 · 08 · 09 · 10 🟧 Represent meaning as vectors, then store and search billions of them with ANN indexes
5 Β· RAG & Advanced RAG 11 Β· 12 πŸŸ₯ Build a grounded answering system end to end β€” then prove which control fixes a wrong answer

πŸ“š Curriculum Navigation

Legend β€” πŸ“‚ Notes index (chapter-by-chapter) Β· πŸ“„ Complete document (single consolidated file) Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide (full source, block-by-block)

# Lecture πŸ“‚ Notes πŸ“„ Complete πŸ’» Codebase πŸ› οΈ Guide
01 🟦 Introduction to FDE & Generative AI Foundations πŸ“‚ πŸ“„ βž– βž–
02 🟦 How LLMs Work (From Tokens to Transformers) πŸ“‚ πŸ“„ βž– βž–
03 🟩 Talking to an LLM from Your Application πŸ“‚ πŸ“„ πŸ’» πŸ› οΈ
04 🟩 Building a Chatbot: Context, Memory, Streaming & Hallucinations πŸ“‚ πŸ“„ πŸ’» πŸ› οΈ
05 🟨 Autonomous AI Agents, Tool Calling & Human-in-the-Loop πŸ“‚ πŸ“„ πŸ’» πŸ› οΈ
06 🟨 AI Streaming β€” From LLM Tokens to a Live Chat Experience πŸ“‚ πŸ“„ πŸ’» πŸ› οΈ
07 🟧 Vector Embeddings β€” From First Principles πŸ“‚ πŸ“„ βž– βž–
08 🟧 Vector Embeddings Project β€” Movie Recommendation System πŸ“‚ πŸ“„ πŸ’» πŸ› οΈ
09 🟧 Vector Embedding Search & Storage πŸ“‚ πŸ“„ βž– βž–
10 🟧 Deep Dive into Vector Databases & ANN Algorithms πŸ“‚ πŸ“„ πŸ’» πŸ› οΈ
11 πŸŸ₯ Retrieval-Augmented Generation (RAG) πŸ“‚ πŸ“„ πŸ’» Productions RAG
πŸ§ͺ Eassy RAG
πŸ› οΈ Productions RAG (00 β†’ 14)
πŸ› οΈ Eassy RAG (01 β†’ 08)
12 πŸŸ₯ Advanced RAG β€” Chunking, Hybrid Retrieval, Reranking & Context Engineering πŸ“‚ πŸ“„ πŸ’» Advanced RAG πŸ› οΈ (00 β†’ 10)

🧭 Want the full chapter-level roadmap with per-chapter topic tables? Open the Main Repository Index & Curriculum Roadmap.


πŸ“– Lecture Highlights

Each lecture below is summarised twice: a one-line thesis and a topic chip list for scanning, plus a collapsible full breakdown with the complete subject coverage. Colour squares match the Learning Path phases.


Thesis β€” The job is not to build the chatbot the client asked for; it is to find the business problem underneath it, and the history of AI explains why the current tools look the way they do.

E-commerce case study (50k daily queries) Β· Problem vs Solution discovery Β· Symbolic AI Β· Expert Systems Β· ML paradigm shift Β· Statistical N-grams Β· RNN hidden-state decay Β· Transformer attention Β· Production AI stack

πŸ”Ž Full breakdown

E-commerce case study (50k daily queries), Problem vs Solution discovery, Symbolic AI & Expert Systems, Machine Learning paradigm shifts, Statistical N-grams, RNN hidden state decay, Transformer Attention mechanism, and Enterprise Production AI Stack topology.

πŸ“‚ Notes index Β· πŸ“„ Complete document


Thesis β€” An LLM is a next-token probability machine: text β†’ tokens β†’ vectors β†’ attention β†’ logits β†’ softmax β†’ one token, appended and repeated.

Autoregressive next-token prediction Β· Subword tokenization (BPE/WordPiece) Β· Dense embeddings ℝ^d_model Β· Positional encodings Β· Scaled dot-product attention (Q, K, V) Β· Multi-block state propagation Β· Logits head Β· Softmax Β· Temperature Β· Streaming

πŸ”Ž Full breakdown

Autoregressive next-token prediction, Subword tokenization (BPE/WordPiece), Dense Vector Embeddings $\mathbb{R}^{d_{\text{model}}}$, Positional Encodings, Scaled Dot-Product Self-Attention ($Q, K, V$), Transformer multi-block state propagation, Logits projection head, Softmax, Temperature scaling, and autoregressive streaming.

πŸ“‚ Notes index Β· πŸ“„ Complete document


Thesis β€” A raw model is an engine, not a car: your application supplies the keys, the dashboard, the fuel budget and the guardrails.

ChatGPT vs raw LLM Β· Deterministic tools Β· Knowledge cutoff Β· 4 invariant request components Β· Prefill vs decode economics Β· Node.js + Express + TypeScript Β· Zod validation Β· Client singletons Β· Telemetry audit Β· Prompt-injection defense

πŸ”Ž Full breakdown

ChatGPT vs Raw LLM (Car vs Engine analogy), Deterministic tools (Calculator, DB, Weather), Knowledge cutoff limits, The 4 Invariant Request Components (Where, Who, Which Model, What), Token economics (Prefill vs Decode, cost & latency), Node.js + Express + TypeScript microservice setup, Zod validation, OpenAI client singletons, response telemetry audit, and prompt injection defense via multi-role architecture.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide


Thesis β€” There is no conversation in the model β€” only the array your server sends. Memory, streaming and hallucination are therefore application design problems, not model properties.

HTTP statelessness Β· Coreference binding Β· system / user / assistant roles Β· 4 pillars of system prompts Β· Context-window budget Β· O(NΒ²) token bloat Β· Lost-in-the-middle Β· Sliding window & rolling summaries Β· Parametric vs in-context knowledge Β· SSE streaming Β· Fluency β‰  truth Β· Sycophancy Β· 7-layer defense in depth

πŸ”Ž Full breakdown

Statelessness of HTTP LLM endpoints, the illusion of conversational continuity, coreference and pronoun binding failure, message roles (system, user, assistant), prompt contamination anti-patterns, the 4 Pillars of system prompts, context window budget constraints, quadratic token accumulation problem ($O(N^2)$ bloat), lost-in-the-middle phenomenon, sliding window and rolling summarization in TypeScript, Parametric Knowledge ($\Theta$) vs In-Context Working Memory ($X_{\text{prompt}}$), autoregressive token streaming via Server-Sent Events (SSE), fluency vs truth orthogonality, coherent fabrication vs benign nonsense, model sycophancy (Aditya Tandon sorting law experiment), and the 7-layer defense-in-depth architecture.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide


Thesis β€” Agency is a spectrum, and every step up it costs context budget, latency and blast radius β€” so sandbox the workspace and keep a human on the irreversible actions.

Tool delegation Β· 5-step tool-calling wire protocol Β· JSON Schema + Zod validation Β· ReAct loop (Thought βž” Action βž” Observation) Β· O(NΒ²) context economics Β· Agency spectrum Β· safePath sandboxing Β· BrewLab case study Β· 3-tier HITL Β· Durable pause/resume webhooks

πŸ”Ž Full breakdown

From token prediction to deterministic tool delegation (Safe Calculator, Weather, Currency Exchange), the 5-step tool calling wire protocol, JSON Schema parameter validation via Zod, multi-step ReAct closed loop (Thought βž” Action βž” Observation), $O(N^2)$ quadratic context economics, agency spectrum (Fixed Code βž” Dynamic Router βž” Plan & Execute βž” Autonomous ReAct), workspace filesystem sandboxing (safePath jail, symlink containment), autonomous website builder case study (BrewLab coffee landing page), and 3-tier Human-in-the-Loop (HITL) authorization with durable pause/resume webhooks.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide


Thesis β€” Generation and delivery are two independent processes. Streaming is what you build in the gap between them, and TTFT β€” not total latency β€” is the number users feel.

Prefill vs decode Β· TTFT vs total latency Β· 4-layer granularity model Β· UTF-8 multi-byte splits Β· Chunked transfer encoding Β· SSE wire grammar Β· 7 pipeline invariants Β· .call() β†’ .stream() Β· Dual-write pattern Β· status: "interrupted" Β· ReadableStream + TextDecoder Β· AbortController Β· Three watchdogs Β· Backpressure Β· p95(clientTTFT βˆ’ serverTTFT) alert

πŸ”Ž Full breakdown

Autoregressive token generation and the prefill-vs-decode latency duality, generation vs. delivery as two independent processes, TTFT vs. total latency and human reading speed as the throughput threshold, the four-layer granularity model (LLM token β‰  provider chunk β‰  network chunk β‰  decoded piece) with UTF-8 multi-byte split discipline, chunked transfer encoding and the exact SSE wire grammar (data/event/id/retry, \n\n framing, heartbeats), the 7 pipeline invariants, the .call() β†’ .stream() return-type change (String β†’ Flux<String>/AsyncIterable), the dual-write pattern (stream out, buffer in) with one reconstructed assistant message per turn and status: "interrupted" for partial answers, the browser half (fetch resolves on headers, ReadableStream.getReader(), one TextDecoder({stream:true}), one growing bubble, sticky auto-scroll, AbortController), and production hardening: three watchdogs, backpressure that stalls instead of overflowing, cancellation propagation to the provider, in-band error protocols after 200 OK, and the p95(clientTTFT βˆ’ serverTTFT) alert that detects buffering regressions. Companion codebase ships a three-transport streaming microservice (raw text/plain, NDJSON, SSE) plus a browser client with a telemetry HUD, chaos injection and an executable await response.text() anti-pattern demo.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide


Thesis β€” Computers cannot do mathematics on symbols, so meaning has to become geometry β€” and learned embeddings beat hand-crafted features because context, not a human, chose the axes.

Symbol vs meaning Β· Feature vectors Β· Euclidean vs dot vs cosine Β· Feature-engineering failure Β· Learned representations Β· Embedding lookup table Β· Gradient descent Β· king βˆ’ man + woman β‰ˆ queen Β· Feature vector β‰  embedding Β· CLIP multi-modal spaces Β· Embedding application taxonomy

πŸ”Ž Full breakdown

The symbol-vs-meaning gap, why computers need numbers to perform mathematics, one-number representations and their failure, multi-dimensional feature vectors and vector spaces, Euclidean distance vs. dot product vs. cosine similarity, the failure of hand-crafted feature engineering (dimensionality explosion, task specificity, language ambiguity), learned representations through context prediction, the embedding lookup table and gradient-descent training loop, vector arithmetic (king βˆ’ man + woman β‰ˆ queen), the critical distinction between a feature vector and a learned embedding, multi-modal shared spaces (CLIP), and the application taxonomy unlocked by embeddings: semantic search, nearest-neighbour retrieval, clustering, classification, ranking, recommendation, and RAG.

πŸ“‚ Notes index Β· πŸ“„ Complete document


Thesis β€” REPRESENT β†’ STORE β†’ COMPARE β†’ RANK: embed stable content once, embed the changing query per request, and rank with cosine similarity.

REPRESENT β†’ STORE β†’ COMPARE β†’ RANK Β· Why not prompt the whole catalog Β· Precomputation insight Β· Offline/online architecture Β· Semantic search vs similar-item Β· Content-based vs collaborative Β· Cosine from first principles Β· Zero-vector guards Β· O(N Γ— D) scoring Β· Optional LLM explanation layer

πŸ”Ž Full breakdown

A complete, working movie recommendation engine built on REPRESENT β†’ STORE β†’ COMPARE β†’ RANK. Covers why not to prompt an LLM with the entire catalog (context limits, repeated work, unnecessary generation, cost/latency), the precomputation insight (stable movie descriptions embedded once; changing user queries embedded per request), the two-phase offline/online architecture, semantic search vs. similar-movie recommendation sharing one ranking engine, content-based vs. collaborative filtering, cosine similarity from first principles ((A Β· B) / (β€–Aβ€– Γ— β€–Bβ€–)), zero-vector and dimension guards, O(N Γ— D) scoring, and the full system design with an optional LLM explanation layer that leads into RAG. Companion codebase ships an Express + TypeScript API with Zod validation, batch startup embeddings, OpenAI live mode plus deterministic mock mode, an 18-movie catalog, and a chapter-wise implementation guide (00 β†’ 08) with block-by-block explanations.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide


Thesis β€” At scale, "store the vectors" and "search the vectors" are two different engineering problems β€” and brute-force KNN is the baseline you must beat on purpose, not by accident.

Store vs search Β· Vector DB anatomy Β· Pre- vs post-filtering Β· Hybrid search + RRF Β· Brute-force KNN baseline Β· 15.36B dimension ops @ 10MΓ—1536 Β· 6 KB/vector Β· 600 GB/100M Β· k-d tree branch-and-bound Β· Curse of dimensionality Β· IVF Β· HNSW Β· PQ Β· LSH Β· DiskANN Β· Two-stage rescoring Β· Capacity planning & CDC Β· Zero-downtime re-embedding Β· recall@K / MRR / nDCG Β· ACL security

πŸ”Ž Full breakdown

Why the 30-movie recommender from Lecture 08 cannot survive scale, and what replaces it. Covers the two separate engineering problems β€” storing hundreds of millions of vectors and searching them efficiently β€” the myth that relational databases cannot store vectors (they can; they simply cannot index similarity with a B-tree), the anatomy of a vector database (ID + vector + payload, fixed dimensions and metrics, write/read pipelines, pre- vs post-filtering, hybrid search with RRF), and brute-force KNN as the correct baseline: O(N Γ— D) per query, 10M Γ— 1536 = 15.36 billion dimension operations, 1536 float32 β‰ˆ 6 KB per vector, 6 GB per million, 600 GB per 100 million. Then the indexing story: why sorted scalar indexes work, why a k-d tree partitions space one axis at a time, the exact branch-and-bound pruning rule (planeDist < bestDist), and why pruning collapses as dimensions grow β€” boundary proliferation, volume concentration, and distance concentration. Finally, ANN indexes in practice: IVF (nlist/nprobe), HNSW (M/efConstruction/efSearch), product quantization (32Γ— compression, ADC), scalar/binary quantization, LSH bands and rows, DiskANN, two-stage retrieval with exact rescoring, and production design: capacity planning, CDC ingestion, deletes and orphan chunks, zero-downtime model re-embedding with alias swaps, sharding and tail latency, multi-tenancy, recall@K / MRR / nDCG evaluation, caching, ACL security, vendor selection, runbooks, and a production checklist.

πŸ“‚ Notes index Β· πŸ“„ Complete document


Thesis β€” The lecture that turns the retrieval half of RAG into working code: implement IVF, HNSW and PQ yourself, then put Qdrant or pgvector behind the same interface.

Irreversible model/dimension choices Β· Cosine vs dot vs L2/L1 Β· Exact KNN as ground truth Β· Speed–recall contract Β· IVF (nlist/nprobe) Β· HNSW (M/efConstruction/efSearch) Β· Product quantization + ADC Β· 5-layer vector DB anatomy Β· Qdrant vs pgvector Β· Chunking Β· hybrid + RRF Β· reranking Β· Latency budgets Β· Failure runbook

πŸ”Ž Full breakdown

The lecture that turns the retrieval half of RAG into working code. Notes cover embeddings and irreversible model/dimension choices, cosine vs dot vs L2/L1 and metric consistency, exact KNN as the ground truth (O(N Γ— D), 15.36 billion dimension operations at 10M Γ— 1536), the speed–recall contract, IVF (nlist/nprobe, k-means, boundary vectors), HNSW (level sampling, greedy descent, efConstruction/efSearch, neighbour diversity, tombstones, filter weakness), product quantization (codebooks, ADC, rescoring, 64Γ— compression), the five-layer anatomy of a vector database, the Qdrant vs pgvector decision, and production retrieval: chunking, hybrid search + RRF, reranking, evaluation, latency budgets, security and a failure runbook. The companion codebase implements every algorithm from scratch in strict TypeScript β€” IVF, HNSW and PQ included β€” plus a CRUD vector store with payload filters, BM25/RRF hybrid search, official Qdrant and pgvector adapters tested against Docker, and a chapter-wise implementation guide (00 β†’ 10) with the full source and block-by-block explanations. No RAG generation: the LLM answer layer belongs to Lecture 11.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide


Thesis β€” Hallucination is a mechanism, not a bug: the model is a stateless next-token predictor, so grounding means putting verified evidence in the prompt and refusing when it is missing.

Parametric vs non-parametric memory Β· Two pipelines / seven serving steps Β· Extraction & chunking hazards Β· Orphan chunks Β· Embedding-space contract Β· Namespaces & score calibration Β· Hybrid search + RRF Β· MMR Β· reranking Β· Four-clause prompt contract Β· Exact refusal sentence Β· Verified [n] citations Β· Prompt injection as authority Β· Query condensation Β· Sessions & IDOR Β· recall@K Β· MRR Β· nDCG Β· SLOs Β· degradation Β· blue/green re-index

πŸ”Ž Full breakdown

The generation half of RAG, built end to end. Notes start from the stateless model β€” parametric vs non-parametric memory, why hallucination is a mechanism rather than a bug, and why a larger context window is capacity rather than attention β€” then build the open-book architecture: two pipelines, seven serving steps, and the failure modes that survive a correct design. Ingestion covers extraction hazards, cleaning, chunking strategies and overlap arithmetic, metadata and deterministic ids, and the orphan-chunk problem. Retrieval covers the embedding-space contract, dimensions and prefixes, namespaces, score calibration, top-K, metadata filters, hybrid search with RRF, MMR and reranking. Grounding covers the four-clause prompt contract, the exact refusal sentence the script uses, citation markers, fabrication guards, and prompt injection as an authority and capability problem. Conversation state covers query condensation ("And for shoes?"), memory strategies and their quadratic cost, session ownership and IDOR, and history poisoning. Evaluation separates retrieval from generation with recall@K, MRR and nDCG, citation validity, refusal correctness, a debug tree and a per-request trace; production design adds SLOs, degradation paths, caching keyed by corpusVersion, blue/green re-indexing, a failure runbook and build-vs-buy. The companion codebase is a working, framework-free system in strict TypeScript β€” structure-aware token chunking, OpenAI plus deterministic offline embeddings, an in-memory store and a Pinecone adapter behind one interface, hybrid retrieval with a calibrated score floor, a grounded prompt with verified [n] citations, TTL-bounded sessions with query rewriting, a 12-case golden set (recall@4 1.00, citations 12/12, refusals 12/12, expected facts 12/12 offline), and an Express API that returns the full trace with every answer β€” plus a chapter-wise implementation guide (00 β†’ 14) with the full source and block-by-block explanations.

🧩 Two codebases ship with this lecture β€” they answer different questions:

Codebase Language & size The question it answers What's inside
🏭 Productions RAG TypeScript Β· 30 files Β· guide 00 β†’ 14 How do you build the real thing? Every stage behind an interface, hybrid retrieval, citation verification, sessions, evaluation and an HTTP API.
πŸ§ͺ Eassy RAG Plain JavaScript Β· 6 modules Β· 477 lines Β· guide 01 β†’ 08 What is the smallest honest pipeline? pdf-parse β†’ 1,000-character chunks with a 150-character overlap β†’ text-embedding-3-small truncated to 1,024 dimensions β†’ one Qdrant point per chunk with a deterministic UUID id β†’ top-5 cosine retrieval β†’ a six-clause grounded prompt returning [Source n] citations and the exact chunks used, or a refusal when retrieval returns nothing.

⚠️ Real failure modes documented in the Eassy RAG guide, not hidden: the pdf-parse@1.1.1 ESM crash (and the createRequire fix), the chunker's 850-character whitespace-free limit (Chunking failed to advance), and the collection dimension guard that stops silent space mismatches.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ› οΈ Productions RAG guide (00 β†’ 14) Β· πŸ› οΈ Eassy RAG guide (01 β†’ 08)


Thesis β€” Basic RAG makes one heroic assumption: the retrieved chunks contain everything needed. This lecture makes that true, then proves the model used the result honestly.

Coverage vs selection failures Β· Retrieval-or-generation decision tree Β· stride = size βˆ’ overlap Β· Structural chunking + breadcrumbs Β· Semantic breakpoints Β· Parent-child (small-to-big) Β· Contextual retrieval + late chunking Β· K_retrieve vs K_context Β· Calibrated score floors + MMR Β· Fail-closed ACL + temporal filters Β· BM25 from first principles Β· RRF Β· Two-stage reranking + two-sided gate Β· Precedence + bookending + token budget Β· Ablation matrix Β· Blue/green re-indexing

πŸ”Ž Full breakdown

The engineering discipline of making basic RAG's one heroic assumption true β€” the retrieved chunks contain everything needed to answer correctly β€” and then proving that the model used the result honestly. Notes start by separating the two failure classes (coverage and selection) and give a four-step tree for deciding whether a wrong answer is a retrieval problem or a generation problem. Chunking covers fixed-size arithmetic (stride = size βˆ’ overlap, storage β‰ˆ S/(Sβˆ’O), the overlap β‰₯ size bug, orphan chunks), then structural chunking with breadcrumbs and the two-pass rule for tables, semantic breakpoints and why they are not the default, parent-child (small-to-big) retrieval, contextual retrieval and late chunking. Retrieval covers K_retrieve as a recall ceiling versus K_context as a token bill, calibrated score floors, MMR, metadata filtering with fail-closed tenant/ACL rules and temporal validity, BM25 from first principles, reciprocal rank fusion and why scores cannot be added across two rankings, and two-stage reranking with a two-sided gate that decides when nothing was relevant. Context engineering covers precedence when documents disagree, lost-in-the-middle bookending, evidence labels, token budgets and prompt injection as an authority problem. Evaluation and production cover recall@K, MRR, nDCG, faithfulness, citation validity, refusal correctness, the ablation matrix, the seven pinned versions, blue/green re-indexing and a failure runbook. The companion codebase is a framework-free system in strict TypeScript β€” fixed/structural/semantic chunkers, an offline hash embedder plus OpenAI behind one interface, an in-memory store with pre- and post-filtering, a filter DSL with ACL and asOf rules, BM25 + RRF, a joint reranker with a calibrated gate, context assembly with parents, dedupe, precedence, budget and bookending, a 14-case golden set and a six-row ablation matrix (recall 0.571 β†’ 0.821, refusal 0.000 β†’ 1.000, context tokens 725 β†’ 566) β€” plus a chapter-wise implementation guide (00 β†’ 10) with the full source and block-by-block explanations. Runs with no API key: every number in the guide is reproducible offline.

🧩 Two codebases ship with this lecture β€” they answer different questions:

Codebase Language & size The question it answers What's inside
🏭 Advanced RAG TypeScript Β· 26 files Β· ~4,200 lines Β· guide 00 β†’ 10 Which control actually fixes a wrong answer? Every stage behind an interface, an ablation matrix that changes one control at a time, calibrated score floors, pre-filtering with fail-closed access rules, and a trace returned with every answer.
πŸ”— The Lecture 11 codebases (Productions RAG Β· Eassy RAG) TypeScript & JavaScript How do you build a grounded answering system at all? Lecture 12 assumes that system exists and asks what to change when it is wrong.

βš–οΈ Honest limits β€” documented rather than hidden: the offline embedder is lexical (hashes, stems and character 4-grams) so it handles morphology but not paraphrase; the reranker is a joint lexical scorer rather than a neural cross-encoder; and the extractive generator quotes sentences without reasoning, which is why facts sits at 0.583 while refusal is 1.000 β€” a retrieval-vs-generation distinction the guide's failure tree names explicitly.

πŸ“‚ Notes index Β· πŸ“„ Complete document Β· πŸ’» Codebase Β· πŸ› οΈ Implementation guide (00 β†’ 10)


🧰 Technology Stack

Layer What the curriculum uses
Languages TypeScript JavaScript SQL
Runtime & server Node.js Express SSE
Validation & typing Zod tsx
Model providers OpenAI Spring AI
Vector stores Qdrant Pinecone pgvector
Infrastructure Docker Mermaid Markdown

πŸš€ Quick Start

1 Β· Reading the notes (no setup required)

1. Open  index.md                      β†’ full chapter-level roadmap
2. Open  Lecture NN/notes/README.md    β†’ chapter index for that lecture
3. Open  Lecture NN/notes/NN_*.md      β†’ one chapter at a time
   ...or Lecture NN/notes/Lecture_NN_Complete_Notes.md for the single-document version

Every note set also ships the original Notes.pdf slides and an Excalidraw-Notes.svg diagram file in the same folder.

2 Β· Running the code

Each codebase is self-contained with its own package.json. Pick a lecture folder and install:

# Lecture 12 β€” Advanced RAG (runs with NO API key)
cd "Lecture 12/code/advanced-rag"
npm install
npm run baseline     # naive pipeline: 8 of 14 golden cases fail, each with a named stage
npm run ablation     # one control at a time: recall 0.571 β†’ 0.821
npm run ask -- "Is the AX-204 still covered after 18 months?"
npm run dev          # HTTP API on :3100
# Lecture 11 β€” Productions RAG (set OPENAI_API_KEY for live embeddings)
cd "Lecture 11/code/Productions RAG"
npm install
npm run ingest && npm run ask && npm run eval
# Lecture 11 β€” Eassy RAG (smallest honest pipeline, needs Qdrant + OpenAI key)
cd "Lecture 11/code/Eassy RAG"
npm install
npm run index        # PDF β†’ chunks β†’ embeddings β†’ Qdrant
npm run query        # question β†’ retrieval β†’ grounded answer with [Source n]

πŸ”‘ Keys are optional where it matters. The Lecture 12 codebase and the Eassy RAG guide are built so their numbers reproduce offline; set OPENAI_API_KEY (and optionally COHERE_API_KEY) to swap in real embeddings and a real cross-encoder without changing a line of logic.

3 Β· Following an implementation guide

Each codebase ships an implementations guide/ folder that walks the same source chapter by chapter: file details β†’ complete source β†’ block-by-block explanation β†’ commands and verification output.


πŸ—‚οΈ Repository Structure

Forward-Deployed-Engineer/
β”œβ”€β”€ README.MD                       # ← you are here
β”œβ”€β”€ index.md                        # Master roadmap: every lecture + per-chapter topic tables
β”œβ”€β”€ prompt.md                       # Note-generation brief used across lectures
β”‚
β”œβ”€β”€ Lecture 01/ … Lecture 12/       # 12 lectures
β”‚   β”œβ”€β”€ notes/
β”‚   β”‚   β”œβ”€β”€ README.md               # Chapter index for the lecture
β”‚   β”‚   β”œβ”€β”€ Notes.pdf               # Original source slides
β”‚   β”‚   β”œβ”€β”€ Excalidraw-Notes.svg    # Hand-drawn diagram source
β”‚   β”‚   β”œβ”€β”€ 01_*.md … NN_*.md       # Chapter-by-chapter notes
β”‚   β”‚   └── Lecture_NN_Complete_Notes.md   # Single consolidated document
β”‚   └── code/                       # Present for lectures 03 Β· 04 Β· 05 Β· 06 Β· 08 Β· 10 Β· 11 Β· 12
β”‚       β”œβ”€β”€ README.md               # What the codebase does + how to run it
β”‚       β”œβ”€β”€ src/ Β· package.json Β· tsconfig.json
β”‚       └── implementations guide/  # Chapter-wise build guide (full source, block by block)
β”‚
└── (Lecture 11 additionally ships two codebases: Productions RAG and Eassy RAG)

πŸ“ Conventions

Every artefact in this repository follows the same four-part contract, so you can jump between lectures without relearning the layout:

# Convention What it means
1 Notes are chapter-wise 6–10 chapter files per lecture, each answering one question, numbered in reading order.
2 A consolidated document always exists Lecture_NN_Complete_Notes.md condenses the chapters and links back to them β€” it is not a blind concatenation.
3 Guides are block-by-block Each implementation guide states the file's details, prints the complete source (never an excerpt), then explains every block and the command that proves it.
4 Claims are measured Retrieval, refusal, citation and latency numbers in the notes come from a runnable golden set, and honest limits are written down rather than hidden.

πŸ—ΊοΈ Roadmap

Status Item
βœ… Lectures 01 β†’ 12 published with chapter-wise notes and consolidated documents
βœ… Codebases + implementation guides for lectures 03 Β· 04 Β· 05 Β· 06 Β· 08 Β· 10 Β· 11 Β· 12
βœ… Master roadmap maintained in index.md
πŸ”œ Additional chapters where the source slides are thinner than the engineering reality
πŸ”œ More evaluation golden sets so every quantitative claim stays reproducible

🟒 The repository is under active development β€” new lecture material lands as the curriculum progresses.


🀝 Contributing

  1. Read the conventions in prompt.md and the Conventions table above.
  2. Keep the four-part contract: chapter-wise notes β†’ consolidated document β†’ runnable code β†’ block-by-block implementation guide.
  3. Update the indexes: if you add a lecture or a codebase, update index.md and this README's Curriculum Navigation table.
  4. Prove your numbers: any metric you quote (recall, refusal, latency, token counts) should be reproducible from a command in the codebase.
  5. Encode links correctly: paths contain spaces, so use %20 (e.g. ./Lecture%2012/code/implementations%20guide/README.md).

Pull requests that improve depth, fix a wrong claim, or add a missing failure mode are especially welcome. πŸŽ‰


πŸ“„ License & Attribution

This repository is an educational curriculum. Lecture content, notes and diagrams are derived from the referenced source materials and papers β€” notably "Attention Is All You Need" (Vaswani et al., 2017) β€” which remain the property of their respective authors. Code samples are provided for learning and reference; verify against your own security, licensing and compliance requirements before production use.


⭐ If this curriculum helps you, star the repository β€” it makes the next lecture easier to find.

πŸ“‘ Master Index Β· πŸ“– Curriculum Navigation Β· πŸš€ Quick Start

Built for Forward Deployed Engineers who measure what they ship.

About

Master curriculum for Forward Deployed Engineering (FDE) & Production Generative AI Systems. Covers enterprise AI architecture, mathematical foundations of Transformers & Attention, RAG systems, and production AI stack design.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages