一键导入
query-transformation-strategies
Use query rewriting, step-back prompting, and sub-query decomposition to improve retrieval quality and comprehensiveness.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use query rewriting, step-back prompting, and sub-query decomposition to improve retrieval quality and comprehensiveness.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use this skill when building, debugging, or improving Retrieval-Augmented Generation systems, including chunking, vector database selection, hybrid search, reranking, multimodal RAG, code documentation RAG, retrieval latency, and production RAG architecture.
Chunk nested documents into parent-child levels so retrieval can move from broad sections to fine-grained passages.
Use semantic boundaries and embedding similarity to chunk text for higher-relevance retrieval.
Route RAG chunking decisions across semantic, hierarchical, sliding-window, contextual-header, and framework-selection strategies.
Use overlapping windows to preserve context across chunk boundaries while controlling retrieval size.
Reduce retrieval latency with caching, batching, and index-level optimization.
| name | query-transformation-strategies |
| title | Query Transformation Strategies |
| description | Use query rewriting, step-back prompting, and sub-query decomposition to improve retrieval quality and comprehensiveness. |
| allowed-tools | ["Read","Grep","Glob","Bash"] |
| category | retrieval-strategies |
| tags | ["query-expansion","step-back","sub-query","query-rewriting"] |
Query transformation strategies modify or expand user queries before retrieval to bridge the gap between natural language queries and document representations. These techniques improve retrieval relevance by generating multiple query variants, each targeting different aspects of the information need.
Direct query-to-document matching has inherent limitations:
Use an LLM to reformulate the original query into a more detailed, specific version.
Why: Enhanced queries include relevant terminology, proper context, and specific aspects that the original query might miss. This improves matching with technical documents and domain-specific content.
Instruct the LLM to expand queries with relevant domain terminology, clarify ambiguous terms, and add context that would appear in target documents.
Generate a broader, more general version of the query to retrieve foundational context.
Why: Step-back queries provide background information and fundamental concepts that help ground more specific answers. This is especially valuable for technical topics where understanding basics is essential.
Generate step-back queries that capture higher-level concepts, general principles, or background knowledge related to the specific query.
Break down complex queries into 2-4 simpler sub-questions covering different aspects.
Why: Sub-query decomposition ensures comprehensive coverage of multi-faceted questions. Each sub-query targets a different aspect, allowing retrieval of diverse information that together provide a complete answer.
Direct the LLM to identify component questions that, when answered together, comprehensively address the original query.
Execute multiple query variants and combine their retrieval results.
Why: Multi-query retrieval increases recall by retrieving documents matched by different query formulations. Combining results ensures broader coverage and higher likelihood of finding relevant information.
Retrieve documents for each query variant, then deduplicate results and re-rank by relevance to the original query.
Combine results from different query transformations using scoring and deduplication.
Why: Result fusion prevents redundant information and prioritizes the most relevant documents across all query variants. A weighted scoring approach balances specificity with comprehensiveness.
Use reciprocal rank fusion (RRF) or weighted scoring to combine results from different query variants.
For implementation patterns, see LangChain routing workflows, LlamaIndex Query Transform Cookbook, and the Step-back prompting paper.