Study guide

3.1 Hybrid Search, Metadata Filtering & Semantic Reranking

AWS Certified Generative AI Developer - Professional AIP-C01

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Exam Overview & Foundation Model Fundamentals

1.1 AIP-C01 Exam Structure, Logistics & Passing Strategy 1.2 AIP-C01 Scoring & Professional Decision Strategy 1.3 Foundation Model Landscape & Model Selection on Amazon Bedrock 1.4 Model Abstraction, Controlled Switching & Resilience 1.5 Customization Spectrum: Prompting vs RAG vs Fine-Tuning vs Continued Pre-training 1.6 Custom Model Deployment & Lifecycle Management

2 Chapter 2: Bedrock Knowledge Bases & RAG Architectures

2.1 Managed RAG Architecture with Bedrock Knowledge Bases 2.2 Knowledge Source Integration, Synchronization & Freshness 2.3 Data Ingestion, Parsing & Chunking Strategies 2.4 Embedding Models & Vector Representations 2.5 Vector Index Scale, Migration & Retrieval Evaluation 2.6 Vector Database Selection: OpenSearch Serverless vs Aurora pgvector vs Managed Stores 2.7 Vector Store Security, Multi-Tenancy & Connectivity

3 Chapter 3: Advanced Vector Search, Indexing & Data Compliance

3.1 Hybrid Search, Metadata Filtering & Semantic Reranking 3.2 Metadata Filtering, Reranking & Query Transformation 3.3 Fine-Tuning & Continued Pre-Training Data Pipeline Engineering 3.4 Data Validation, Multimodal Processing & Model Formatting 3.5 Data Privacy, Data Residency & Compliance Governance 3.6 Privacy Preservation, Source Lineage & Audit Evidence

4 Chapter 4: Prompt Engineering & Bedrock Runtime APIs

4.1 Advanced Prompt Engineering Techniques & Inference Parameters 4.2 Inference Parameters, Prompt Governance & Regression 4.3 Converse API vs InvokeModel API & Message Formatting 4.4 Tool Calling, FM API Resilience & Model Routing 4.5 Streaming Architectures & Asynchronous Event Processing 4.6 Resilient Streaming, Deployment & Asynchronous Processing

5 Chapter 5: Amazon Bedrock Agents & Tool Integration

5.1 Agentic Architecture, ReAct Reasoning Loops & Orchestration 5.2 Agent Frameworks, MCP & Lifecycle Management 5.3 Action Groups, OpenAPI Schemas & AWS Lambda Integration 5.4 Agent Memory, Session State & Multi-Agent Collaboration Patterns 5.5 Persistent State & Multi-Agent Coordination 5.6 Advanced Agent Prompt Templates & Flow Customization 5.7 Agent Safeguards, Tool Reliability & Cost Control

6 Chapter 6: Workflow Orchestration & Application Integration

6.1 Amazon Bedrock Prompt Flows & Visual Orchestration 6.2 Step Functions Orchestration & Human-in-the-Loop Workflows 6.3 Enterprise Integration: API Gateway, AppSync, and EventBridge 6.4 Hybrid Integration, GenAI Gateways & CI/CD Tooling

7 Chapter 7: AI Safety & Guardrails for Amazon Bedrock

7.1 Guardrails Architecture, Denied Topics & Content Filters 7.2 Content Safety, Defense in Depth & Threat Detection 7.3 Sensitive Information Filters & PII Redaction/Masking 7.4 Contextual Grounding Checks & Hallucination Prevention

8 Chapter 8: Security, Access Control & Network Architecture

8.1 IAM Least Privilege & Resource Policies for Bedrock 8.2 PrivateLink VPC Endpoints & Network Isolation 8.3 Encryption with AWS KMS & Cross-Account Access Patterns

9 Chapter 9: Governance, Auditing & Operational Logging

9.1 SageMaker Model Cards & AI Governance Frameworks 9.2 Lineage, Fairness, Transparency & Continuous Governance 9.3 Invocation Logging, CloudTrail Auditing & Observability 9.4 Responsible AI, Bias Mitigation & Red Teaming Methodologies

10 Chapter 10: Performance, Throughput & Cost Optimization

10.1 On-Demand vs Provisioned Throughput & Capacity Planning 10.2 Capacity Measurement, Scaling Patterns & Resilience 10.3 Batch Inference & Bedrock Intelligent Prompt Routing 10.4 Intelligent Prompt Routing & Application Eligibility 10.5 Prompt Caching, Token Optimization & Latency Reduction

11 Chapter 11: Testing, Evaluation & Troubleshooting GenAI Solutions

11.1 Amazon Bedrock Model Evaluation (Automatic & Human Workflows) 11.2 Human, RAG & Continuous Evaluation 11.3 Evaluation Metrics & RAG Quality Benchmarking (Ragas, ROUGE, BLEU) 11.4 RAG and Agent Performance Evaluation 11.5 CloudWatch Metrics, Throttling & Operational Observability 11.6 Quota Diagnosis, Retry Control & Operational Troubleshooting 11.7 Troubleshooting Common GenAI Failure Modes & Agent Traces 11.8 Prompt Maintenance, Content Handling & Deployment Validation

3.1 Hybrid Search, Metadata Filtering & Semantic Reranking

Key Takeaways Explain This Topic AI

Pure dense vector search excels at semantic matching and conceptual paraphrasing but fails on exact alphanumeric tokens such as product SKUs, serial numbers, software error codes, and niche acronyms.

Hybrid search in Amazon Bedrock Knowledge Bases and OpenSearch Serverless bridges vocabulary mismatch by merging dense k-NN vector retrieval with sparse BM25 lexical scoring using Reciprocal Rank Fusion (RRF).

Reciprocal Rank Fusion calculates an aggregated score via RRF_Score = SUM(1 / (k + rank)), normalizing disparities between unbounded BM25 scores and bounded vector similarities without requiring manual weight tuning.

Deterministic metadata filtering is implemented using S3 companion files named with the exact suffix .metadata.json, executing pre-filtering directly during vector index search to eliminate unauthorized or irrelevant chunks before retrieval.

Semantic reranking uses cross-encoder models such as Cohere Rerank to evaluate query-document pairs jointly with bidirectional cross-attention, re-ranking the top-k retrieved candidates to maximize context window relevance and reduce LLM hallucinations.

Last updated: September 2026

3.1 Hybrid Search, Metadata Filtering & Semantic Reranking

Retrieval-Augmented Generation (RAG) systems in enterprise environments require far greater retrieval precision than basic nearest-neighbor semantic search can provide. When generative AI applications transition from prototype to production, developers encounter query patterns where pure dense embeddings struggle—most notably queries involving exact part numbers, error codes, proprietary acronyms, and strict multi-attribute access control filters. This section examines advanced retrieval architectures within Amazon Bedrock Knowledge Bases and Amazon OpenSearch Serverless, focusing on hybrid search, metadata pre-filtering, and two-stage semantic reranking.

The Limitations of Pure Dense Vector Retrieval

Dense vector retrieval maps text chunks into continuous, high-dimensional vector spaces (such as 1,024 or 1,536 dimensions) using embedding models like Amazon Titan Text Embeddings v2. Retrieval operates by calculating mathematical proximity—typically cosine similarity, dot product, or Euclidean distance (L2 norm)—between the query vector and indexed document vectors.

While dense vector search excels at capturing conceptual nuance, thematic intent, and cross-lingual meaning, it suffers from well-documented failure modes in production applications:

Exact Alphanumeric Identifiers and Serial Numbers : When a user searches for an exact part code such as SKU-8492-X or a vehicle identification number (VIN), dense embedding models project the subword tokens into an abstract semantic cluster. A document containing SKU-8492-Y may have an almost identical cosine similarity score (e.g., 0.985 vs. 0.987), leading the vector database to retrieve the incorrect product manual.

Software Stack Traces and Error Codes : Strings like NullPointerException , ECONNRESET_403 , or ERR_DB_CLIENT_TIMEOUT carry critical operational meaning that subword tokenizers (like Byte-Pair Encoding) split into generic subwords ( ECONN , RESET , 403 ), losing the exact technical signature.

Out-of-Vocabulary (OOV) Terms and Project Names : Highly specific internal codenames, novel chemical compounds, or brand-new regulatory acronyms not represented in the embedding model's pre-training corpus produce dispersed, uninformative vector representations.

Short Queries with High Precision Intent : Queries consisting of one or two keywords (e.g., "Form 1099-MISC box 7") often map to broad semantic spaces, retrieving generalized tax overviews rather than the specific filing instructions for that exact box.

Sparse Lexical Search and BM25 Mechanics

To overcome these limitations, production architectures leverage sparse lexical search , primarily powered by the BM25 (Best Matching 25) ranking function within OpenSearch Serverless. BM25 is an advanced probabilistic information retrieval algorithm that improves upon classic TF-IDF (Term Frequency-Inverse Document Frequency).

BM25 evaluates relevance based on three core components:

Term Frequency (TF) : How frequently the query terms appear in a given document chunk, governed by a saturation parameter ( k 1 k_1 k 1 ​ ) that prevents a term repeated 50 times from artificially dominating the score.

Inverse Document Frequency (IDF) : How rare the query term is across the entire corpus, giving immense weight to rare tokens (like SKU-8492-X ) while suppressing ubiquitous words (like system or manual ).

Document Length Normalization ( b b b ) : Penalizes excessively long chunks to prevent documents with higher word counts from scoring artificially high simply by chance.

While BM25 is virtually immune to the exact-token matching failures of dense vectors, it suffers from the vocabulary mismatch problem : if a user searches for "automobile warranty coverage" and a document chunk discusses "car guarantee protection," BM25 returns zero relevance because no exact terms overlap.

Hybrid Search Mechanics: Score Fusion and RRF

Hybrid search combines the semantic generalization of dense vector retrieval with the exact-token precision of BM25 sparse search. In Amazon Bedrock Knowledge Bases backed by Amazon OpenSearch Serverless, a single query triggers parallel execution of both search mechanisms. ┌─────────────────────────────┐

  • │ User Query │
  • └──────────────┬──────────────┘
  • │
  • ┌───────────────────────┴───────────────────────┐
  • ▼ ▼
  • ┌──────────────────────────┐ ┌──────────────────────────┐
  • │ Dense Vector Retrieval │ │ Sparse Lexical Search │
  • │ (k-NN Cosine Similarity)│ │ (BM25 Score) │
  • └────────────┬─────────────┘ └─────────────┬────────────┘
  • │ │
  • │ Ranked Candidates (1..N) │ Ranked Candidates (1..N)
  • └───────────────────────┬───────────────────────┘
  • ▼
  • ┌─────────────────────────────┐
  • │ Reciprocal Rank Fusion │
  • │ (RRF) │
  • └──────────────┬──────────────┘
  • ▼
  • ┌─────────────────────────────┐
  • │ Fused Ranked Results │
  • └─────────────────────────────┘
  • The Challenge of Direct Score Combination

A critical challenge in hybrid search is score calibration:

Dense vector cosine similarity produces bounded float values between 0.0 and 1.0 (or -1.0 to 1.0 ).

BM25 produces unbounded positive real numbers between 0.0 and +infinity (often ranging from 2.5 to 35.0+ depending on corpus size and term rarity).

Directly adding raw scores ( S c o r e v e c t o r + S c o r e B M 25 Score_{vector} + Score_{BM25} S cor e v ec t or ​ + S cor e BM 25 ​ ) causes the unbounded BM25 score to overwhelmingly dictate the final ranking, rendering the vector similarity score virtually irrelevant.

Reciprocal Rank Fusion (RRF)

To resolve disparate scoring scales, Amazon Bedrock and OpenSearch utilize Reciprocal Rank Fusion (RRF) . RRF is an algorithmic rank-merging technique that operates on the ordinal ranking positions of documents across multiple retrieval lists, completely disregarding raw numerical scores.

The RRF score of document d d d across a set of retrieval methods M M M is defined as: R R F _ S c o r e ( d ) = ∑ m ∈ M 1 k + r m ( d ) RRF\_Score(d) = \sum_{m \in M} \frac{1}{k + r_m(d)} RRF _ S core ( d ) = m ∈ M ∑ ​ k + r m ​ ( d ) 1 ​

Where:

M M M is the set of retrieval systems (Dense Vector search and Sparse BM25 search).

r m ( d ) r_m(d) r m ​ ( d ) is the 1-based rank position of document d d d in the results of system m m m .

k k k is a constant smoothing parameter (by default k = 60 k = 60 k = 60 in information retrieval standards).

If a document does not appear in the top results of a specific retrieval system, its rank term for that system is omitted (or treated as infinity).

Why k = 60 k = 60 k = 60 Matters

The constant k k k dampens the penalty difference between adjacent ranks. For example, when k = 60 k = 60 k = 60 :

  • Rank 1 yields a score component of 1 60 + 1 = 0.01639 \frac{1}{60 + 1} = 0.01639 60 + 1 1 ​ = 0.01639
  • Rank 2 yields a score component of 1 60 + 2 = 0.01613 \frac{1}{60 + 2} = 0.01613 60 + 2 1 ​ = 0.01613
  • Rank 10 yields a score component of 1 60 + 10 = 0.01428 \frac{1}{60 + 10} = 0.01428 60 + 10 1 ​ = 0.01428

Because the drop-off is smooth, a document that ranks moderately well in both dense search (e.g., rank 3) and sparse search (e.g., rank 4) will achieve a higher cumulative RRF score ( 0.01587 + 0.01562 = 0.03149 0.01587 + 0.01562 = 0.03149 0.01587 + 0.01562 = 0.03149 ) than a document that ranks 1st in dense search ( 0.01639 0.01639 0.01639 ) but fails to appear in the sparse search list entirely.

Loading diagram... Two-Stage Hybrid Search and Semantic Reranking Pipeline