Skip to content
AI.info

ML data engineering

Data Engineering for Text, Images, Audio, and Sensors

Engineer modality-specific evidence, transformations, grouping, alignment, and monitoring for ML datasets.

By the end you can

Visual

Each modality has a different evidence boundary

An image does not tell you which way up it is in its pixels. It tells you in a tag beside them. Exif — the exchangeable image file format for digital still cameras, managed jointly by CIPA and JEITA since 2009, in version 3 since 2023 — calls that tag Orientation. Tag 274 (112.H), type SHORT, count 1, default 1, eight defined values covering every rotation and mirror. Value 1 is the ordinary one: “The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.”

That is the whole contract for orientation: one SHORT, eight legal values, sitting outside the pixel array. Two files can carry identical pixels and be two different pictures, because one of them carries tag 274 and the other lost it in transit. The raw object, its metadata and its derived representation have to travel together, and a single tag is enough to measure how far apart they have drifted.

Text, images and video, audio and speech, sensors and telemetry, and multimodal records each have their own version of that tag — the small piece of context, held beside the bytes rather than inside them, without which the bytes cannot be read correctly. Encoding, language, layout and document version do it for text. Capture device, compression, crop and annotation geometry for images and video. Sample rate, channel, codec and noise conditions for audio. Clock synchronization, calibration, units and device placement for sensors. Alignment and temporal tolerance for multimodal records.

FigureHierarchy · 5 levels
  • Text and documents

    Encoding, language, layout, redaction, segmentation, rights, and document version affect meaning.

    • Images and video

      Capture device, compression, crop, frame rate, annotation geometry, and provenance affect visibility.

      • Audio and speech

        Sample rate, channel, codec, segmentation, speaker consent, and noise conditions shape the signal.

        • Sensors and telemetry

          Clock synchronization, calibration, units, dropout, firmware, and device placement govern interpretation.

          • Multimodal records

            Alignment, missing modalities, paired identity, and temporal tolerance determine whether evidence belongs together.

A filename is not a sufficient contract for unstructured evidence.

Example

The bytes arrive successfully while the evidence changes

Unstructured pipelines often preserve files. They lose the context required to interpret them, and the loss is quiet, because decoding still succeeds and nothing raises an error.

  • A document OCR pipeline drops page rotation and reading order, corrupting table extraction. The rotation it dropped was a single Exif SHORT, tag 274, and every decoder downstream now assumes the default value 1.
  • A camera firmware update changes tone mapping, making historical image brightness incomparable.
  • An audio service resamples one channel incorrectly, altering spectral features without failing decoding.
  • Numbers can be perfectly valid and still be denominated in the wrong unit. The Mars Climate Orbiter was lost on 23 September 1999. Thruster impulse data had been delivered in pound-force-seconds where the interface specification required newton-seconds, every figure low by a factor of 4.45. NASA's investigation board reported on 10 November 1999: “The MCO MIB has determined that the root cause for the loss of the MCO spacecraft was the failure to use metric units in the coding of a ground software file, “Small Forces,” used in trajectory models.” The file was well formed and the numbers were in range. The orbiter arrived on a trajectory roughly 170 kilometres lower than planned, with an after-the-fact periapsis estimate of 57 km.
  • A multimodal dataset pairs a report with the latest image rather than the image available when the report was written.

Preserve raw evidence and derived artifacts under separate identities

A resized image, an OCR transcript, an audio embedding or a windowed sensor tensor is not the same artifact as its source. Each derived object depends on code, parameters, model versions, and sometimes on a step that does not run the same way twice. Store a stable source identity, content hash, provenance, transformation version, and the relationship between raw and derived forms. That is what lets you reprocess when a decoder, tokenizer or representation changes.

For sensitive data, “preserve raw” can conflict with minimization and retention duties. The policy then has to say which evidence is kept, which is protected, and which is irreversibly transformed. Medical imaging shows what stating it looks like in machine-readable form. The Cancer Imaging Archive applies the DICOM Basic Application Level Confidentiality Profile with five named options: Clean Pixel Data, Clean Descriptors, Retain Longitudinal With Modified Dates, Retain Patient Characteristics, Retain Safe Private. It then records every rule it applied inside the derived object itself, in Method Code Sequence (0012,0063). The derived image travels with a declaration of what was removed from it. The alternative is a promise held in a separate document that the next team will never read.

Derived representations accelerate learning; raw provenance makes them auditable.

Case

PIL and OpenCV disagree about what resizing means

Put one image through PIL's resize and through OpenCV's, and you get two different images. PIL implementations “adjust the antialiasing filter width by the downsampling factor”. The other libraries hold the filter width fixed, so implementations “using OpenCV, TensorFlow and PyTorch libraries with default flags, contain severe aliasing artifacts”. Parmar and colleagues ran that comparison in 2022. Then they priced it.

Downsample FFHQ from 1024 to 256, train identical StyleGAN2 models on the result, and the score depends on the resize function alone: FID 4.82 ± 0.09 with naive nearest, 5.08 ± 0.16 with TensorFlow bilinear, 5.13 ± 0.20 with PyTorch bilinear, 6.21 ± 0.23 with PIL bicubic. Same architecture, same source images, same training procedure. Only the resize function changed, and the score moved from 4.82 to 6.21.

The direction is not intuitive either. The paper's Figure 8 caption reports: “Interestingly, when training with JPEG-75 dataset images (left), applying lossy compression artifically improves the FID score by a large margin (4.00→3.48).” Degrading the data improved the number.

None of this is hidden. The “antialias flag is available in TensorFlow 2, but is set to False (default value) for the FID calculation”, and TensorFlow's own source still defines tf.image.resize with antialias=False. The choice was made once, by somebody else. Everyone who never opened the signature inherited it.

Comparison

Segmentation creates the examples the model will learn

The correct unit depends on the decision, not on what the file format happens to make easy. A whole document or recording preserves broad context but localizes badly. A chunk, frame or window supports detection and retrieval, but it creates correlated examples, and its boundaries change the labels. An event or region aligned to a detected span, box, speaker or sensor event gives precise supervision, but it depends on upstream detection and on geometry or time metadata being present.

The cost of getting the grouping wrong is not hypothetical. It has been measured on a benchmark everybody trusts. In 2020 Barz and Denzler checked CIFAR for near-duplicates, and their abstract says what they found: “We find that 3.3% and 10% of the images from the CIFAR-10 and CIFAR-100 test sets, respectively, have duplicates in the training set.” On that duplicated subset their ResNet-110 models made an error rate of 0% on CIFAR-10 and 2.9% on CIFAR-100. On the full test sets the same models made 5.3% and 26.1%. Nothing was memorized in a mysterious way: the model had seen those examples. Re-running on the duplicate-free ciFAIR test sets raised average error by 0.41 percentage points on CIFAR-10 and 2.73 points on CIFAR-100, a relative difference the paper puts as high as 12%.

That is what “unrealistically easy evaluation” costs when the duplicates are accidental copies of whole images. Chunks of one document, frames of one video, windows from one device, or utterances from one speaker are duplicates by construction. They are also far more numerous.

FigureComparison · 3 columns

Document or recording level

One example covers the entire source object.

  • Preserves broad context
  • Can exceed model limits
  • Weak localization
  • Useful for global classification

Chunk, frame, or window level

The source is divided into local segments.

  • Supports detection and retrieval
  • Boundary choices affect labels
  • Creates correlated examples
  • Needs source-group splitting

Event or region level

Examples are aligned to detected spans, boxes, speakers, or sensor events.

  • Precise supervision
  • Depends on upstream detection
  • Requires geometry or time metadata
  • Useful for structured outputs

Steps

Release a modality dataset with its capture context

Adapt the checklist to the modality rather than reducing it to generic row validation. Identify the source object first: content hash, producer, acquisition device, consent state, original timestamps. Everything else attaches to that stable identity.

Step 2, validate decoding, is where the small print lives — codec, shape, duration, channel, orientation, language, corrupted-object handling. “Orientation” here means one specific thing that can be checked mechanically. Exif defines it as tag 274 (112.H), type SHORT, count 1, default 1, with eight defined values. A validator can assert that the tag is present and legal. A pipeline that silently assumes the default is making a claim about the data it never tested.

Step 3 preserves the transformations: crop, normalization, segmentation, resampling, OCR and embedding logic, each versioned. As Parmar and colleagues measured, the resize function alone moved FID from 4.82 ± 0.09 to 6.21 ± 0.23 on one dataset.

Step 4 groups related samples, so that frames, chunks, speakers, patients or devices do not leak across splits. Omitting it is what Barz and Denzler quantified: 3.3% of CIFAR-10 and 10% of CIFAR-100 test images had duplicates in the training set, and on those the error rate was 0% and 2.9%. Step 5 inspects real artifacts across devices, conditions, languages and failure modes, because no aggregate statistic will show you a rotated page or a mis-resampled channel. Step 6 publishes the limitations: missing modalities, coverage, rights, and known acquisition shifts.

FigureProcess · 6 steps
  1. 1. Identify the source object

    Record content hash, producer, acquisition device, consent state, and original timestamps.

  2. 2. Validate decoding

    Check codec, shape, duration, channel, orientation, language, and corrupted-object handling.

  3. 3. Preserve transformations

    Version crop, normalization, segmentation, resampling, OCR, and embedding logic.

  4. 4. Group related samples

    Prevent frames, chunks, speakers, patients, or devices from leaking across splits.

  5. 5. Inspect real artifacts

    Review examples across devices, conditions, languages, and failure modes.

  6. 6. Publish limitations

    Document missing modalities, coverage, rights, and known acquisition shifts.

Key idea

A pretrained model’s processor is part of the data contract

Vision, audio and language models expect a particular tokenizer, resize policy, normalization, sample rate or special-token convention. Replace the processor and you can invalidate the learned representation, even when the tensor shapes still match.

Whisper states its audio contract in a single sentence. Its 2022 paper: “All audio is re-sampled to 16,000 Hz, and an 80-channel log-magnitude Mel spectrogram representation is computed on 25-millisecond windows with a stride of 10 milliseconds.”

That prose sentence is not the executable form of the contract. The executable form is a handful of integers. Hugging Face's WhisperFeatureExtractor defaults are sampling_rate=16000, n_fft=400, hop_length=160, feature_size=80 and chunk_length=30. A 400-sample analysis window and a 160-sample hop are, at 16,000 Hz, exactly the 25 ms window and 10 ms stride the paper describes. Then 80 Mel channels per frame, and a 30-second chunk. A pipeline matches all six or it is handing the model something the model never learned on.

The same paper fixes the scale and the coverage. Whisper was trained on 680,000 hours of audio, and section 1 says what is inside that number: “Of those 680,000 hours of audio, 117,000 hours cover 96 other languages.” A further 125,000 hours are X→en translation. Those figures are also a monitoring specification. “Language coverage” is not a vague concern for a model whose training distribution is documented to that resolution. It is a distribution you can compare your inbound audio against.

Version the preprocessing with the model and test it on preserved fixtures. For migrations, compare both low-level outputs and task behavior. Do not assume that a generic library default reproduces the processor used during pretraining.

The model and its input processor form one executable interface.

Figure

Whisper's stated preprocessing, drawn: 25 ms windows at a 10 ms stride overlap by 60%, giving 100 frames and 8,000 Mel values a second at 16,000 Hz.

Position

Every default in the pipeline was chosen by someone who never saw your task

There is a decision inside the resize call, and it is taken whether or not anybody makes it. Libraries disagree about what resizing means. PIL adjusts the antialiasing filter width by the downsampling factor, the others hold it fixed, and implementations “using OpenCV, TensorFlow and PyTorch libraries with default flags, contain severe aliasing artifacts”. Parmar and colleagues measured what the disagreement is worth. Identical StyleGAN2 models trained on FFHQ downsampled from 1024 to 256 score FID 4.82 ± 0.09, 5.08 ± 0.16, 5.13 ± 0.20 and 6.21 ± 0.23, depending only on whether the resize was naive nearest, TensorFlow bilinear, PyTorch bilinear or PIL bicubic. A paper reporting 4.82 and a paper reporting 6.21 may have done the same work. They differ in a line of setup code that neither of them printed.

The conclusion worth drawing is not that one library is right. It is that a default is a decision, taken by somebody solving a different problem and inherited in silence by everyone who does not override it. TensorFlow's source still defines tf.image.resize with antialias=False, and the FID calculation leaves it there. The resizing choice sits upstream of the score without ever appearing in it.

Whisper shows what stating the decision looks like instead: “All audio is re-sampled to 16,000 Hz, and an 80-channel log-magnitude Mel spectrogram representation is computed on 25-millisecond windows with a stride of 10 milliseconds.” One sentence in the paper, five named integers in the feature extractor, and any pipeline can be checked against it. Write the preprocessing contract down and version it beside the data. A disagreement between two libraries then becomes a reviewable choice rather than an accident nobody can see.

Preprocessing you did not choose is still preprocessing you shipped.

Analogy

Modality data needs a chain of custody

The source file is the evidence item. Each crop, transcript or embedding is a laboratory derivative. Chain of custody records who acquired it, how it was transformed, and which version informed a conclusion.

In medical imaging this is not a metaphor but a numbered standard. DICOM is published by NEMA in twenty-two numbered parts, and Annex E of PS3.15 defines a Basic Application Level Confidentiality Profile — the rules for producing a de-identified derivative of an image. The Cancer Imaging Archive applies that profile with five named options: Clean Pixel Data, Clean Descriptors, Retain Longitudinal With Modified Dates, Retain Patient Characteristics, Retain Safe Private. It records which of them it applied in Method Code Sequence (0012,0063) of the object it produced. The custody record ships inside the evidence.

The standard is also candid about what its own transformation does not reach. PS3.15 section E.2 states: “Unless the Clean Pixel Data Option or the Clean Recognizable Visual Features Option is specified, this Profile does not address information in the pixels.” Scrub every attribute in the header and a patient name burned into the image is still there.

That is the general shape of the problem. A derivative can be useful without preserving every detail of the source. But the analyst needs to know what information may have been lost, what may have been introduced, and what the cleaning step was never designed to touch. Training datasets aggregate millions of items and often permit statistical rather than case-by-case review. The principle of traceable transformation still applies.

Unstructured data becomes trustworthy when capture, transformation, and loss are visible.

Monitor acquisition conditions, not only embeddings

Embedding drift can reveal a change. It rarely explains whether the cause is device, codec, language mix, lighting, noise, content, or model behavior. How much of a representation is capture rather than content has been measured directly.

A pneumonia model trained on 158,323 chest radiographs from three institutions scored AUC 0.931 (95% CI 0.927–0.936) on the Mount Sinai and NIH data it was pooled from, and 0.815 (0.745–0.885) at Indiana University. Zech and colleagues published that in PLOS Medicine on 6 November 2018. Then they trained a network to do nothing but name the hospital a radiograph came from. It identified 22,050 of 22,062 NIH radiographs (99.95%) and 8,386 of 8,388 Mount Sinai radiographs (99.98%). Their author summary draws the consequence: “The performance of CNNs in diagnosing diseases on X-rays may reflect not only their ability to identify disease-specific imaging findings on X-rays but also their ability to exploit confounding information.”

The effect is not particular to radiographs. Biondetti and colleagues classified the scanner manufacturer of 782 head CTs at 98.11% ± 0.65 and 98.86% ± 1.25 test accuracy, with AUROC 0.99 ± 0.01. A network that reads the site off the pixels at 99.95% and the manufacturer at 98.11% is telling you that site and scanner are inside every embedding computed from those pixels. Change either one and the embedding distribution moves, before anything a monitor is watching does.

So preserve metadata about how the item was captured, and raw quality indicators. Monitor missing modalities, decode failures, duration and resolution distributions, device and firmware mix, language coverage, and alignment error. These signals support faster root-cause analysis. When privacy prevents retaining raw examples, maintain approved diagnostic samples or irreversible summaries that still expose system changes.

The fastest explanation of representation drift often lives in capture metadata.

Key takeaways