Chunk¶
New in v2.0
- class Chunk¶
A finalized, retrieval-ready portion of a document, returned as an item in
ChunkedDocument. Treat chunks returned byDocument.to_chunks()as read-only. Mutatingtextormetadataafter readingcontent_hashcan leave that cached hash, and caches on the owningChunkedDocument, out of date. To change chunk boundaries, useChunkedDocument.reassemble_chunks(); keep application-specific data separately, keyed by the chunk id.- id¶
The chunk id, formatted as
c{n}, wherenis its position in thisChunkedDocument. Chunk ids are local to the result and may change when chunks are reassembled with different parameters.
- text¶
The chunk’s Markdown text, rendered from its layout content.
- tagged_content¶
Context-enriched text for embedding. It includes the chunk’s section path, page, and non-paragraph content types where available, followed by its Markdown text. This is separate from
textand is included by default inChunkedDocument.to_dicts()andChunkedDocument.to_json().
- metadata¶
A ChunkMetadata instance containing page, layout, structure, token-count, and provenance information for this chunk.
- content_hash¶
A lazily computed SHA-256 hash of
textafter runs of whitespace have been collapsed to one space and leading and trailing whitespace has been removed. The hash is cached. It is stable across rendering-only whitespace changes, but changes when the normalized text changes.
