TECHNOLOGY

ZenML custom materializers: preserve embedding row identities through the save-load round trip

In this article
THE QUICK TAKE

A materializer defines a representation contract; a successful load is insufficient if row identities or interpretation changed during serialization.

The array loads but refers to different documents

A custom embedding bundle contains vectors and their document identifiers. Its materializer saves the vectors and later rebuilds identifiers from a separately sorted list. Loading succeeds and the array shape is correct, but the association between a vector and its document is broken. The round trip preserved values without preserving the full artifact meaning.

Specify the bundle as a unit. Document order, vector dtype, normalization convention and model identity all contribute to interpretation. A reconstructed Python object is only useful if these relationships survive the storage boundary.

Save and load are the representation contract

The materializer guide describes serialization, persistence and reconstruction through materializers. A custom implementation should write the information needed to restore the intended type and semantic relationships, rather than relying on ambient files in the consumer environment.

For the embedding bundle, store identifiers beside vectors in an unambiguous schema. If the representation changes, record its schema version and make unsupported versions explicit. Avoid silently assuming that a newly written loader understands every older artifact layout.

Storage access is a separate abstraction

The artifact-store guide explains the persistence layer and how materializers determine representation and storage behavior. Use the documented store interface so the implementation does not accidentally work only with a local filesystem path.

Test the same semantic contract with the storage backend the pipeline actually uses. Remote accessibility cannot repair reordered rows, and correct local reconstruction does not prove that every required file was written to the remote store.

Metadata helps inspection but does not replace payload

The metadata guide describes contextual information attached to artifacts. A row count and vector dimension make useful inspection fields, but they do not preserve the individual row-to-document mapping. That mapping belongs in the materialized representation itself.

Explicit Arrow feature contracts illustrate the distinction between physical values and interpretation. An embedding bundle needs an equally explicit account of identifier type, missing values and the correspondence between its components.

Verify meaning after reconstruction

Round-trip a small bundle with deliberately recognizable document identifiers and noninterchangeable vectors. Check association, order, dtype and the declared model reference after loading in a clean consumer context.

Compare with distributed shard overlap when bundles are combined. A materializer should preserve each bundle’s internal mapping, while aggregation must still establish that bundles do not duplicate or omit logical documents. Successful deserialization answers neither question automatically.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles