Skip to main content
FixedSizeChunking creates chunks up to chunk_size characters and avoids splitting a word when a boundary is available.
1

Create a Python file

fixed_size_chunking.py
2

Set up your virtual environment

3

Install dependencies

4

Export your OpenAI API key

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
5

Run PgVector

6

Run the script

The example sets split_on_pages=False so PDFReader combines the pages before applying FixedSizeChunking. Keep the default value of True to chunk each page independently.

Fixed Size Chunking Params

Developer Resources