Skip to content
StackDecode
LLM Library
Running and Using LLMsAnimated

Retrieval-Augmented Generation

Give the model relevant documents before it answers.

The idea

The system searches a knowledge base using embeddings, puts the best passages into the prompt, and the model answers using them. This adds fresh and private knowledge without retraining.

Watch it work

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

User questionEmbedderVector DBRerankerLLM
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Turn the question into an embedding vector.

step:
1/4
at:
User question
1/9

The green dot is a request moving through the system.

Step by step

  1. 1Split documents into chunks and embed them
  2. 2Embed the question
  3. 3Retrieve the closest chunks
  4. 4Add them to the prompt and generate

Where it is used

Chat with your documents, support bots, enterprise search.

Watch out for

Poor retrieval gives poor answers, so test retrieval separately.