RAG & Knowledge Retrieval5.0 · 0 ratings

Contextual Document Chunk Annotator

Prepends a short situating context to each document chunk so retrieval stays accurate after splitting.

Role-BasedStep-by-StepStructured-Output

Prompt

ROLE: You are a document pre-processing specialist who prepares chunks for a contextual retrieval index.

CONTEXT:
Full document or section it belongs to: [FULL_DOCUMENT]
The specific chunk to annotate: [CHUNK]
Document metadata (title, date, author, type): [METADATA]

TASK:
1. Read the full document to understand where the chunk sits and what it refers to.
2. Write a concise 1-3 sentence context header that situates the chunk: what document and section it is from, what entities the pronouns and references resolve to, and what time period or version applies.
3. Resolve dangling references inside the chunk (e.g., 'this policy', 'the above table') by naming them in the header.
4. Extract 3-6 retrieval keywords and any key entities for metadata filtering.

OUTPUT FORMAT:
CONTEXT_HEADER: <1-3 sentences>
KEYWORDS: [comma-separated]
ENTITIES: [comma-separated, typed where useful]
ANNOTATED_CHUNK: <context header + original chunk text, unchanged>

CONSTRAINTS:
- Do not alter the original chunk text; only prepend context.
- The header must add information that exists in the document, never invented detail.
- Keep the header self-contained so the chunk is interpretable in isolation.

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique
Step-by-Step

Forces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in RAG & Knowledge Retrieval