agentsclimarketplace

Semantic chunking

Skill Goodnight77/rag-skills/skills/chunking/semantic-chunking

Use semantic boundaries and embedding similarity to chunk text for higher-relevance retrieval.From its SKILL.md

Install
npx -y skills add Goodnight77/rag-skills --skill semantic-chunking

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 7 stars7 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.1 KB, as published. Nobody here has run it

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

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

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.