Certopolis

AWS Certified Generative AI Developer – Professional

Bedrock hybrid search, reranking, query decomposition: AIP-C01

Use HYBRID search when queries contain exact strings such as part numbers, because it adds a raw-text search to the vector search. Use a reranker model to reorder retrieved passages by relevance to the query. Use query decomposition when one question covers several things, because it splits the question into sub-queries before retrieval.

Search type

A knowledge base query can use semantic search, which searches only the vector embeddings, or hybrid search, which combines the vector search with a search of the raw text. If you set nothing, Amazon Bedrock picks the strategy for your vector store.

Set it in retrievalConfiguration.vectorSearchConfiguration.overrideSearchType as HYBRID or SEMANTIC. Hybrid search works only with Amazon RDS, Amazon OpenSearch Serverless and MongoDB vector stores that contain a filterable text field. With any other store, the query uses semantic search.

Example: sales staff ask for part HX-4410-B and get chunks about similar parts. Hybrid search finds the exact string while natural language questions keep their semantic matches.

Reranking

A reranker model scores each passage against the query and reorders them. You can retrieve fewer but more relevant results, which can lower the cost and latency of the generation call. Reranking works only on text.

There are two ways to use it. Call the Rerank operation directly with the query and a list of documents, which works for passages from any source, such as an Aurora pgvector table. Or add a reranking configuration to a Retrieve or RetrieveAndGenerate call on a knowledge base, where the reranked order overrides the knowledge base's default ranking.

Query decomposition and result count

Query decomposition breaks a complex query into smaller sub-queries, so more than one search can run against the knowledge base. A question that compares two products becomes one sub-query per product. It is set in a RetrieveAndGenerate request under orchestrationConfiguration.queryTransformationConfiguration with the type QUERY_DECOMPOSITION.

A query returns up to five results by default. numberOfResults sets the maximum, and fewer can come back. With hierarchical chunking, numberOfResults counts child chunks, and children that share a parent come back as one result.

Where the exam catches people

  • Believing a reranker fixes missed exact identifiers: a reranker only reorders what retrieval returned, so a chunk that was never retrieved stays missing. Hybrid search adds the raw-text match.
  • Believing hybrid search works with every vector store: it needs RDS, OpenSearch Serverless or MongoDB with a filterable text field, and otherwise falls back to semantic search.
  • Believing you need a knowledge base to use a Bedrock reranker: the Rerank operation takes inline documents from any source.
  • Believing a higher numberOfResults makes a comparison question cover both products: more passages can still all come from one product. Query decomposition searches for each part of the question.

Written from Amazon Web Services's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An industrial parts supplier uses an Amazon Bedrock knowledge base with an Amazon OpenSearch Serverless vector store to answer questions from its sales team. The vector index contains a filterable text field. Sales representatives often ask about specific part numbers such as HX-4410-B. The knowledge base returns chunks about similar parts but often misses the chunk that contains the exact part number. The company must improve retrieval for exact part numbers without reducing the quality of results for natural language questions. Which solution will meet these requirements with the LEAST operational overhead?

    Right. In the game that’s Renown for your Foundation Model Integration, Data Management, and Compliance building.

    Not that one: B is right. In the game your Foundation Model Integration, Data Management, and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The HYBRID search type "Combines searching vector embeddings (semantic search) with searching through the raw text", so the exact string is found while natural language questions keep their semantic matches. OpenSearch Serverless with a filterable text field supports it.

    Written from docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

  2. A legal research company runs a search service that retrieves the 100 most similar passages for each question from an Amazon Aurora PostgreSQL table by using the pgvector extension. Only the first 10 passages fit in the prompt that the service sends to an FM in Amazon Bedrock, and answers often miss the most relevant passage. The company must reorder the 100 passages by relevance to the question with an Amazon Bedrock reranker model and send the top 10 to the FM. The existing retrieval query and the Aurora table must stay unchanged. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Foundation Model Integration, Data Management, and Compliance building.

    Not that one: D is right. In the game your Foundation Model Integration, Data Management, and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The first is to "Call the Rerank operation directly through the Amazon Bedrock API", and the same page says "The Rerank operation sends the query, documents, and any additional configurations as input to a reranker model." The Rerank API reference (https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Rerank.html) takes sources as inline documents and a numberOfResults setting, so the passages from Aurora go in unchanged and the top 10 come back.

    Written from docs.aws.amazon.com/bedrock/latest/userguide/rerank.html

  3. An insurance company runs an assistant for its call center agents. The assistant calls the RetrieveAndGenerate API against an Amazon Bedrock knowledge base. The terms of each insurance product are in a separate document in the knowledge base. Agents often ask comparison questions, such as "Does Home Plus or Landlord Shield cover flood damage to rental properties?" For these questions, the retrieved passages usually come from only one product's document, and the answer covers only that product. The company wants each answer to cover every product that the question names. The company does not want to write orchestration code. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Foundation Model Integration, Data Management, and Compliance building.

    Not that one: B is right. In the game your Foundation Model Integration, Data Management, and Compliance building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    And "Enabling this option may result in multiple queries being executed against your Knowledge Base, which may aid in a more accurate final response." It is set in the RetrieveAndGenerate request under orchestrationConfiguration, in queryTransformationConfiguration with the type QUERY_DECOMPOSITION. A comparison of two products becomes one sub-query for each product, so each product's document is searched, with no orchestration code.

    Written from docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html