ladderlore
Request a guide
  • Type a service name, like S3 or IAM.

  • Retrieve

    Returns
    Chunks, scores and sources
    Pick it when
    You build the prompt and call the model
  • RetrieveAndGenerate

    Returns
    An answer with citations
    Pick it when
    You want grounded answers in one call
The two query APIs.
Question
Lambda pipeline
Knowledge bases
Foundation model with Guardrails
Answer with citations
  1. 1The question arrives.
  2. 2Lambda decomposes or routes it, adds filters and calls Retrieve on one or more knowledge bases.
  3. 3Retrieved chunks, reranked, go into the prompt. Guardrails check the prompt and the answer.
  4. 4The answer returns with citations.
A custom pipeline adds routing and checks around retrieval.

Step by step

  1. 1The question arrives.
  2. 2Lambda decomposes or routes it, adds filters and calls Retrieve on one or more knowledge bases.
  3. 3Retrieved chunks, reranked, go into the prompt. Guardrails check the prompt and the answer.
  4. 4The answer returns with citations.

What it is

Two APIs query a knowledge base. Retrieve returns chunks with text, source and score, and nothing more, so you control the prompt and the model. RetrieveAndGenerate retrieves and then calls a model, and returns an answer with citations. It also supports query decomposition (orchestration configuration with QUERY_DECOMPOSITION), which breaks a complex question into sub-queries, and a guardrail in its generation configuration. Citations need the output format instructions placeholder in a custom prompt template.

What it is

A custom pipeline in AWS Lambda is for needs the managed call cannot meet. It can route a question to one of several knowledge bases by intent, decompose a question, add metadata filters from the user context, merge and rerank results, and then call the model through Converse. Apply Guardrails to the final prompt and the answer with the guardrail settings in Converse or with the ApplyGuardrail API, so retrieved text cannot slip past your rules. A guardrail on a knowledge base node in Bedrock Flows only applies when it uses RetrieveAndGenerate.

What it is

Choose the simplest path that works. RetrieveAndGenerate for a quick, grounded answer. Retrieve plus your own model call when you need control over the prompt, the model or the output. A custom pipeline when routing, several stores or extra steps are part of the requirement.

Remember

  • Retrieve: chunks and scores only. RetrieveAndGenerate: an answer with citations.
  • Query decomposition splits a complex question into sub-queries.
  • Metadata filters narrow retrieval to the right documents.
  • Custom pipeline in Lambda: routing across knowledge bases, merge, rerank, then generate.

Remember

  • Guardrails: in generation configuration, or ApplyGuardrail for a custom pipeline.

On the exam

  • “Need the source passages and then use your own prompt and model” points to Retrieve.
  • “A grounded answer with citations in one call” points to RetrieveAndGenerate.
  • “Multi-part questions retrieve poorly” points to query decomposition.
  • “Route each question to the right knowledge base by topic” points to a custom pipeline, for example in Lambda.