Reranking Bedrock Knowledge Base Results for Legal Precedents
A legal research company is developing an AI-powered chat assistant that uses Amazon Bedrock with a knowledge base that contains millions of legal documents. When attorneys search for legal case precedents, the initial retrieval returns many documents. The company wants the chat assistant to generate all responses within 3 seconds. The foundation model (FM) that the chat assistant uses has a context window limitation that allows effective processing for only 10 documents for each query. Currently, the retrieval configuration fetches 50 documents by using semantic search. Attorneys report that highly relevant precedents frequently appear in positions 15-40 of the results. The company needs a solution to improve the relevance of query results. The solution must meet the company's latency and context window constraints. Which solution will meet these requirements?
Community Insight
The question tests how to improve relevance when relevant results fall outside the FM's context window; the trap is assuming semantic search alone ranks well, or resorting to custom Lambda/TF-IDF/cosine re-scoring instead of the native reranking feature.
For Amazon Bedrock Knowledge Bases, enabling a reranker model reorders a wide initial retrieval (e.g., 50 documents) and returns only the top-scored results (e.g., 10) that fit the FM's context window. This question establishes that cross-encoder reranking is the mechanism that surfaces relevant precedents buried at positions 15–40 while preserving the 3-second latency budget.
Choosing option C or D — building custom Lambda-based merging with TF-IDF or recomputing cosine similarity. Both duplicate what the retrieval pipeline already does (embedding similarity), add Lambda cold-start and processing latency that threatens the 3-second target, and offer weaker relevance than a cross-encoder that scores the query and document jointly.
Community Discussion (1 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Amazon Bedrock Knowledge Bases support an optional reranking step (for example, using Amazon Rerank or Cohere Rerank models, with language-specific configuration) that runs after the initial vector/semantic retrieval. The reranker is a cross-encoder: it evaluates the query and each candidate document jointly, producing far more accurate relevance scores than the bi-encoder embeddings used in retrieval. This directly solves the reported symptom — relevant precedents at positions 15–40 — because reranking reorders the entire 50-document candidate set. By configuring the knowledge base to return only the top 10 results, the response fits the FM's 10-document context window and reduces prompt processing, which helps meet the 3-second response requirement. This is a native, managed capability requiring no custom code.Why the Other Options Are Wrong
Option A fails because raising temperature only increases output randomness and has no effect on retrieval relevance; asking the model to scan all 50 documents also violates the 10-document context limit and burns latency. Option C builds three chunk-size knowledge bases and a Lambda that merges 150 results and applies TF-IDF — a lexical scoring method ill-suited to semantic legal-precedent matching, and the extra retrieval and processing would exceed the 3-second latency target. Option D recomputes cosine similarity between the query embedding and each document embedding, which is exactly the same scoring the vector search already performed, so it adds Lambda overhead without improving ranking of documents at positions 15–40; a cross-encoder reranker is strictly better here.Community Comment Notes
A single community comment selected option B, reasoning that "Enable reranking on the knowledge base by using a reranker model with language-specific configurations" lets the assistant retrieve 50 documents and return only the top 10. That aligns with AWS's documented reranking feature for Bedrock Knowledge Bases and with the question's latency and context-window constraints, so the community pick is consistent with the vendor capability rather than being a guess.Official Reference
Exam Strategy
When relevance suffers despite correct embeddings and relevant items rank low, look for the managed reranking option in Bedrock Knowledge Bases — it reorders a broad candidate set and returns only the top N to fit the context window; avoid custom Lambda post-processing unless reranking is unavailable.
Frequently Asked Questions
Why does reranking fix precedents that appear at positions 15–40 in the results?
A cross-encoder reranker rescores every candidate by jointly evaluating the query and each document, so relevant items buried by vector similarity move into the top 10 returned to the FM.
Why is recomputing cosine similarity in a Lambda function (option D) not effective?
Cosine similarity over the same embeddings is what vector retrieval already uses, so re-sorting by it changes nothing while adding Lambda latency that risks the 3-second response target.
Related Analysis
Practice All AIP-C01 Questions
Access 110 questions with complete answers and detailed explanations.
View Full AIP-C01 Practice Test →