Abstract
Machine learning (ML) prediction APIs are increasingly widely used. An ML API can change over time due to model updates or retraining. This presents a key challenge in the usage of the API because it is often not clear to the user if and how the ML model has changed. Model shifts can affect downstream application performance and also create oversight issues (e.g. if consistency is desired). In this paper, we initiate a systematic investigation of ML API shifts. We first quantify the performance shifts from 2020 to 2021 of popular ML APIs from Google, Microsoft, Amazon, and others on a variety of datasets. We identified significant model shifts in 12 out of 36 cases we investigated. Interestingly, we found several datasets where the API's predictions became significantly worse over time. This motivated us to formulate the API shift assessment problem at a more fine-grained level as estimating how the API model's confusion matrix changes over time when the data distribution is constant. Monitoring confusion matrix shifts using standard random sampling can require a large number of samples, which is expensive as each API call costs a fee. We propose a principled adaptive sampling algorithm, MASA, to efficiently estimate confusion matrix shifts. MASA can accurately estimate the confusion matrix shifts in commercial ML APIs using up to 90% fewer samples compared to random sampling. This work establishes ML API shifts as an important problem to study and provides a cost-effective approach to monitor such shifts.
Introduction
Modern developers increasingly rely on "ML-as-a-Service" (MLaaS) for tasks like sentiment analysis, facial recognition, and speech recognition. However, these third-party models are not static; providers frequently retrain or update them behind the scenes without versioning or notification. These "silent updates" can be disastrous for downstream applications. For instance, the authors found that the IBM speech API’s accuracy on a specific dataset dropped by 7% between 2020 and 2021, while Google's accuracy on the DIGIT dataset shifted by over 20%.
The Challenge of Monitoring Shifts
Simply monitoring overall accuracy is often insufficient. A model might maintain 90% accuracy but shift its errors from one class to another, which can break specific business logic or introduce new biases. To truly understand a shift, one must estimate the change in the model's confusion matrix.
The primary hurdle is cost. Querying commercial APIs costs money per call. Assessing a full confusion matrix through standard random sampling is prohibitively expensive for most users. In a systematic study of 36 API-dataset combinations, the researchers found significant shifts (>1% change) in 12 cases, proving that these models are far from stable.
MASA: Efficient Shift Estimation
The authors propose MASA (ML API Shift Assessment), a principled framework to estimate the difference between an old confusion matrix ($C^O$) and a new one ($C$) with minimal queries.
The core innovation is Uncertainty-aware Adaptive Sampling:
- Data Partitioning: MASA divides the dataset into "strata" based on true labels and "difficulty levels" determined by the confidence of a cheap, open-source proxy model.
- Adaptive Allocation: Instead of sampling uniformly, MASA uses an Upper Confidence Bound (UCB) approach. It prioritizes sampling from partitions where the model's performance is most uncertain or variable.
- Optimization: The algorithm aims to minimize the squared Frobenius norm error, measuring the distance between estimated and true shifts.
Key Results and Insights
MASA achieved the same estimation accuracy as uniform sampling while using over 50% fewer samples in most cases, and up to 90% fewer samples in some. By focusing on "informative" samples—those the model is likely to struggle with—MASA builds an accurate picture of new behavior much faster than random guessing.
In a case study on the Amazon YELP sentiment API, MASA estimated the shift with only a 0.1% difference from the true shift using just 2,000 samples. This efficiency represents a direct financial win for companies performing model audits, as each saved sample translates to lower API costs.
Conclusion
This work establishes ML API shifts as a critical problem for the AI ecosystem. Updates are not always upgrades; silent shifts can degrade performance or introduce new errors. MASA provides a cost-effective, principled approach to monitor these shifts, allowing developers to maintain oversight of the "black box" models they depend on.
Summary updated