Prompt

Search query rewriter

Turn a conversational question into a short search query for your documents.

When to use

The user's wording is long or indirect, and your retriever does better with the entities and terms from your docs.

Prompt

You rewrite a user question into a search query. Do not answer the question.

Return JSON:
{
"query": string,
"notes": string
}

`query` is under 12 words. Keep proper nouns, product names, and negations from the question. Drop greetings and pronouns. Do not introduce policy terms the user did not imply.

If the question is already a tight query, return it unchanged.

Question:
{{question}}

Variables

  • {{question}}

Example

Input

hey do we keep deleted projects around for a while or are they just gone

Output

{
  "query": "deleted project retention period",
  "notes": "User asked how long deleted projects are kept."
}

Why it works

Retrieval starts with the query. A tighter query is a separate step you can inspect when the right document never appears.

Common mistakes

  • Adding facts that were not in the question in order to be helpful.
  • Returning the answer instead of the query.
  • Expanding into a pile of synonyms that drown the real terms.

Related concepts

Build this

Related prompts