Certopolis

AWS Certified Generative AI Developer – Professional

Bedrock Knowledge Bases chunking strategies for AIP-C01

A knowledge base splits each document into chunks, embeds each chunk and stores the vectors. Pick fixed-size or default chunking for plain text, hierarchical when answers need the surrounding section, semantic to split on meaning, and no chunking when each file is already one unit. The chunking strategy is set when the data source is created and can't be changed afterwards.

The strategies

Default chunking splits content into chunks of about 300 tokens and keeps whole sentences together.

Fixed-size chunking lets you set the maximum tokens per chunk and an overlap percentage between consecutive chunks.

Hierarchical chunking creates child chunks inside parent chunks. You set the parent size, the child size and the overlap tokens. Retrieval searches the child chunks, then replaces them with their parent chunk so the model gets more context. Because several children can share one parent, a query can return fewer results than numberOfResults asked for. AWS does not recommend hierarchical chunking with an S3 vector bucket as the vector store.

Semantic chunking splits text where the meaning changes. You set maximum tokens, a buffer size (how many neighbouring sentences are embedded together) and a breakpoint percentile threshold. A higher threshold gives fewer, larger chunks. It costs extra because it uses a foundation model.

No chunking treats each document as one chunk. AWS suggests splitting documents into separate files first. With no chunking you cannot see page numbers in citations or filter on the page-number metadata field.

Your own chunking logic

If no built-in strategy fits, choose no chunking and add a custom transformation Lambda function. You also give the knowledge base an S3 bucket for intermediate storage. The function reads the files, writes chunked files back to the same bucket and returns references, and the knowledge base continues ingestion from there.

For example, to make each chunk exactly one contract clause, set no chunking and let the Lambda function split at clause numbers. If you only want to add chunk-level metadata, keep a built-in strategy such as fixed-size and use the Lambda function after chunking. Chunk-level metadata overrides file-level metadata when keys collide.

Changing the strategy later

The UpdateDataSource API reference says you can't change chunkingConfiguration after you create the data source. To move existing documents to a new strategy and keep the same knowledge base ID, add a second data source over the same S3 location with the new strategy, ingest it, test it, then delete the old data source. If the old data source uses the DELETE data deletion policy, its chunks are removed from the vector store.

Where the exam catches people

  • Believing UpdateDataSource can switch fixed-size chunking to hierarchical: chunkingConfiguration is fixed when the data source is created.
  • Believing hierarchical chunking always returns numberOfResults chunks: children that share a parent are replaced by that one parent, so fewer results can come back.
  • Believing custom chunking in Lambda works with fixed-size chunking set: to apply your own split, choose no chunking and add the custom transformation with an S3 bucket.
  • Believing semantic chunking costs the same as fixed-size: it uses a foundation model, which adds cost based on the amount of data.
  • Believing no chunking keeps page-number citations: with no chunking you cannot view page numbers in citations or filter on the page-number field.

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. A company runs an internal policy assistant on a customer-managed Amazon Bedrock knowledge base with an Amazon OpenSearch Serverless vector store. The knowledge base has one Amazon S3 data source that was created with fixed-size chunking of 300 tokens and the DELETE data deletion policy. Answers about long policy sections miss the surrounding context. The company will move the same documents to hierarchical chunking. The application must keep using the same knowledge base ID, and no fixed-size chunks can remain in the vector store after the change. Which combination of steps will meet these requirements? (Select TWO)

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

    Not that one: D,E 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

    A second data source over the same S3 location can carry the hierarchical settings inside the same knowledge base. Removing the original data source, which uses the DELETE policy, then clears the fixed-size chunks.

    Written from docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateDataSource.html

  2. A company runs an HR assistant on an Amazon Bedrock knowledge base that uses Amazon Titan Text Embeddings V2 and the default chunking strategy. A preprocessing job has already split the employee handbook into 1,800 text files in the Amazon S3 data source. Each file holds one policy question and its complete answer and is between 150 and 1,200 tokens long. The assistant calls the Retrieve API with numberOfResults set to 5. Answers often omit conditions because a retrieved chunk holds only part of a policy answer. Each result must contain one complete file, and each call must return five results when five relevant files exist. 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: A 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

    Every result is then one complete file, and five relevant files give five results. The largest file, 1,200 tokens, is well inside the Titan Text Embeddings V2 input limit (https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html): "Titan Text Embeddings V2 takes as input a non-empty string with up to 8,192 tokens or 50,000 characters."

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

  3. A law firm uses an Amazon Bedrock knowledge base with an Amazon S3 data source that holds 8,000 commercial contracts. Each contract is divided into numbered clauses that range from one sentence to several pages. Answers often quote only part of a clause because retrieved chunks start or end in the middle of a clause. Each chunk must contain exactly one complete clause. A GenAI developer has written an AWS Lambda function that splits contract text at clause numbers. The firm wants to keep using the managed ingestion of the knowledge base. 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: C 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

    It adds that the knowledge base needs "an Amazon S3 bucket for the knowledge base to write files to be chunked by your Lambda function", and that the function writes the chunked files back to the same bucket for the knowledge base to process.

    Written from docs.aws.amazon.com/bedrock/latest/userguide/kb-custom-transformation.html