Skill 3.1.5

Design and implement chunks for embeddings

Key Concepts

A chunk should hold one coherent idea and fit the model's token limit. Too-large chunks dilute meaning and waste prompt space in RAG; too-small chunks lose context. Overlap repeats part of the previous chunk so a sentence split at a boundary still appears whole in one chunk. Strategies include fixed-size chunks, splitting on sentences or paragraphs, and structure-aware splitting on headings.

AI_GENERATE_CHUNKS(SOURCE = text, CHUNK_TYPE = FIXED, CHUNK_SIZE = n, OVERLAP = pct, ENABLE_CHUNK_SET_ID = 1) is a table-valued function, used with CROSS APPLY, that returns chunk, chunk_order, chunk_offset, chunk_length and optionally chunk_set_id. CHUNK_SIZE is in characters, OVERLAP is a percentage from 0 to 50, and the function needs compatibility level 170. A chunk table stores the parent document's key, chunk order and text with the vector, so search results can be traced back to the document.