# RAG pipeline diagram

> A one-page 1920 × 1080 diagram of a retrieval augmented generation pipeline for a policy assistant that answers from 2,300 internal documents. Each step is one card component with its title, description and failure note as text to overwrite, and the index is five drawers whose names and counts can each be changed.

- The design, as a .vd file: https://getv.design/library/rag-pipeline-diagram.vd
- Its page: https://getv.design/library/rag-pipeline-diagram

## How it was made

Drafted from this prompt:

> A pipeline diagram for Larchmont Engineering's policy assistant: documents are cut into passages and stored, a question retrieves the five best passages, the answer is written from them, and sources are shown. Mark where it can go wrong.

Then refined:

- Added an access check step before retrieval.
- Made the filing cabinet larger and pulled one drawer open to show where the passages came from.
- Removed the footer line, which added nothing and crowded the bottom edge.

## Make it yours

- "Make a RAG architecture diagram for our own documents."
- "Add a step that checks the answer before it is shown."
- "Change the five drawers to our own collections and counts."

## The source

```vd
version 12
kind design
title "RAG pipeline diagram"
$navy = #0C1B33
$paper = #F4F7FB
$blue = #2F6BFF
$amber = #FFB020
$lane = #E4EBF7
$mist = #B9C7E2
$deep = #16305A
$m = 100
$c0 = 145
$cw = 270
$ch = 202
$step = 340

font head = Orbitron
  fallback "system-ui, sans-serif"
  face asset=orbitron-500 weight=500
  face asset=orbitron-700 weight=700

font body = Scada
  fallback "system-ui, sans-serif"
  face asset=scada-400 weight=400
  face asset=scada-700 weight=700

asset orbitron-500 = font/woff2 hash=sha256-c13360768270c65d6c97701b100a88993885671dfdfd2a400aa58ea0195381ea bytes=6596 license=OFL
asset orbitron-700 = font/woff2 hash=sha256-ee6acc5ad5349018f9ca71fab8118144160e110838931874150a1ac3f97db38d bytes=6528 license=OFL
asset scada-400 = font/woff2 hash=sha256-3a2c05357da99bb4dc1acdacbfd4dbe036e2322008eb9d3110fdde99df25b456 bytes=15188 license=OFL
asset scada-700 = font/woff2 hash=sha256-5efd8f2ead6cb379adfc977d300a7905cf1d3fd3ee2a1a264a1bc2250bf69259 bytes=15284 license=OFL

frame page x=0 y=0 w=1920 h=1080 background=paper
  text title x=$m y=40 w=1500 h=60 font=head size=44 weight=700 letterSpacing=-1 fill=navy
    "From 2,300 documents to a cited answer"
  text sub x=$m y=112 w=1200 h=58 font=body size=21 lineHeight=1.3 fill=deep
    "Larchmont Engineering's policy assistant runs in two lanes: one when documents are added, one when someone asks. Each amber slip says where a step can go wrong."

  rect lane.add x=0 y=190 w=(100%) h=264 fill=lane
  text lane.add.t x=$c0 y=(@lane.add.y + 12) w=700 h=30 font=head size=20 weight=700 fill=navy
    "When documents are added"
  instance add.1 component=card x=$c0 y=(@lane.add.y + 52)
    override card.n
      "1"
    override card.t
      "Ingest"
    override card.d
      "Policies and standards are copied from 14 shared drives"
    override card.w
      "Old copies come along too, so withdrawn rules get quoted."
  instance add.2 component=card x=(@add.1.x + $step) y=@add.1.y
    override card.n
      "2"
    override card.t
      "Split"
    override card.d
      "Each document is cut into passages of about 300 words"
    override card.w
      "A cut in the wrong place parts a rule from its exception."
  instance add.3 component=card x=(@add.2.x + $step) y=@add.1.y
    override card.n
      "3"
    override card.t
      "Index"
    override card.d
      "Each passage is turned into numbers for its meaning and filed"
    override card.w
      "An edited document is not re-filed, so the index goes stale."
  connector add.a1 x1=@add.1.right y1=(@add.1.y + 62) x2=@add.2.left y2=(@add.2.y + 62) stroke=blue strokeWidth=3 end=arrow
  connector add.a2 x1=@add.2.right y1=(@add.2.y + 62) x2=@add.3.left y2=(@add.3.y + 62) stroke=blue strokeWidth=3 end=arrow

  text stat.n x=(@add.3.right + 110) y=(@add.1.y - 6) w=560 h=80 font=head size=64 weight=700 letterSpacing=-2 fill=blue
    "61,400"
  text stat.d x=@stat.n.x y=(@stat.n.bottom + 4) w=560 h=60 font=body size=22 lineHeight=1.3 fill=navy
    "passages in the index, about 27 from each of the 2,300 documents"
  rect key.slip x=@stat.n.x y=(@stat.d.bottom + 26) w=56 h=28 fill=amber
  text key.t x=(@key.slip.right + 16) y=(@key.slip.y + 1) w=480 h=28 font=body size=19 fill=navy
    "Amber slip: where a step can go wrong"

  group cabinet
    rect cab.body x=600 y=(@lane.add.bottom + 32) w=720 h=252 fill=navy radius=6
    rect cab.d1 x=608 y=(@cab.body.y + 8) w=704 h=44 fill=deep radius=3
    rect cab.d2 x=608 y=(@cab.d1.bottom + 4) w=704 h=44 fill=deep radius=3
    rect cab.d3 x=(608 + 56) y=(@cab.d2.bottom + 4) w=704 h=44 fill=blue radius=3
    rect cab.d4 x=608 y=(@cab.d3.bottom + 4) w=704 h=44 fill=deep radius=3
    rect cab.d5 x=608 y=(@cab.d4.bottom + 4) w=704 h=44 fill=deep radius=3
    rect cab.h1 x=(@cab.d1.cx - 36) y=(@cab.d1.cy - 4) w=72 h=8 fill=mist radius=4
    rect cab.h2 x=(@cab.d2.cx - 36) y=(@cab.d2.cy - 4) w=72 h=8 fill=mist radius=4
    rect cab.h3 x=(@cab.d3.cx - 36) y=(@cab.d3.cy - 4) w=72 h=8 fill=paper radius=4
    rect cab.h4 x=(@cab.d4.cx - 36) y=(@cab.d4.cy - 4) w=72 h=8 fill=mist radius=4
    rect cab.h5 x=(@cab.d5.cx - 36) y=(@cab.d5.cy - 4) w=72 h=8 fill=mist radius=4
  text cab.n1 x=(@cab.d1.x + 20) y=@cab.d1.y w=300 h=@cab.d1.h font=body size=20 valign=middle fill=paper
    "HR and leave"
  text cab.c1 x=(@cab.d1.right - 200) y=@cab.d1.y w=180 h=@cab.d1.h font=body size=20 valign=middle align=right fill=mist
    "412 documents"
  text cab.n2 x=(@cab.d2.x + 20) y=@cab.d2.y w=300 h=@cab.d2.h font=body size=20 valign=middle fill=paper
    "Finance and expenses"
  text cab.c2 x=(@cab.d2.right - 200) y=@cab.d2.y w=180 h=@cab.d2.h font=body size=20 valign=middle align=right fill=mist
    "296 documents"
  text cab.n3 x=(@cab.d3.x + 20) y=@cab.d3.y w=300 h=@cab.d3.h font=body size=20 weight=700 valign=middle fill=paper
    "Engineering standards"
  text cab.c3 x=(@cab.d3.right - 200) y=@cab.d3.y w=180 h=@cab.d3.h font=body size=20 weight=700 valign=middle align=right fill=paper
    "701 documents"
  text cab.n4 x=(@cab.d4.x + 20) y=@cab.d4.y w=300 h=@cab.d4.h font=body size=20 valign=middle fill=paper
    "Health and safety"
  text cab.c4 x=(@cab.d4.right - 200) y=@cab.d4.y w=180 h=@cab.d4.h font=body size=20 valign=middle align=right fill=mist
    "538 documents"
  text cab.n5 x=(@cab.d5.x + 20) y=@cab.d5.y w=300 h=@cab.d5.h font=body size=20 valign=middle fill=paper
    "IT and security"
  text cab.c5 x=(@cab.d5.right - 200) y=@cab.d5.y w=180 h=@cab.d5.h font=body size=20 valign=middle align=right fill=mist
    "353 documents"

  text idx.t x=$c0 y=(@cab.body.y + 12) w=440 h=40 font=head size=30 weight=700 fill=navy
    "The index"
  text idx.d x=$c0 y=(@idx.t.bottom + 10) w=410 h=104 font=body size=21 lineHeight=1.3 fill=deep
    "Both lanes meet here. Passages are filed by meaning in five collections, not by document title."
  text idx.o x=1430 y=(@cab.d3.y - 6) w=390 h=104 font=body size=21 lineHeight=1.3 fill=deep
    "The open drawer is the one that held the passages for a question about weld inspection."

  rect lane.ask x=0 y=(@cab.body.bottom + 34) w=(100%) h=264 fill=lane
  text lane.ask.t x=$c0 y=(@lane.ask.y + 12) w=700 h=30 font=head size=20 weight=700 fill=navy
    "When someone asks"
  instance ask.1 component=card x=$c0 y=(@lane.ask.y + 52)
    override card.n
      "1"
    override card.t
      "Question"
    override card.d
      "A member of staff types a question in plain words"
    override card.w
      "A vague question pulls back vague passages."
  instance ask.2 component=card x=(@ask.1.x + $step) y=@ask.1.y
    override card.n
      "2"
    override card.t
      "Access check"
    override card.d
      "Only documents this person may read are searched"
    override card.w
      "A wrong group setting hides the right policy or shows a private one."
  instance ask.3 component=card x=(@ask.2.x + $step) y=@ask.1.y
    override card.n
      "3"
    override card.t
      "Retrieve"
    override card.d
      "The five best matching passages are pulled out"
    override card.w
      "The best passage may rank sixth and never be read."
  instance ask.4 component=card x=(@ask.3.x + $step) y=@ask.1.y
    override card.n
      "4"
    override card.t
      "Answer"
    override card.d
      "The model writes a reply from those five passages only"
    override card.w
      "It can state more than the passages say."
  instance ask.5 component=card x=(@ask.4.x + $step) y=@ask.1.y
    override card.n
      "5"
    override card.t
      "Cite"
    override card.d
      "The reply names each document, section and date"
    override card.w
      "A source from an old version looks as sound as a new one."
  connector ask.a1 x1=@ask.1.right y1=(@ask.1.y + 62) x2=@ask.2.left y2=(@ask.2.y + 62) stroke=blue strokeWidth=3 end=arrow
  connector ask.a2 x1=@ask.2.right y1=(@ask.2.y + 62) x2=@ask.3.left y2=(@ask.3.y + 62) stroke=blue strokeWidth=3 end=arrow
  connector ask.a3 x1=@ask.3.right y1=(@ask.3.y + 62) x2=@ask.4.left y2=(@ask.4.y + 62) stroke=blue strokeWidth=3 end=arrow
  connector ask.a4 x1=@ask.4.right y1=(@ask.4.y + 62) x2=@ask.5.left y2=(@ask.5.y + 62) stroke=blue strokeWidth=3 end=arrow
  connector feed.in x1=@add.3.cx y1=@add.3.bottom x2=@add.3.cx y2=@cab.body.y stroke=blue strokeWidth=3 end=arrow
  connector feed.out x1=@cab.body.cx y1=@cab.body.bottom x2=@ask.3.cx y2=@ask.3.y stroke=blue strokeWidth=3 end=arrow

frame card x=0 y=1200 w=$cw h=$ch component clip radius=4
  rect card.top x=0 y=0 w=(100%) h=124 fill=navy
  text card.n x=18 y=12 w=36 h=36 font=head size=28 weight=700 fill=blue
    "1"
  text card.t x=56 y=16 w=196 h=32 font=head size=22 weight=700 fill=paper
    "Step"
  text card.d x=18 y=60 w=234 h=62 font=body size=17 lineHeight=1.2 fill=mist
    "What the step does"
  rect card.slip x=0 y=124 w=(100%) h=78 fill=amber
  text card.w x=18 y=132 w=234 h=62 font=body size=16 lineHeight=1.25 fill=navy
    "Where it can go wrong"
```
