Vector Databases: Pinecone, Weaviate & pgvector · บทเรียน

กลยุทธ์การแบ่งส่วนสำหรับ RAG

เรียนรู้การแบ่งเอกสารเป็นส่วนที่มีประสิทธิภาพสำหรับการสร้างเวกเตอร์ฝัง เพื่อให้ระบบ RAG ดึงบริบทที่แม่นยำและเกี่ยวข้องได้

บทเรียน 4 จาก 413 ขั้นตอน

กลยุทธ์การแบ่งส่วนสำหรับ RAG เป็นบทเรียน Vector Databases: Pinecone, Weaviate & pgvector ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Vector Databases: Pinecone, Weaviate & pgvector และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Vector Databases: Pinecone, Weaviate & pgvector มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Chunking Matters

Before embedding, documents are split into chunks. Chunk quality directly determines retrieval quality — too large dilutes relevance, too small loses context.

Fixed-Size Chunking

The simplest method splits text every N characters or tokens. Fast but can cut sentences mid-thought.

def fixed_chunks(text, size=500):
    return [text[i:i+size] for i in range(0, len(text), size)]

Overlapping Windows

Add overlap between chunks so context spanning a boundary is not lost. A 10-20% overlap is common.

def overlap_chunks(text, size=500, overlap=100):
    step = size - overlap
    return [text[i:i+size] for i in range(0, len(text), step)]

Sentence-Aware Splitting

Split on sentence boundaries so each chunk stays grammatically whole. This usually improves embedding quality over raw character splits.

import re
sentences = re.split(r'(?<=[.!?])\s+', document_text)

Recursive Chunking

Recursive splitting tries large separators first (paragraphs), then smaller ones (sentences, words) until chunks fit the size limit. It respects natural structure.

Semantic Chunking

Semantic chunking groups sentences by meaning similarity, starting a new chunk when topic shifts. More expensive but very precise.

Chunk Size vs Model

Match chunk size to your embedding model's context window and your LLM's prompt budget.

  • Small chunks: precise but fragmented
  • Large chunks: rich but noisy

Keeping Metadata

Store source, page, and position metadata with each chunk so you can cite sources and reconstruct context later.

chunk = {
  'text': part,
  'source': 'guide.pdf',
  'page': 4,
  'position': idx
}

Parent-Child Chunks

Embed small child chunks for precise matching, but return their larger parent chunk to the LLM for full context. Best of both worlds.

Evaluating Chunking

Test different chunking configs with the same queries and measure retrieval hit rate. There is no universal best — measure for your data.

Practical Defaults

A solid starting point:

  • Recursive splitting
  • ~500 tokens per chunk
  • ~50-100 token overlap
  • Attach source metadata

Quick Check

Test your chunking knowledge.

Recap

You learned fixed, overlapping, sentence-aware, recursive, and semantic chunking, plus parent-child retrieval and metadata. Good chunking is the foundation of accurate RAG retrieval.

เริ่มต้นได้ฟรี

เรียนรู้ Vector Databases: Pinecone, Weaviate & pgvector ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

คำถามที่พบบ่อย

บทเรียน “กลยุทธ์การแบ่งส่วนสำหรับ RAG” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “กลยุทธ์การแบ่งส่วนสำหรับ RAG” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Vector Databases: Pinecone, Weaviate & pgvector ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Vector Databases: Pinecone, Weaviate & pgvector มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “กลยุทธ์การแบ่งส่วนสำหรับ RAG”

เรียนรู้การแบ่งเอกสารเป็นส่วนที่มีประสิทธิภาพสำหรับการสร้างเวกเตอร์ฝัง เพื่อให้ระบบ RAG ดึงบริบทที่แม่นยำและเกี่ยวข้องได้ คุณปฏิบัติ Vector Databases: Pinecone, Weaviate & pgvector ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Vector Databases: Pinecone, Weaviate & pgvector หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Vector Databases: Pinecone, Weaviate & pgvector บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “กลยุทธ์การแบ่งส่วนสำหรับ RAG” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Vector Databases: Pinecone, Weaviate & pgvector นี้ได้ไหม

ได้ บทเรียน Vector Databases: Pinecone, Weaviate & pgvector ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ภาพรวมสถาปัตยกรรมระบบ RAG
  2. การผสานเข้ากับกรอบการทำงาน LLM
  3. การค้นคืนข้อมูลตามบริบท
  4. กลยุทธ์การแบ่งส่วนสำหรับ RAG
← กลับไปที่ Vector Databases: Pinecone, Weaviate & pgvector