rag-stack
One question travels down a four-layer RAG stack, matching chunks come back up, the LLM drafts an answer and it returns with citations.
Swipe sideways to see the whole figure.
- Verb
- travel
- Archetype
- layers
- Domain
- ai
- viewBox
- 1200 × 640
- Control
- once: plays one pass, then rests on the finished state
- Pass
- 9.8 s
- Tags
- rag, llm, retrieval, vector-search, architecture, ai
- Files
- rag-stack.html (fragment) · rag-stack-demo.html (playable page) · spec.yaml · thumb.png
- Source
- pool/rag-stack/
Paste the fragment into any HTML deck; it plays while an ancestor has the
class visible (one pass for once, then it holds the finished state) and
otherwise shows its resting frame. Rename the prefix
(rag-stack) when you adapt it so it stays unique in your deck.
spec.yaml
# Layers of a retrieval-augmented generation (RAG) app: one question goes down the stack,
# relevant chunks come back up, and the LLM answers with citations. Scaffold with:
# python3 scripts/scaffold_from_spec.py pool/rag-stack/spec.yaml -o pool/rag-stack/rag-stack.html --rendered-width 1200
# The shipped rag-stack.html is hand-built on top of the scaffold: one aligned chip column with
# offset down/up wires, a chat transcript, retrieval scores and source documents with citation
# badges, and packet hops timed so the holder of the packet is the one active chip.
name: rag-stack
archetype: layers
verb: travel
traveller: { name: the user's question }
size: [1200, 640]
control: once
cycle: 9.8
nodes:
- { id: chat, label: Chat UI, sub: "question in, answer out", layer: 3, group: ui }
- { id: orch, label: Orchestrator, sub: "retrieve, then prompt", layer: 2, group: app }
- { id: llm, label: LLM, sub: "writes the answer", layer: 2, group: app }
- { id: index, label: Vector index, sub: "similarity search", layer: 1, group: retrieval, kind: store }
- { id: docs, label: Documents, sub: "split into chunks", layer: 0, group: data, kind: data }
edges:
- { from: chat, to: orch }
- { from: orch, to: index }
- { from: index, to: docs }
- { from: docs, to: index }
- { from: index, to: orch }
- { from: orch, to: llm }
- { from: llm, to: orch }
- { from: orch, to: chat }
groups:
- { id: ui, label: Interface }
- { id: app, label: Orchestration }
- { id: retrieval, label: Retrieval }
- { id: data, label: Data sources }
phases:
- { t: 0, label: build, note: "A RAG app in four layers" }
- { t: 1.1, label: ask, active: [chat], flow: ["chat>orch"], note: "A user asks a question" }
- { t: 2.1, label: search, active: [orch], flow: ["orch>index"], note: "The question is embedded and searched" }
- { t: 3, label: lookup, active: [index], flow: ["index>docs"], note: "Nearest chunks point at their sources" }
- { t: 4, label: chunks, active: [docs], flow: ["docs>index"], note: "The relevant chunks come back up" }
- { t: 5, label: top-k, active: [index], flow: ["index>orch"], note: "Top-k chunks reach the orchestrator" }
- { t: 5.9, label: prompt, active: [orch], flow: ["orch>llm"], note: "Question plus chunks go to the LLM" }
- { t: 6.9, label: generate, active: [llm], flow: ["llm>orch"], note: "The LLM drafts a grounded answer" }
- { t: 7.8, label: answer, active: [chat], flow: ["orch>chat"], note: "Answer with citations returns to the UI" }
- { t: 8.8, label: hold, active: [chat] }