﻿# Prodigy before_db: reduce stored media without losing the example a reviewer saw

Use Prodigy before_db transformations with recoverable media references and preserved annotation meaning rather than silently rewriting reviewed examples.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-prodigy-before-db-media-provenance/
Language: en

## Identify the persistence transformation

A media annotation task can carry a large embedded image or audio payload into the database. The [Prodigy custom recipe guide](https://prodi.gy/docs/custom-recipes) provides `before_db` as a callback that can transform examples before persistence, including replacing embedded media with a reference. Treat that callback as a data transformation with a defined output contract. It changes what future exports retain, rather than merely changing how efficiently the current browser displays the task.

## Preserve a recoverable media reference

Before removing embedded bytes, establish which external object will reproduce the reviewed example. A local path meaningful on the annotation server may not resolve on the machine used for training or audit. Preserve the source identity, expected revision and required access route separately from credentials. The reference must continue to identify the same media, not whatever file happens to occupy a reused path when someone later reloads the annotation.

## Keep reviewed values intact

Avoid mixing media compaction with text cleanup, label remapping or other semantic edits. The [component reference](https://prodi.gy/docs/api-components) places the callback in the controller's persistence lifecycle. A transformed example can be accepted by storage even though it no longer represents what the reviewer judged. Use a separate, versioned postprocessing step for changes that alter training meaning so the original annotation and its derived representation can be compared independently.

## Read the persisted result back

The [database API](https://prodi.gy/docs/api-database) provides retrieval of stored examples. Test a representative transformation by reading the saved object and loading its media from the destination environment. Check the annotations against that reconstructed input, including a moved source file and an unavailable reference. An operation that makes the database smaller but leaves only an inaccessible path has shifted the storage problem rather than solved recoverability of the dataset.

## Record the boundary in the release

Retain the callback revision and the media-preservation policy with the annotation export. The guides on [content identity](/journal/data-guide-exact-hash-normalization-boundary/) and [removal lineage](/journal/data-guide-dataset-removal-lineage-tombstone/) explain related dependencies. Separate size reduction from any claim about data retention or privacy: an external media object may remain stored elsewhere. A useful release can explain both where the reviewed input lives and which transformation produced the compact annotation consumed by the next training step.
