惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
博客园 - 司徒正美
D
Docker
T
The Blog of Author Tim Ferriss
罗磊的独立博客
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
J
Java Code Geeks
Jina AI
Jina AI
博客园 - 【当耐特】
C
Check Point Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
RAG - Chunking
Ramya Peruma · 2026-05-11 · via DEV Community

Ramya Perumal

What is chunking

Chunking is the process of breaking data into smaller pieces called chunks. Chunking happens before the data is fed into an embedding model, which converts each chunk into a vector (point) and stores the converted vectors in a vector database.

Why chunking Matters in RAG

Data can contain different types of context while still relating to the same topic.

From the above example, we may have a paragraph related to the Redis database that contains multiple contexts. An embedding model like nomic-embed-text converts the entire paragraph into a single vector point and stores it in the database.

This is where chunking plays a major role. Proper chunking helps retrieve only the most relevant information and avoids unrelated content.

For example, if a chunk contains information about both Python and Java, a query about Python may also retrieve Java-related information because both topics exist in the same chunk. Effective chunking helps prevent unrelated data from being retrieved.

Even an entire document can be stored as a single chunk. However, the purpose of chunking is to split the data into smaller meaningful sections so that only relevant data is retrieved for the user query while avoiding irrelevant information.

Chunking Method(Discrete way - formula methodology)

  • Fixed Chunking

Fixed chunking is the most common chunking method. In this approach, a fixed character or token limit is assigned to every chunk.

There is no single best chunking strategy for all datasets. Choosing the right chunk size usually requires a trial-and-error approach.

Disadvantage
A chunk may break in the middle of a sentence, resulting in incomplete context. This can reduce retrieval quality and may lead to irrelevant results.

Solution
One way to overcome this issue is to allow the chunk to continue until the sentence ends by checking for punctuation such as "." or spaces.

  • Overlapping chunking

In some cases, related information may be stored far apart in vector space due to the embedding model’s understanding. As a result, the LLM may miss relevant information during retrieval.

To overcome this issue, overlapping chunking is used.

In overlapping chunking, each chunk includes a portion of the previous chunk’s ending content. This helps the embedding model place related chunks closer together in the vector database.

The purpose of overlapping is to improve retrieval by making semantically related chunks easier to find.

Disadvantage

There is a possibility that irrelevant information may also be retrieved because of the overlap.

Example

Suppose:

Paragraph 1 is related to Topic A
Paragraph 2 is related to Topic B

If overlapping is applied, a query about Topic B may also retrieve some information from Topic A because part of Paragraph 1 overlaps with Paragraph 2.

In such scenarios, storing these chunks closer together may not be necessary. This is where semantic chunking becomes useful.

  • Semantic Chunking

Another scenario is when two paragraphs discuss the same topic but are not strongly related to each other. Normally, these paragraphs may still be stored nearby in the vector database. In such cases, overlapping chunking may not be necessary.

Semantic chunking solves this problem by grouping content based on meaning rather than fixed size.

In this method, each sentence is compared with the previous chunk using a similarity threshold value.

If the similarity score is below the threshold value, the sentence becomes a separate chunk.
If the similarity score is above the threshold value, it is added to the current chunk.

Libraries such as NLTK can be used to implement semantic chunking. The threshold value is configurable based on the use case.

  • Embedded Chunking

In embedding-based chunking, embedding models are used instead of libraries like NLTK.

This method works by calculating cosine similarity between sentences and grouping semantically similar sentences into chunks.

Advantage
Better semantic understanding
More accurate chunk boundaries

Disadvantage
Higher computational cost
Additional embedding model usage cost

Choosing the Right Chunking Method

Choosing a chunking method always involves trade-offs. There is no single chunking strategy that works for all datasets.

The best chunking method depends on:

Dataset type
Cost
Time
Retrieval accuracy requirements
Embedding model behavior

Different applications may require different chunking strategies to achieve the best RAG performance.