# ChunkingConfigurationProperty

Details about how to chunk the documents in the data source.

A *chunk* refers to an excerpt from a data source that is returned when the knowledge base that it belongs to is queried.

- Source: Generated at build time
- Type last changed: v2.154.0 · 22 Aug 2024

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_bedrock as bedrock } from 'aws-cdk-lib';
const chunkingConfigurationProperty: bedrock.CfnDataSource.ChunkingConfigurationProperty = {
  chunkingStrategy: 'chunkingStrategy',

  // the properties below are optional
  fixedSizeChunkingConfiguration: {
    maxTokens: 123,
    overlapPercentage: 123,
  },
  hierarchicalChunkingConfiguration: {
    levelConfigurations: [{
      maxTokens: 123,
    }],
    overlapTokens: 123,
  },
  semanticChunkingConfiguration: {
    breakpointPercentileThreshold: 123,
    bufferSize: 123,
    maxTokens: 123,
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_bedrock as bedrock

chunking_configuration_property = bedrock.CfnDataSource.ChunkingConfigurationProperty(
    chunking_strategy="chunkingStrategy",

    # the properties below are optional
    fixed_size_chunking_configuration=bedrock.CfnDataSource.FixedSizeChunkingConfigurationProperty(
        max_tokens=123,
        overlap_percentage=123
    ),
    hierarchical_chunking_configuration=bedrock.CfnDataSource.HierarchicalChunkingConfigurationProperty(
        level_configurations=[bedrock.CfnDataSource.HierarchicalChunkingLevelConfigurationProperty(
            max_tokens=123
        )],
        overlap_tokens=123
    ),
    semantic_chunking_configuration=bedrock.CfnDataSource.SemanticChunkingConfigurationProperty(
        breakpoint_percentile_threshold=123,
        buffer_size=123,
        max_tokens=123
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.bedrock.*;

ChunkingConfigurationProperty chunkingConfigurationProperty = ChunkingConfigurationProperty.builder()
        .chunkingStrategy("chunkingStrategy")

        // the properties below are optional
        .fixedSizeChunkingConfiguration(FixedSizeChunkingConfigurationProperty.builder()
                .maxTokens(123)
                .overlapPercentage(123)
                .build())
        .hierarchicalChunkingConfiguration(HierarchicalChunkingConfigurationProperty.builder()
                .levelConfigurations(List.of(HierarchicalChunkingLevelConfigurationProperty.builder()
                        .maxTokens(123)
                        .build()))
                .overlapTokens(123)
                .build())
        .semanticChunkingConfiguration(SemanticChunkingConfigurationProperty.builder()
                .breakpointPercentileThreshold(123)
                .bufferSize(123)
                .maxTokens(123)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Bedrock;

var chunkingConfigurationProperty = new ChunkingConfigurationProperty {
    ChunkingStrategy = "chunkingStrategy",

    // the properties below are optional
    FixedSizeChunkingConfiguration = new FixedSizeChunkingConfigurationProperty {
        MaxTokens = 123,
        OverlapPercentage = 123
    },
    HierarchicalChunkingConfiguration = new HierarchicalChunkingConfigurationProperty {
        LevelConfigurations = new [] { new HierarchicalChunkingLevelConfigurationProperty {
            MaxTokens = 123
        } },
        OverlapTokens = 123
    },
    SemanticChunkingConfiguration = new SemanticChunkingConfigurationProperty {
        BreakpointPercentileThreshold = 123,
        BufferSize = 123,
        MaxTokens = 123
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

chunkingConfigurationProperty := &ChunkingConfigurationProperty{
	ChunkingStrategy: jsii.String("chunkingStrategy"),

	// the properties below are optional
	FixedSizeChunkingConfiguration: &FixedSizeChunkingConfigurationProperty{
		MaxTokens: jsii.Number(123),
		OverlapPercentage: jsii.Number(123),
	},
	HierarchicalChunkingConfiguration: &HierarchicalChunkingConfigurationProperty{
		LevelConfigurations: []interface{}{
			&HierarchicalChunkingLevelConfigurationProperty{
				MaxTokens: jsii.Number(123),
			},
		},
		OverlapTokens: jsii.Number(123),
	},
	SemanticChunkingConfiguration: &SemanticChunkingConfigurationProperty{
		BreakpointPercentileThreshold: jsii.Number(123),
		BufferSize: jsii.Number(123),
		MaxTokens: jsii.Number(123),
	},
}
```

## Properties

- `chunkingStrategy`: string (required) — Knowledge base can split your source data into chunks.

  A *chunk* refers to an excerpt from a data source that is returned when the knowledge base that it belongs to is queried. You have the following options for chunking your data. If you opt for `NONE` , then you may want to pre-process your files by splitting them up such that each file corresponds to a chunk.

  - `FIXED_SIZE` – Amazon Bedrock splits your source data into chunks of the approximate size that you set in the `fixedSizeChunkingConfiguration` .
  - `HIERARCHICAL` – Split documents into layers of chunks where the first layer contains large chunks, and the second layer contains smaller chunks derived from the first layer.
  - `SEMANTIC` – Split documents into chunks based on groups of similar content derived with natural language processing.
  - `NONE` – Amazon Bedrock treats each file as one chunk. If you choose this option, you may want to pre-process your documents by splitting them into separate files.

- `fixedSizeChunkingConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.FixedSizeChunkingConfigurationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnDataSource.FixedSizeChunkingConfigurationProperty.html) — Configurations for when you choose fixed-size chunking.

  If you set the `chunkingStrategy` as `NONE` , exclude this field.

- `hierarchicalChunkingConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.HierarchicalChunkingConfigurationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnDataSource.HierarchicalChunkingConfigurationProperty.html) — Settings for hierarchical document chunking for a data source.

  Hierarchical chunking splits documents into layers of chunks where the first layer contains large chunks, and the second layer contains smaller chunks derived from the first layer.

- `semanticChunkingConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.SemanticChunkingConfigurationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrock.CfnDataSource.SemanticChunkingConfigurationProperty.html) — Settings for semantic document chunking for a data source.

  Semantic chunking splits a document into into smaller documents based on groups of similar content derived from the text with natural language processing.
