A Generative AI Engineer is indexing a help center exported as HTML. Every article uses <h2> and <h3> elements for its sections. The team wants each chunk to stay inside one section and to carry the section titles as metadata so answers can cite them. Which approach should the engineer use to split the pages?
Choose one.
Structure-aware splitters split on a document's own headings and keep those headings as chunk metadata.
The requirement has two parts: chunks bounded by sections, and section titles kept as metadata. HTMLHeaderTextSplitter does both for HTML. Flattening with get_text() loses the structure, the HTML language preset ignores which section a chunk sits in, and the Markdown splitter expects # markers rather than heading elements.
- Identify the source format (HTML with heading elements).
- Note both requirements: section-bounded chunks and header metadata.
- Pick the splitter that understands that format's headers and records them.
Exam tip: Match the splitter to the format: HTML headings use HTMLHeaderTextSplitter, Markdown headings use MarkdownHeaderTextSplitter.
Databricks GenAI Engineer: Document Extraction, Filtering and Chunking into Delta Tables — the lesson that teaches this.