TL;DR
This paper introduces Vamsa, an automated system that tracks which columns in a dataset are used to train machine learning models directly from Python scripts. This is crucial for debugging, ensuring fairness, and maintaining compliance in increasingly complex ML workflows.
What Problem Does This Paper Address?
As machine learning (ML) models become more prevalent in critical domains like finance and healthcare, understanding their behavior and ensuring their fairness and reliability is paramount. A key aspect of this is knowing exactly what data went into training a model. This "data provenance" is essential for debugging, explaining model decisions, and meeting regulatory requirements. However, current ML pipelines, often written in Python, make it difficult to automatically track this information. Data scientists typically don't explicitly log this provenance, and manual tracking is time-consuming and error-prone. Existing tools like MLflow and Kubeflow help manage ML pipelines but don't automatically link model outputs back to specific data columns. Vamsa aims to fill this gap by providing an automated solution that works without requiring any changes to existing Python scripts.
Methods
Vamsa employs a three-module architecture for automated ML provenance tracking:
- Derivation Extractor: This module performs static analysis on Python scripts to build a "workflow intermediate representation" (WIR). This WIR captures the dependencies between imported libraries, variables, functions, and their operations, essentially creating a program graph.
- KB-Based Annotator: This module enriches the WIR with semantic information. It uses a knowledge base (KB) containing details about ML libraries and their APIs (inputs, outputs, roles). When it encounters an ML operation (like
fitortrain_test_split), it queries the KB to identify variables as models, features, or labels. This module is designed to be extensible to new ML libraries by simply updating the KB. - Provenance Tracker: This module takes the annotated WIR and, using the KB, identifies the specific columns from the original dataset that were used to derive the features and labels for each ML model. It handles both column inclusion (columns used) and exclusion (columns explicitly dropped) and uses a guided traversal mechanism to trace data flow through various operations.
A key design principle is to support unmodified Python scripts, avoiding any need for user input or code changes.
Datasets
The paper uses two primary datasets for evaluation:
- Kaggle Dataset: A collection of 26K Python scripts downloaded from Kaggle.
- NTBK Dataset: A corpus of 24.8K Python notebooks crawled from GitHub.
These datasets were filtered to include scripts that import libraries, are syntactically correct, compatible with Python 3, and contain common ML framework calls (like fit). For accuracy evaluation, a smaller subset of 150 scripts from each dataset was manually labeled to create a ground truth.
Key Insights and Ideas
- Automated Provenance is Feasible: The core insight is that static analysis, combined with a well-curated knowledge base of ML APIs, can effectively automate the challenging task of tracking data provenance in complex Python scripts.
- Modularity and Extensibility are Key: Vamsa's design, separating the core logic from library-specific details via a knowledge base, is crucial for its adaptability to the rapidly evolving ML landscape. This allows Vamsa to support new libraries without code modifications.
- Column-Level Granularity is Achievable: The system goes beyond just identifying which files were used, pinpointing the exact columns that contribute to model features and labels, which is critical for fine-grained analysis.
- Static Analysis Suffices for Many Cases: While loops and conditionals can introduce undecidability, the paper argues that their presence in typical data science scripts is minimal, making static analysis a practical and effective approach for most scenarios.
Key Results
- High Accuracy: Vamsa achieves high precision and recall, ranging from 90.4% to 99.1% on labeled datasets for feature and label inclusion/exclusion. Model identification is particularly accurate (100%).
- Efficient Performance: The system operates with low latency, typically in the order of milliseconds for average-sized scripts. The breakdown shows that Derivation Extraction and WIR composition take the most time, but remain efficient.
- Broad Coverage: Vamsa demonstrates good coverage across large corpora, with the Derivation Extractor successfully processing most scripts. The KB-based Annotator and Provenance Tracker also achieve significant coverage (e.g., 91.88% for model annotation on Kaggle).
- Real-World Utility: A case study highlights Vamsa's ability to quickly identify models affected by data corruption issues in a production environment, significantly reducing debugging time.
Limitations and Future Work
- Undecidability: The paper acknowledges that static analysis has inherent limitations with control flow constructs like loops and conditionals, which can make provenance tracking undecidable.
- Knowledge Base Population: While the KB is designed for extensibility, its initial population is manual.
- Specific Python Constructs: Vamsa's current implementation does not cover certain Python grammar constructs like
DictComp,SetComp, andJoinedStr. - Runtime Information: The authors suggest incorporating runtime information as a future direction to handle cases that are undecidable with static analysis.
- Finer-Grained Provenance: Exploring provenance at a more granular level (e.g., specific data partitions) is another avenue for future work.
- Automated KB Population: Developing methods for automatically populating the knowledge base is a key area for future research.
Summary updated