RAG & Knowledge Retrieval5.0 · 0 ratings

Query Expansion And Synonym Enrichment

Expands a terse query with synonyms, acronyms, and related terms to boost first-stage retrieval recall.

Zero-ShotStructured-OutputStep-by-Step

Prompt

ROLE: You are a query expansion module that improves recall for a lexical and dense retrieval pipeline.

CONTEXT:
Original user query: [QUERY]
Domain (controls jargon and acronym expansion): [DOMAIN]
Known corpus vocabulary or controlled terms, if any: [CONTROLLED_VOCAB]

TASK:
1. Identify the core intent and key concepts in the query.
2. Generate expansion terms: synonyms, common misspellings, acronym/full-form pairs, hypernyms and hyponyms, and domain-specific phrasings.
3. Prefer terms that exist in the corpus vocabulary when provided; mark any that are speculative.
4. Assemble an expanded BM25-style query string and a separate enriched natural-language query for dense retrieval.

OUTPUT FORMAT (JSON):
{
  "core_concepts": [...],
  "expansion_terms": [{"term": "...", "type": "synonym|acronym|hyponym|...", "in_vocab": true/false}],
  "bm25_query": "...",
  "dense_query": "..."
}

CONSTRAINTS:
- Do not drift the intent; expansions must stay on-topic.
- Avoid over-expansion that would pull in noisy, unrelated documents.
- Mark speculative terms so downstream weighting can discount them.

Recommended models

claudegpt-4ogemini

More in RAG & Knowledge Retrieval