Skip to main content
A Document represents a piece of text content along with its metadata, source information, and optional embedding vector. Documents are the fundamental unit that flows through the entire RAG pipeline.

Creating Documents

Document Fields

Generating Embeddings

Embed a document manually using any embedder:
When using the Knowledge class, embedding is handled automatically during add(). You only need to embed manually if you are working with documents directly.

Serialization

Convert documents to and from dictionaries for storage or transmission:

Metadata and Filtering

Attach metadata to documents for filtering during search:

Chunked Documents

When a large document is chunked, each chunk is a separate Document with chunk tracking:
This lets you reconstruct the original document order or display chunk context to users.