semantic-chunking
Skill8 starsChanged 7 months agoMITView on GitHub
Use semantic boundaries and embedding similarity to chunk text for higher-relevance retrieval.
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rag-skillsSkill
- choosing-a-chunking-frameworkSkill
- contextual-chunk-headersSkill
- hierarchical-chunkingSkill
- chunkingSkill
- sliding-window-chunkingSkill
- rag-for-code-documentationSkill
- rag-for-multimodal-contentSkill
- data-type-handlingSkill
- index-versioning-and-reindexingSkill
- production-rag-deploymentSkill
- deploymentSkill
- generation-evaluation-metricsSkill
- rag-evaluation-frameworksSkill
- retrieval-evaluation-metricsSkill
- evaluation-metricsSkill
- optimize-retrieval-latencySkill
- performance-optimizationSkill
- agentic-rag-routingSkill
- multi-agent-rag-orchestrationSkill
- rag-agentsSkill
- adaptive-retrievalSkill
- context-enrichment-windowSkill
- crag-corrective-ragSkill
- explainable-retrievalSkill
- graph-ragSkill
- hybrid-search-bm25-denseSkill
- hyde-hypothetical-document-embeddingsSkill
- hype-hypothetical-prompt-embeddingsSkill
- multi-pass-retrieval-with-rerankingSkill
- query-transformation-strategiesSkill
- raptor-hierarchical-retrievalSkill
- self-ragSkill
- retrieval-strategiesSkill
- choosing-vector-db-by-datatypeSkill
- qdrant-for-production-ragSkill
- qdrant-setup-ragSkill
- vector-databasesSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
Use sentence boundary detection rather than simple period splitting.
- Distinctive: line 46
Why: Document structure often encodes semantic boundaries (chapters, sections, subsections).
- Distinctive: line 57
When retrieval quality is more important than fixed-size guarantees
- Distinctive: line 59
When using semantic search (vector embeddings) for retrieval
- Distinctive: line 65
When you need exact token count guarantees (e.g., for API limits)
- Distinctive: line 67
When using exact keyword matching (BM25) where chunk size matters less
- Distinctive: line 77
Coverage: No significant information lost in chunk boundaries
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Overview
Semantic chunking divides documents into segments based on natural language boundaries and semantic meaning rather than fixed character counts. This approach preserves context integrity and improves retrieval relevance by keeping related ideas together.
Problem Statement
Fixed-size chunking (e.g., 1000 tokens) often cuts through mid-sentence, mid-paragraph, or mid-concept, resulting in:
- Fragments that lose semantic meaning
- Context bleeding across unrelated chunks
- Poor retrieval relevance for semantic search
- Difficulty for LLMs to understand isolated fragments
Key Concepts
- Semantic Boundaries: Natural break points in text (paragraphs, sections, sentences)
- Context Preservation: Keeping related ideas and arguments together
- Sentence Boundary Detection: Using NLP tools to identify proper sentence ends
- Paragraph Cohesion: Identifying when a new thought or argument begins
- Overlapping Windows: Small overlaps to preserve context between adjacent chunks
Implementation Guide
Step 1: Detect Sentence Boundaries
Use sentence boundary detection rather than simple period splitting. This handles abbreviations, decimal numbers, and other edge cases.
Why: Simple period/regex splitting fails on "Dr. Smith", "3.14", "U.S.A.", etc.
Step 2: Group Sentences into Semantic Units
Group sentences into chunks based on semantic cohesion rather than fixed counts.
Why: Similarity-based chunking adapts to document density - dense technical sections get smaller chunks, narrative sections get larger ones.
Step 3: Apply Structure-Based Chunking
Leverage document structure (headings, markdown, HTML tags) to identify natural sections.
Why: Document structure often encodes semantic boundaries (chapters, sections, subsections).
Step 4: Implement Adaptive Sizing
Adjust chunk sizes based on content characteristics (code blocks, lists, tables).
Why: Different content types need different chunking strategies for optimal retrieval.
For practical implementations, compare Sentence-BERT, LlamaIndex Semantic Chunker, LangChain RecursiveCharacterTextSplitter, and spaCy sentence segmentation.
When to Use This Skill
- Documents with clear semantic structure (articles, reports, documentation)
- When retrieval quality is more important than fixed-size guarantees
- For narrative or explanatory content where context matters
- When using semantic search (vector embeddings) for retrieval
- For Q&A systems that need coherent context for answers
When NOT to Use This Skill
- Code repositories where line-level precision matters
- Log files or structured data with fixed formats
- When you need exact token count guarantees (e.g., for API limits)
- Streaming data where chunk boundaries can't be deferred
- When using exact keyword matching (BM25) where chunk size matters less
Related Skills
- Hierarchical Chunking - For nested document structures
- Sliding Window Chunking - For overlapping context preservation
- Hybrid Search BM25 Dense - Combining search methods
Metrics & Success Criteria
- Retrieval Relevance: Retrieved chunks should contain complete, self-contained information
- Context Preservation: Related concepts remain in same chunk
- Coverage: No significant information lost in chunk boundaries
- Token Efficiency: Chunks balanced between too small (lossy) and too large (noisy)
- Semantic Coherence: Chunks represent coherent thoughts or sections
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

