Skip to main content
Agentic chunking is an intelligent method of splitting documents into smaller chunks by using a model to determine natural breakpoints in the text. Rather than splitting text at fixed character counts, it analyzes the content to find semantically meaningful boundaries like paragraph breaks and topic transitions.
1

Create a Python file

agentic_chunking.py
2

Set up your virtual environment

3

Install dependencies

4

Run PgVector

5

Run the script

Custom Prompts

Custom prompts override default chunking behavior and are prioritized over default instructions.
Best Practices:
  • Always set max_chunk_size when using custom_prompt.
  • Focus custom_prompt on chunking logic only.
  • The default instructions automatically handle the output format constraints.
See Agentic Chunking with Custom Prompt for a complete example.

Agentic Chunking Params