Context Workflows Workflow Advanced

AI RAG Context Workflow

Prepare documents for a RAG system so retrieved answers stay accurate — budget the chunk size to the model, ground the sources against drift, and split them on clean boundaries for retrieval.

The problem

RAG answers are only as good as the chunks behind them. Split documents arbitrarily and a retrieved fragment arrives stripped of the context that made it meaningful. Size chunks wrong for the model and you either waste the window or starve it. Skip grounding and the model fills gaps with confident invention. The retrieval layer gets the blame, but the failure usually happened earlier — in how the source was prepared. That preparation is unglamorous and decisive: budget the chunk size, ground the sources, and split where the meaning actually breaks.

Recommended workflow

Each step uses an existing NewPrompt tool, pre-filled by a matching resource. Open the resource to read it, or jump straight into the tool with the inputs ready.

  1. Budget the chunk size to the model

    Decide how big a chunk can be once you account for the query, the retrieved neighbors, and room to answer. Chunk size is a budgeting decision before it's a splitting one.

    Outcome A target chunk size that fits retrieval plus a real response.
  2. Ground the sources against drift

    Package each source with grounding rules so the model answers from the retrieved text — and says so when the text doesn't cover the question — instead of inventing.

    Outcome Sources framed so the model stays inside them.
  3. Split on clean boundaries for retrieval

    Chunk to the budgeted size on real boundaries, so each retrieved piece is self-contained and still makes sense pulled out of order.

    Outcome Retrieval-ready chunks that hold meaning on their own.

Expected outcome

A set of source documents chunked to the right size, grounded against hallucination, and split so each retrieved piece stands on its own — the preparation that lets a RAG system return accurate, sourced answers instead of confident guesses.

Best for

  • Preparing a knowledge base for retrieval
  • Fixing a RAG system that returns vague or wrong answers
  • Chunking documents so retrieval stays accurate

Not for

  • Analyzing or summarizing a single document in one sitting — use the AI Long Document Analysis Workflow
  • Content that already fits in the prompt with no retrieval layer

FAQ

AI RAG context prep vs long document analysis workflow

Prepare documents for RAG when you're feeding a corpus into a retrieval system to query later; use long document analysis when you're reading one oversized file in a single session and want a summary. This grounds and chunks for storage across many docs — it never summarizes.

Why budget chunk size before splitting?

Because the right chunk size depends on what else shares the window at query time — the question, the other retrieved chunks, and the response. Splitting first and sizing later is how you end up re-chunking everything.

Does grounding replace a good retriever?

No — it complements it. Even perfect retrieval fails if the model treats retrieved text as a suggestion. Grounding tells it to answer from the source and admit gaps, which is what keeps RAG answers honest.

What does RAG chunk preparation output look like?

A set of source documents chunked to your budgeted size on clean boundaries, each piece self-contained, with grounding rules attached so the model answers from the retrieved text. It's retrieval-ready preparation you load into your own retriever — not the retriever itself, which you still build and run.

How to prepare documents for a RAG system

Work the three steps in your own AI tool: budget the chunk size with the context-window estimator, ground each source with the long-input formatter, then split on clean boundaries with the long-prompt splitter. NewPrompt supplies the prompts and order; you run them and load the output into your retriever.

RAG returns wrong answers, how do I fix it?

Usually the preparation failed, not the retriever. Chunks split mid-thought arrive stripped of context; chunks sized wrong crowd out the answer; ungrounded sources let the model invent. Re-run the workflow — budget the size, ground against drift, split on real boundaries — before you blame the retrieval layer.

Part of these projects

Complete build journeys that include this workflow as a stage.

Tip: Each step's resource opens its tool pre-filled — start at step one and carry the output forward.