Process long pages and PDFs in chunks

Run the AI over pages and PDFs too long for one request.

On this page

Chunking slices a long text, like a book-length PDF or a three-hour transcript, into pieces that fit the model, and runs a GPT step on each piece in turn. Use it when you need every part of the text read, not just the start.

Without chunking, {{page}} puts as much of the page into the prompt as fits and cuts the end. With today's large models that is often enough; turn on chunking when it isn't.

# Turn on chunking in a GPT step

  1. Type / in the chat and click Create, or edit a command you made.
  2. In a GPT step, under run options, click the scissors button, Chunked.
  3. Put {{chunk}} in the prompt where each piece goes. Until you do, the step reminds you to reference {{chunk}} parameter in prompt.
  4. Fill in the chunk settings, or keep the defaults:
FieldWhat it does
text to slice into chunksThe text to slice. {{page}} by default; {{transcript}} or your own parameter work too
tokens per chunkThe largest request, prompt and chunk together, at least 512. Empty (auto) uses as much as the model takes
message if text is emptyOptional. Written in the chat when there is nothing to slice

gpt step chunked

  1. Click Save. When the command runs, each answer is marked with its chunk, like 2 / 5.

On an open PDF, {{page}} is the PDF's text, and on a YouTube video it is the transcript.

# Combine the answers

When the last chunk is done, all answers are joined, separated by blank lines, into the step's parameter: {{gpt}} by default. Add a second GPT step that works on the joined answers:

Step 1, chunked, on {{page}}:

List the key facts from this part of the document, 3 to 5 short bullet points.
Answer in {{language}}.

PART {{chunk.index}} OF {{chunk.total}}:
{{chunk}}

Step 2, a single request:

Below are notes taken from each part of a long document. Write a 30-word TL;DR,
then the 5 most important takeaways as bullet points. Answer in {{language}}.

NOTES:
{{gpt}}

{{chunk.index}} and {{chunk.total}} are the piece's number and the number of pieces.

# Good to know

  • Each chunk is a separate request: the model sees one piece of the text at a time. Put everything it needs, like the task and the output format, in the prompt.
  • Turn on Isolated (the button next to Chunked) to send each chunk without the chat history and system messages. It saves tokens and works on HARPA's cloud models and your own API keys.
  • On HARPA's cloud models, every chunk is a request that uses cloud credits. See Cloud models and credits.
  • To pull only the passages about one topic instead of reading everything, use {{page query limit=…}}: see Read other pages with {{page}}.