The Real Fullstack

The Broken Chunking Strategy

The policy document is indexed. Why does the assistant quote eligibility rules that stop mid-sentence?

مهندس8 دقيقةمختبر تصحيح الأخطاءمحاكي الخط الزمني
ragembeddingspythonmarkdown

لم يُترجم هذا التحدي إلى العربية بعد. أنت تقرأ النسخة الإنجليزية.

المهمة:Chunk the document so every key passage fits inside one chunk, while the top-3 chunks stay within 1,600 tokens.السياق · أهداف التعلّم ▾

Tallow Cloud indexes a 6,000-token refund policy with fixed 512-token chunks. The eligibility rules start just before a chunk boundary, so retrieval returns half a rule list. Someone suggested 2,048-token chunks; then every answer costs a fortune and contains three unrelated sections.

المهمة: Chunk the document so every key passage fits inside one chunk, while the top-3 chunks stay within 1,600 tokens.

أهداف التعلّم

  • See how chunk boundaries break facts.
  • Use structure-aware splitting and overlap.
  • Balance chunk size against precision and cost.
المحاكاةمحاكاة
facts
1definitions (tokens 120–340) fits in one chunk
2refund table (tokens 2150–2530) fits in one chunk
3eligibility rules (tokens 3350–3700) split across chunks
تشغيل المحاكاة
splitter = MarkdownHeaderTextSplitter(headers_to_split_on=[("#", "h1"), ("##", "h2")])sections = splitter.split_text(policy_markdown)                         # never cut across sectionschunks = RecursiveCharacterTextSplitter(chunk_size=512, chunk_overlap=0).split_documents(sections)for c in chunks:    c.metadata["breadcrumb"] = " > ".join(c.metadata.values())   # keep the section title with every chunk

تبسيط

Facts are fixed token ranges; retrieval always returns the chunk containing a fact if one exists. نموذج تعليمي — الأرقام توضّح سلوكًا وليست قياسات أداء.

المفاهيم

مفيد قبل هذا التحدي

تحديات ذات صلة

المراجع