import { Arrow, FigBox, FILL, LoopFigure, type LoopStop } from "./LoopFigure"; const CX = 300; const STOPS: LoopStop[] = [ { x: CX, y: 448, ids: ["scale"], inspect: "scale", title: "Prompt tokens", note: "A single token stream: instructions, context, and the answer so far. Scale is tokens × parameters × compute.", }, { x: CX, y: 368, ids: ["decoder"], inspect: "decoder", title: "Embedding + positions", note: "Tokens become vectors. Causal masking will keep each position from seeing the future.", }, { x: CX, y: 278, ids: ["decoder"], inspect: "decoder", title: "Masked self-attention", note: "Decoder-only: no encoder. Every layer is causal multi-head attention plus a feed-forward net.", }, { x: CX, y: 198, ids: ["decoder"], inspect: "decoder", title: "Feed-forward × N", note: "Stacked N times. GPT-style models drop the encoder entirely and generate left to right.", }, { x: CX, y: 108, ids: ["decoder"], inspect: "decoder", title: "Linear + softmax", note: "Next-token distribution. The sampled token is appended and the loop continues.", }, { x: 560, y: 108, ids: ["align"], inspect: "align", title: "Post-training", note: "Instruction data and preference methods (RLHF, DPO) turn a next-token model into something you can talk to.", }, { x: 560, y: 448, ids: ["align", "scale"], inspect: "align", title: "Append next token", note: "The predicted token joins the prompt. The decoder runs again.", }, ]; export function LlmLoop({ onSelect }: { onSelect: (id: string) => void }) { return ( {({ on, markerId }) => ( Large Language Model Decoder-only Transformer onSelect("align")} /> Nx onSelect("decoder")} /> onSelect("decoder")} /> onSelect("decoder")} /> onSelect("decoder")} /> onSelect("scale")} /> params × data × compute append token )} ); }