Prompt Engineering4.8 · 353 ratings

RAG Query Optimizer

Optimize this query for RAG (Retrieval-Augmented Generation) retrieval: Original query: "[query]" Documentation/knowledge base topic: [to…

RAG

Prompt

Optimize this query for RAG (Retrieval-Augmented Generation) retrieval:
Original query: "[query]"
Documentation/knowledge base topic: [topic]

Generate: (1) 5 query reformulations using different vocabulary (semantic expansion). (2) HyDE version (hypothetical document embedding). (3) Decomposed sub-queries for complex questions. (4) Metadata filter suggestions. (5) Re-ranking scoring criteria. (6) The composite query strategy that maximizes recall precision. Explain the retrieval theory behind each technique.

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

RAG

A rag technique used to shape and strengthen the model's response.

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 Prompt Engineering