بنقرة واحدة
context-enrichment-window
Add surrounding chunks to retrieved results to provide more coherent and complete context.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add surrounding chunks to retrieved results to provide more coherent and complete context.
التثبيت باستخدام 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 | context-enrichment-window |
| title | Context Enrichment Window |
| description | Add surrounding chunks to retrieved results to provide more coherent and complete context. |
| allowed-tools | ["Read","Grep","Glob","Bash"] |
| category | retrieval-strategies |
| tags | ["context-enrichment","surrounding-context","window","coherence"] |
Context enrichment window expands retrieved chunks by including neighboring text from the original document. This provides more coherent and contextually rich results, mitigating the tendency of vector search to return isolated text fragments.
Vector-based retrieval often returns isolated fragments:
Store chunk indices and document positions during the indexing phase.
Why: To retrieve surrounding chunks, you need to know where each chunk sits in the original document. Indexing maintains this positional information.
Assign a sequential index to each chunk during the chunking process and store the index as metadata.
Include chunk indices and position information in the vector database.
Why: Vector databases need to store positional metadata alongside content to enable context enrichment after retrieval.
Add index, start position, and end position as metadata fields for each chunk in your vector database.
For each retrieved chunk, fetch surrounding chunks by index.
Why: Adding surrounding context provides the narrative flow and information needed to understand the retrieved fragment properly.
Retrieve chunks at indices ±N around each retrieved chunk, where N is the window size.
Properly combine overlapping chunks without duplication.
Why: Chunk overlap means surrounding chunks share text with the target chunk. Proper combination avoids duplication and maintains coherence.
When concatenating chunks, account for overlap by including each character only once.
Adjust window size based on chunk characteristics.
Why: Not all chunks need the same context size. Adaptive sizing balances completeness with efficiency.
Use larger windows for shorter chunks and smaller windows for longer chunks.
Combine all components into a cohesive retrieval system.
Why: A complete pipeline with configurable parameters allows for optimization and experimentation with different window strategies.
For implementation patterns, see LlamaIndex SentenceWindowNodeParser, LangChain ContextualCompressionRetriever, and the RecursiveCharacterTextSplitter for chunking strategies.