Urgent.News

What's breaking now, across hundreds of outlets.

AI

When we chop a document into chunks, doesn't the LLM lose the big picture?

If we split a large document into smaller chunks, how does the LLM understand the complete context? Doesn't it lose the connection between different parts of the document? Let's understand this with a simple example. 1. Why do we split documents? Imagine we have a company policy document containing 100 pages. A user asks: "How many days of leave can I carry forward?" Instead of sending all 100…

When dividing a lengthy document into smaller segments, does the language model lose sight of the broader context? Does it fail to see the relationships between different parts? Let's explore this concept through a straightforward example.

Why do we divide documents? Consider a policy manual spanning 100 pages. A user inquires: "How many days of leave can I carry over?" Rather than sending the entire document to the LLM, Retrieval-Augmented Generation (RAG) breaks it into smaller units known as chunks. This approach conserves computational resources, lowers costs, and enables retrieval of only the pertinent information.

However, a challenge arises. The original document includes:

Chunk 1: "Employees are entitled to 20 days of paid leave annually. Unused leave can be carried forward to the subsequent year."

Chunk 2: "Nevertheless, the maximum accumulated leave balance cannot surpass 30 days."

Now picture a scenario where vector search only returns Chunk 2 upon receiving the user's question: "What is the maximum leave balance I can accumulate?" While RAG successfully finds the correct information—the 30-day limit—it may not fully grasp the context. The LLM receives the leave restriction but might not comprehend the specific type of leave this refers to. The relevant information has been located, yet some context has been potentially lost.

How can we address this issue? There are several strategies:

1. Overlapping chunks: Slightly overlap text between adjacent chunks. For instance, repeat the concluding sentence of Chunk 1 at the beginning of Chunk 2. This preserves the connection between them and helps maintain context.

2. Retrieve multiple chunks: Instead of returning a single matching chunk, provide the top 3 or 5 relevant chunks. The LLM gains additional context from these multiple sources, allowing it to connect information across different sections of the document.

3. Store metadata: Accompany each chunk with metadata such as document name, page number, section title, and chunk number. This additional information enables us to identify related chunks and retrieve supplementary context when necessary.

In conclusion, while chunking documents significantly enhances efficiency and affordability in searching vast texts, neglecting context can result in incomplete or inaccurate responses. The objective isn't merely to identify the correct chunk; it's to furnish enough related information so the LLM can grasp the complete picture.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in AI

The cute AI animals your children imitate are carrying messages meant for adults

Every time I open TikTok, I meet the monkeys. They are cartoon monkeys, made with AI tools, and they speak my Sudanese dialect badly. Whoever makes them clearly doesn't know the dialect.

  • Cute AI animals mimic Sudanese dialects and customs, appealing to children.
  • Some content is sexually explicit while others mock tribal groups.
  • Trend spread globally, with 354 TikTok accounts and 43,000 AI videos viewed 4.5 billion times.

Two editors, one file: how an AI agent edits a project the user has open

Part 6 of a series on Movie Engine, where an AI agent edits Kdenlive video projects while the editor stays open. Earlier parts: 1, overview , 2, UI Automation without stealing focus , 3, menu names…

  • Kdenlive lacks automation API for AI editing
  • Movie Engine enables AI to edit projects safely
  • Lock and check system preserves user edits

More from Wednesday 25 November →