How Did the Model Change? Efficiently Assessing Machine Learning API Shifts

Lingjiao Chen, Matei Zaharia, James ZouICLR 2022 · OpenReview

TL;DR

Commercial Machine Learning APIs (like those from Google and Amazon) update silently and frequently, often causing unexpected performance drops in downstream applications. This paper introduces MASA, an adaptive sampling framework that maps these "model shifts" by estimating changes in confusion matrices with up to 90% fewer API calls than standard methods.

The Challenge of Silent API Updates

Developers increasingly rely on "ML-as-a-Service" (MLaaS) for tasks like speech-to-text or sentiment analysis. However, these APIs are black boxes. Providers continuously update their underlying models to improve performance or incorporate new data, but these updates happen without notice.

Performance shifts across different ML APIs and datasets, highlighting the 7.1% drop in IBM's speech API accuracy.

A "silent update" might improve overall accuracy while simultaneously breaking a specific, critical use case. For example, the authors found that an IBM speech API update caused a 7.1% accuracy drop on a specific dataset because the new model began consistently mistaking certain words. If your application relies on that specific distinction, your system just broke, and you might not know why.

The challenge is that monitoring these shifts is expensive. Every query to a commercial API costs money. To build a full "confusion matrix" (a map of what the model gets right and exactly how it gets things wrong) using traditional random sampling requires thousands of costly queries.

MASA: Adaptive Sampling for Shift Assessment

The authors propose MASA (Model API Shift Assessment), a framework designed to estimate the difference between an old confusion matrix and a new one as efficiently as possible.

The core of MASA is Adaptive Stratified Sampling. Instead of querying the API with random data points, MASA:

  1. Partitions the data: It groups data by true labels and "difficulty levels" (using a cheap, open-source proxy model to guess which samples might be "hard").
  2. Calculates Uncertainty Scores: It identifies which groups have the most "uncertainty" (where the API's predictions are most diverse).
  3. Uses a UCB (Upper Confidence Bound) Strategy: Much like a multi-armed bandit problem, MASA balances "exploring" groups it hasn't sampled much and "exploiting" groups known to have high uncertainty.
  4. Iterative Updates: As it receives results from the API, it updates its uncertainty estimates and shifts its sampling strategy in real-time to focus on the most informative data points.

By focusing on the "hard" or "confusing" data, MASA can reconstruct the model's shift with far fewer queries than uniform sampling.

Datasets and Real-World Evaluation

The researchers conducted a massive systematic study of 36 API-dataset combinations across three primary tasks:

  • Sentiment Analysis: Using YELP, IMDB, WAIMAI, and SHOP datasets.
  • Facial Emotion Recognition: Using FER+, RAFDB, EXPW, and AFNET.
  • Speech Recognition: Using DIGIT, AMNIST, CMD, and FLUENT.

They evaluated APIs from major providers including Google, Microsoft, Amazon, IBM, Baidu, and Face++. As a contribution to the community, they released a dataset of 1,224,278 samples annotated by these APIs at different dates to help others study model drift.

Key Insights

  • API Shifts are Ubiquitous: In 33% of the cases studied, the API's performance changed by more than 1% on the exact same dataset over just one year.
  • Accuracy is a Blunt Instrument: A model’s overall accuracy might stay the same while its internal behavior shifts radically. MASA focuses on the confusion matrix difference, which reveals how the errors changed (e.g., "it's now confusing 'happy' with 'neutral' more often").
  • Uncertainty $\neq$ Error: A surprising "aha moment" in the paper is that high accuracy doesn't necessarily mean low uncertainty. A model can be 100% accurate but still have high uncertainty if its predicted labels are diverse across a partition. MASA uses this diversity to drive its sampling efficiency.
  • The "Hard" Data is the Key: To understand how a model has changed, you don't need to look at the easy samples the model always gets right. You need to look at the "borderline" cases where the model is most likely to flip its decision.

Results: Efficiency and Precision

  • Massive Cost Savings: To reach a 1% error threshold in shift estimation, MASA required 70% to 94% fewer samples than uniform or standard stratified sampling.
  • Higher Precision: Given the same fixed budget (e.g., 2,000 queries), MASA’s estimation error was often an order of magnitude smaller than standard approaches.
Confusion matrix shifts from 2020 to 2021 and MASA's superior shift estimation performance compared to uniform sampling.
  • Theoretical Guarantees: The authors proved that MASA’s estimation error converges at a rate of $O(N^{-5/4})$, which is faster than the $O(N^{-1})$ rate typically seen in standard sampling.

Limitations and Future Directions

The primary limitation is that MASA is currently optimized for classification tasks where confusion matrices are the standard metric. The authors acknowledge that more complex, generative APIs—such as OCR (Optical Character Recognition) or modern Large Language Models (LLMs) that produce free-form text—would require different metrics beyond simple confusion matrices.

Future work could involve extending this adaptive sampling logic to regression tasks or more complex structured outputs, as well as developing "anomaly detectors" that can automatically alert developers the moment a specific cell in the confusion matrix shifts beyond a tolerable threshold.

Summary updated

Abstract

ML prediction APIs from providers like Amazon and Google have made it simple to use ML in applications. A challenge for users is that such APIs continuously change over time as the providers update models, and changes can happen silently without users knowing. It is thus important to monitor when and how much the MLAPIs’ performance shifts. To provide detailed change assessment, we model MLAPI shifts as confusion matrix differences, and propose a principled algorithmic framework, MASA, to provably assess these shifts efficiently given a sample budget constraint.MASAemploys an upper-confidence bound based approach to adaptively determine on which data point to query the ML API to estimate shifts. Empirically, we observe significant ML API shifts from 2020 to 2021 among 12 out of 36 applications using commercial APIs from Google, Microsoft, Amazon, and other providers. These real-world shifts include both improvements and reductions in accuracy. Extensive experiments show that MASA can estimate such API shifts more accurately than standard approaches given the same budget
BibTeX
@inproceedings{chen2022how,
  author = {Lingjiao Chen and Matei Zaharia and James Zou},
  title = {{How Did the Model Change? Efficiently Assessing Machine Learning API Shifts}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=gFDFKC4gHL4},
}

Loading related content...

Figure