Chunking
Split documents into optimal chunks for RAG
Chunking splits documents into pieces for better retrieval.
Quick Start
- Create Agent with Chunked Knowledge
rust use praisonai::{Agent, Knowledge, ChunkingConfig}; // Configure chunking for knowledge base let knowledge = Knowledge::new() .source("docs/") .chunking(ChunkingConfig::semantic() .chunk_size(1000) .overlap(200)) .build()?; // Add documents - they'll be automatically chunked knowledge.add_file("guide.pdf").await?; // Create agent that uses chunked knowledge let agent = Agent::new() .name("Assistant") .instructions("You answer questions using the knowledge base") .build()?; // Search returns relevant chunks let chunks = knowledge.search("How do I get started?").await?;
Chunking Strategies
| Strategy | Best For |
|---|---|
Fixed | Code, technical docs |
Semantic | Articles, narratives |
Sentence | Q&A, FAQs |
Paragraph | Structured documents |
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
chunk_size | usize | 1000 | Characters per chunk |
chunk_overlap | usize | 200 | Overlap between chunks |
strategy | ChunkingStrategy | Semantic | How to split |