/ RAG Basics
Chunking - Chia tài liệu thế nào cho đúng
So sánh fixed-size, recursive và structure-aware chunking, cùng ảnh hưởng của kích thước và overlap tới retrieval.A comparison of fixed-size, recursive, and structure-aware chunking and how size and overlap affect retrieval.
Nguồn tham khảo: Phạm Thành Thái - AI Guru x TiniXReference source: Phạm Thành Thái - AI Guru x TiniX
Tổng quan
Tài liệu xem chunking là bước quyết định đơn vị thông tin mà hệ thống RAG có thể tìm lại. Bài thực hành so sánh ba chiến lược trên cùng dữ liệu, giải thích tokenization, chunk size, overlap, metadata và mở rộng sang semantic cùng parent-child chunking.
Điểm chính
- Không có một chiến lược chunking tối ưu cho mọi loại tài liệu.
- Recursive chunking giữ cấu trúc tự nhiên tốt hơn fixed-size trong nhiều văn bản hỗn hợp.
- Structure-aware chunking phù hợp Markdown, HTML và tài liệu pháp lý khi heading cần được giữ làm metadata.
- Đánh giá phải dùng truy vấn thật và metric retrieval thay vì chỉ nhìn độ dài chunk.
Ghi chú của mình
Mình sẽ coi chunking là một giả thuyết cần đo bằng bộ câu hỏi, không phải một hằng số cấu hình đặt một lần.
Overview
The document treats chunking as the decision that defines what unit of information a RAG system can retrieve. Its exercise compares three strategies on the same data, covers tokenization, chunk size, overlap, and metadata, then introduces semantic and parent-child approaches.
Key points
- No single chunking strategy is optimal for every document type.
- Recursive chunking often preserves natural boundaries better than fixed-size splitting.
- Structure-aware splitting suits Markdown, HTML, and legal documents where headings should remain metadata.
- Evaluate with representative queries and retrieval metrics rather than chunk length alone.
My notes
I will treat chunking as a hypothesis to test against questions, not a one-time configuration constant.