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

Concept

Reranking and retrieval strategies

Tune how many chunks come back, how they are searched and how they are reordered.

Question
Semantic or hybrid search
Reranker model
Foundation model
  1. 1The question goes to the knowledge base.
  2. 2Search returns the top-k chunks. Filters apply here.
  3. 3A reranker reorders them and a few best go into the prompt.
Retrieve wide, rerank, then send a few chunks to the model.

Step by step

  1. 1The question goes to the knowledge base.
  2. 2Search returns the top-k chunks. Filters apply here.
  3. 3A reranker reorders them and a few best go into the prompt.

Retrieve wide, rerank, then send a few chunks to the model.

  • Search type

    What it does
    Semantic or hybrid
    Trade-off
    Hybrid needs a supported store
  • Top-k

    What it does
    Most chunks returned
    Trade-off
    More recall, more tokens
  • Metadata filter

    What it does
    Limits search by attributes
    Trade-off
    Needs metadata files
  • Score cut-off

    What it does
    Your code drops low scores
    Trade-off
    Too high loses answers
  • Reranker

    What it does
    Reorders by relevance
    Trade-off
    Extra cost and delay
Five retrieval settings and what each costs.

1 / 2

  • Search type

    What it does
    Semantic or hybrid
    Trade-off
    Hybrid needs a supported store
  • Top-k

    What it does
    Most chunks returned
    Trade-off
    More recall, more tokens
  • Metadata filter

    What it does
    Limits search by attributes
    Trade-off
    Needs metadata files

2 / 2

  • Score cut-off

    What it does
    Your code drops low scores
    Trade-off
    Too high loses answers
  • Reranker

    What it does
    Reorders by relevance
    Trade-off
    Extra cost and delay
Five retrieval settings and what each costs.

What it is

Retrieval has a few settings. Search type: semantic search matches meaning through embeddings. Hybrid search adds a keyword match on the raw text, which helps with product codes and names. Hybrid works only on some vector stores (Amazon RDS, OpenSearch Serverless and MongoDB) that have a filterable text field. Otherwise Bedrock uses semantic search. The number of results (top-k) sets the most chunks returned. The default is 5. With hierarchical chunking the count is of child chunks, so you may get fewer.

What it is

A metadata filter limits search to chunks whose attributes match, such as year or product, with operators like equals, in and greaterThan, combined with andAll and orAll. It needs metadata files in the data source. Each result also carries a score, so your code can drop weak chunks before the prompt is built.

What it is

A reranker model scores each retrieved chunk against the question and reorders them. It works on text only. Retrieve a wider set, rerank, and keep a few. The foundation model then reads fewer, better chunks, which can lower its cost and latency. The reranker itself adds a model call, so it adds cost and some delay. Use it through the Rerank API, or turn it on in Retrieve and RetrieveAndGenerate.

Remember

  • Semantic: meaning. Hybrid: meaning plus keywords, only on some vector stores.
  • Top-k sets the most results returned. Default 5.
  • Metadata filters need metadata files and narrow search before ranking.
  • A reranker reorders retrieved chunks by relevance. Text only.
  • Reranking adds cost and latency, but can shrink the prompt.

On the exam

  • “Exact product codes are missed by semantic search” points to hybrid search.
  • “Only search documents from the current year” points to a metadata filter.
  • “Top results are close but the best chunk is not first” points to a reranker model.
  • “Fewer tokens sent to the model without losing the best chunks” points to retrieving more and reranking down.