Vibeleaderboard
← All Intel
Intel / article

Don't Mock Machine Learning Models In Unit Tests

Source
eugeneyan.com
Author
Eugene Yan
Date
Photo by Lily Li on Unsplash

Context

A test can pass while software misinterprets a 's prediction. Eugene Yan's testing essay describes the problem: replacing a model with a fabricated output can hide mistakes in how the maps output positions to class meanings.

The essay recommends keeping fast tests for ordinary processing logic while reserving selected checks for the actual model. Randomly initialized models can test structural properties such as output dimensions, but learned behavior requires learned weights. Small real-model checks can therefore catch a different category of failure from a mock, without requiring every unit test to load a large model.

Terms in this piece · Glossary
  • Model — A computational system that uses learned patterns to produce an output from information supplied to it.
  • Application — Software arranged so that a person can use it; in this course, the software around a model that accepts your request, prepares the context and shows the reply.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

Key quotes

“In software, we typically mock dependencies like APIs; in ML, we want to test the actual model (sometimes).”

Eugene Yan

“Google’s T5 NLI model classifies factual consistency with class = 1 while Meta’s BART NLI model classifies it with class = 2!”

Eugene Yan

“Don't Mock Machine Learning Models In Unit Tests”

Eugene Yan
Read the source eugeneyan.com
More from Eugene Yan
Recommended reads