Primary reference: how Bedrock Knowledge Bases work
AWS describes the managed knowledge-base flow and vector-store integration points that make embedding, chunking, and retrieval compatibility a deployment concern.
Read how Bedrock Knowledge Bases workTreat embeddings as a compatibility contract
An embedding maps content and queries into vectors. Record model, dimension, normalization policy, index metric, source version, and migration plan together.
Cosine, inner product, and Euclidean distance are not interchangeable defaults. Select the metric and normalization that the embedding and vector-store implementation expect.
Use exact search as the reference for ANN
Exact nearest-neighbour search establishes a reference result set. Approximate search limits work to meet latency or memory constraints, then its recall is measured against that reference on representative queries.
ANN evaluation loop
Loading diagram...
Tune index controls against observed workload
HNSW exposes construction and search effort; IVF exposes partition and probe choices. More candidate work can improve recall but add latency or memory. Test inserts, deletes, filters, rebuilds, and concurrency too.
Measure compression and migrations
- Keep an exact or high-quality reference set.
- Measure Recall@K, latency percentiles, memory or storage, and update behaviour before and after a representation or index-compression change.
- Re-embed and re-index as a versioned rollout; never mix incompatible dimensions in one field.
- Retain source and chunk identifiers for debugging.
Version the embedding compatibility record
An embedding is not just a number array. It is part of a compatibility contract across the document pipeline, query path, vector field, metric, metadata mapping, and evaluation set. A new model, dimension, normalization rule, or chunking profile is a retrieval migration until proven otherwise.
Embedding compatibility record
Application-owned change record; replace placeholders with deployment-specific values after verifying service support.
Click on an annotation to highlight it in the JSON
AWS’s knowledge-base build guidance should be used to confirm the selected vector-store integration and field expectations for the actual configuration. Do not copy a dimension, metric, or model identifier from an unrelated store, Region, or tutorial. Record what was verified and test it with representative documents before the corpus becomes authoritative for a user workflow.
Lab: expose cosine and normalization assumptions
Use a small, fixed query set with relevance judgments and compare exact rankings under the metric and normalization policy you intend to deploy. The point is not to prove a universal winner; it is to catch a mismatch where query vectors, document vectors, and index scoring no longer mean the same thing.
Teaching pseudocode, not an AWS SDK implementation. Preserve the same vectors and query set across both branches.
for query in goldenQueries:
expected = judgedRelevantIds(query)
exactCosine = rankByCosine(normalize(query), normalize(documents))
exactInnerProduct = rankByDotProduct(query, documents)
record(query.id, {
cosineRecallAtK: overlap(expected, exactCosine.topK),
innerProductRecallAtK: overlap(expected, exactInnerProduct.topK),
scoreDistribution: summarizeScores(),
})
reviewRankingChangesBeforeChoosingIndexMetric()Measure both ranking overlap and the decision the product makes from that ranking. For example, a top result may still be unacceptable if it crosses an access boundary or omits a necessary clause. Agentic AI Lens PERF03 recommends optimizing memory, context, and RAG against workload needs; this experiment makes one of those context-quality assumptions inspectable before it reaches an agent loop.
Accept ANN with a recall budget and migration plan
ANN acceptance and migration plan
| Stage | Decision or control | Validation evidence |
|---|---|---|
| Reference | Keep an exact or high-quality baseline for a sampled corpus. | Per-query relevant IDs and baseline rankings are versioned. |
| Candidate ANN | Tune candidate work and filters for the real query and update mix. | Recall@K, latency percentiles, failures, and update behaviour are compared. |
| Dual-read rollout | Write a new representation or index beside the current one. | Result disagreement is sampled and reviewed before traffic changes. |
| Cutover and rollback | Move a versioned alias only after acceptance; retain a rollback path. | Post-cutover checks and rollback criteria are recorded. |
ANN is a deliberate approximation: it can reduce search work, but must be evaluated against an accepted reference on representative queries. Include filtered queries, source updates, deletes, and concurrent access because a strong unfiltered static benchmark can hide the operational retrieval behaviour users experience. Avoid a single global recall target; set a workload-specific budget with the consequence of a miss in mind.
- Create a new compatibility record and index namespace; never overwrite the only known-good representation.
- Backfill from versioned source chunks and verify document counts, metadata mapping, and retrieval samples.
- Compare baseline and candidate results on the same golden set, including no-result and authorization cases.
- Cut over through a reversible alias or application configuration only after the measured trade-off is accepted by the workload owner.
- Monitor disagreement and retrieval regressions after cutover; restore the prior alias if the pre-agreed rollback condition is met.
Make an index rebuild a reversible cutover decision
An index rebuild changes more than query speed. It can change field mappings, metric behavior, filters, candidate selection, freshness, and the ability to explain a result. Write the cutover decision before backfilling so the team knows which evidence is needed to move traffic and exactly when to restore the prior representation.
Dual-read index cutover record
Application-owned deployment record. Values are placeholders; do not infer a store-specific alias or rebuild operation from this teaching artifact.
Click on an annotation to highlight it in the JSON
AWS vector-store setup documentation identifies vector, text, and metadata field requirements for supported integrations. Verify those requirements against the exact store and configuration you operate before backfill. A dual read is valuable because it reveals a result disagreement while the prior index still supplies a recoverable baseline; it is not proof that every result should be identical across two intentionally different representations.
Keep writes and reads explicit during the comparison. A candidate that is not receiving the same source updates as the current index cannot be evaluated fairly, while a shared write path can conceal a mapping failure if it silently drops metadata. Record the corpus watermark and ingestion status for both representations with every dual-read sample. If parity cannot be established, stop the comparison rather than interpreting disagreement as an ANN-quality result.
Detect representation drift with recall slices
Aggregate recall can conceal the query classes that matter most. Slice the experiment by source type, query intent, metadata filter, language or vocabulary pattern where applicable, and change age. The goal is to find a representation drift that breaks a meaningful retrieval decision before it becomes an apparent model-quality issue downstream.
Representation-drift recall experiment
| Slice | Compare | Validation | Failure response |
|---|---|---|---|
| Recent source replacement | Old versus new source locator ranking | Reviewer confirms current version is selected. | Keep prior index active and inspect lineage/chunking. |
| Filtered policy question | Exact versus ANN under the same metadata filter | Authorized relevant evidence remains in top K. | Retune or reject candidate; do not relax access control. |
| Rare vocabulary or identifier | Query/document representation and ranking overlap | Expected locator is discoverable and citable. | Add representative cases before changing representation. |
| No-evidence query | Candidate and baseline result modes | Both produce a bounded no-evidence outcome. | Fix fallback policy before cutover. |
Keep an exact or high-quality reference where practical, then calculate recall on each slice with human-reviewed expected source identifiers. The Agentic AI Lens asks workloads to optimize memory, context, and RAG for their needs; recall slices make “need” concrete without inventing a universal target. Treat an unexplained slice regression as a release blocker when that slice maps to a user decision the workload claims to support.
Investigate the direction of disagreement, not just its count. A candidate that returns more broadly related sources may increase apparent recall while pushing the decisive source below the context budget; a candidate that returns fewer sources may improve precision but leave a comparison question under-evidenced. Capture the reviewer’s decision consequence for each disagreement, then use that evidence to choose whether the representation, ANN controls, chunking, or downstream context policy needs to change.
- Freeze the corpus, embedding version, filter configuration, and judged query set for the comparison window.
- Run exact/reference and candidate ANN retrieval with the same principal and filter conditions.
- Record source-ID overlap, missing expected evidence, extra unexpected evidence, and user-decision consequence per slice.
- Investigate representation, chunking, metadata, and index configuration separately; roll back the candidate if the accepted slice contract is breached.
Glossary: terms first introduced here
These are the technical terms introduced in this step. Later modules build on them rather than redefining them from scratch.
New vocabulary for this step
| Term | Plain-language meaning | Why it matters here |
|---|---|---|
| Embedding | A numeric representation of text or another input that lets a system compare semantic similarity. | Changing the embedding model changes the retrieval representation and requires a compatible, evaluated index. |
| Vector | The ordered numbers produced by an embedding model for comparison in a similarity space. | Vector dimensions, normalization, and distance metric are part of the retrieval contract. |
| ANN (approximate nearest-neighbour search) | A fast search technique that returns likely similar vectors instead of checking every possible vector exactly. | ANN trades some recall for speed, so its settings need a measured quality and latency check. |
| Recall | The share of expected relevant evidence that a retrieval method successfully returns for a labelled query set. | It exposes missed evidence that a fluent final answer can hide. |
Knowledge Check
Test your understanding with this quiz. You need to answer all questions correctly to mark this section as complete.