Chunks — AI-Powered Intelligent Chunking System

On this page

Production-Grade RAG Chunking Library for Arabic, multilingual, and English text.


What is Chunks?

Chunks is a production-ready Python library that splits documents into optimally-sized, semantically coherent pieces (chunks) for use in Retrieval-Augmented Generation (RAG) pipelines, vector databases, and LLM applications.

It provides:

  • Six specialized chunking strategies (semantic, adaptive, structural, contextual, Arabic, multilingual)
  • A unified orchestrator (ChunkManager) that selects the right strategy automatically
  • Rich metadata on every chunk (keywords, importance score, position, character offsets)
  • Built-in deduplication (hash-based and similarity-based)
  • First-class Arabic NLP support with normalization pipeline
  • LangChain-compatible text splitters
  • Zero mandatory dependencies for rule-based mode; optional sentence-transformers, torch, transformers, tiktoken, beautifulsoup4 for advanced features

Quick Example

Python · 7 lines
from zerda.chunks import SemanticChunker, ChunkConfig

config = ChunkConfig(chunk_size=512, overlap=128)
chunker = SemanticChunker(config=config)

text = "Your document text goes here..."
chunks = chunker.chunk(text, doc_id="",source="my_doc.pdf")


SectionDescription
InstallationHow to install and set up the library
QuickstartGet up and running in five minutes
ArchitectureSystem design and component relationships
ConfigurationAll ChunkConfig options documented
API OverviewComplete public API surface
TutorialsStep-by-step guides from beginner to advanced
CookbookProduction recipes and patterns
FAQCommon questions and answers
TroubleshootingDiagnosing common problems

Class Reference

ClassModulePurpose
ChunkConfigchunksConfiguration dataclass
SemanticChunkerchunksEmbedding-based semantic splitting
AdaptiveChunkerchunksDensity-aware dynamic sizing
StructureAwareChunkerchunksMarkdown/HTML structure-respecting
ContextAwareChunkerchunksSliding-window context preservation
ArabicTextChunkerchunksSpecialized Arabic NLP chunker
MultilanguageTextChunkerchunks17-language auto-detecting chunker
ArabicNormalizerchunksArabic text normalization pipeline
NormalizingChunkerWrapperchunksWraps any chunker with normalization
EmbeddingProviderchunksCached sentence embeddings
MetadataEnricherchunksKeywords, scores, enrichment
DeduplicatorchunksHash and similarity dedup
DocumentStructureParserchunksMarkdown/HTML/plain parser
QueryPatternAnalyzerchunksQuery-driven strategy selection
DocumentChunkchunksCore chunk data model
DocumentchunksInput document model
ChunkMetadatachunksPer-chunk metadata
ChunkTypechunksChunk type enum
DocumentTypechunksDocument type enum
ChunkModechunksOrchestrator mode enum
BaseChunkerchunksAbstract chunker base
TextSplitterchunksAbstract splitter base
CharacterTextSplitterchunksCharacter/separator splitter
RecursiveCharacterTextSplitterchunksHierarchical recursive splitter
TokenTextSplitterchunksToken-count splitter (tiktoken)
SentenceTextSplitterchunksSentence-boundary splitter
StructuredSectionchunksParser output section
NormalizerConfigchunksNormalization toggle config

Design Philosophy

  1. Correctness first — Every chunk preserves meaning. No mid-sentence cuts.
  2. Strategy diversity — Different documents need different strategies; the library exposes all of them.
  3. Arabic-first multilingual — Arabic is a first-class language, not an afterthought.
  4. Composable pipeline — Each component can be used standalone or orchestrated by ChunkManager.
  5. Graceful degradation — Heavy dependencies (torch, transformers) are optional; the library falls back to rule-based modes automatically.