Introduction
Data labeling remains a primary bottleneck in supervised learning. While Large Language Models (LLMs) like GPT-4 can act as zero-shot annotators, their use at scale is often prohibitively expensive, inflexible, and lacks auditability. Alchemist addresses these challenges by shifting the paradigm from "distilling a model into labels" to distilling a model into code. By tasking LLMs to generate labeling programs rather than direct annotations, Alchemist achieves a 500x lower cost and a 12.9% average performance boost over direct LLM annotation.
Methodology
The Alchemist system operates through a four-stage pipeline designed to leverage the logical reasoning of LLMs while maintaining the efficiency of local execution.
- Prompting for Programs: Users provide task descriptions and labeling instructions. The LLM generates multiple Python functions (labeling programs) using logic such as regular expressions or keyword matching.
- Local Execution: These programs are executed locally on the unlabeled dataset. This allows for processing millions of records without incurring additional API costs.
- Weak Supervision: To manage noise or bias in LLM-generated code, Alchemist utilizes the Snorkel framework. It treats programs as "labeling functions," learns their reliability, and aggregates outputs into high-confidence "pseudolabels."
- Model Distillation: A smaller, specialized model (e.g., an MLP) is trained on these pseudolabels, resulting in a fast, private, and generalizable final model.
Handling Multi-modal Data
For non-text data like images, Alchemist employs a "concept-based" approach. The LLM identifies visual primitives (e.g., "paddling feet" vs. "toed feet"), and an open-source model like CLIP generates similarity scores for these concepts. The generated Python programs then use these scores as inputs for classification.
Evaluation and Results
The system was evaluated across text classification (YouTube, SMS, Yelp, IMDb), domain-specific text (medical, financial), computer vision (Waterbirds), and other modalities (ECG, Census).
Key results include:
- Cost Efficiency: For the "Cancer" dataset, costs dropped from $1,200 (GPT-4 direct labeling) to just $0.70 with Alchemist—a 1,700x reduction.
- Performance: Alchemist outperformed zero-shot LLM prompting on the majority of text datasets, with an average accuracy improvement of 12.9%.
- Scalability: Performance generally improves or stabilizes as more programs are collected, allowing the system to scale with logic rather than data volume.
Discussion
Alchemist transforms the "black box" of LLM annotation into a transparent, editable "white box." Because the annotators are Python functions, they provide a clear audit trail that human developers can verify and fix. Furthermore, by forcing models to reason about high-level concepts, the system demonstrates increased robustness against spurious correlations, such as background-based shortcuts in image classification.
While the system is limited by the LLM's coding capabilities and potential inherent biases, it represents a significant step toward making high-quality data labeling accessible and affordable at scale. Future iterations may include automated feedback loops to iteratively refine generated programs based on validation performance.
Summary updated