Skip to content
StackDecode
System Design
19. AI System Design and LLM InfrastructureAnimated

Context Management

Choosing what goes into the model's limited window.

The idea

Select, trim, summarise and order the information the model sees.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

System promptChat historyRetrieved docsContext builderLLM (limited wi…
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

The context window is finite and every token costs money and time.

step:
1/4
at:
Context builder
1/8

The green dot is a request moving through the system.

Step by step

  1. 1Gather candidate information
  2. 2Rank by relevance
  3. 3Trim or summarise to fit
  4. 4Place the key items where the model attends

Where it is used

Long conversations and RAG.

Watch out for

Irrelevant context hurts answers and costs money.

Related