Abstract
Modern machine learning faces a persistent trade-off between the high performance of "black-box" neural networks and the interpretability of "white-box" classical models. We present LeaPR (Learned Programmatic Representations), a framework that bridges this gap by leveraging Large Language Models (LLMs) to automate feature engineering. LeaPR generates human-readable Python code for features that are subsequently utilized by decision tree predictors. Our results across chess, image classification, and text detection demonstrate that LeaPR models can match or exceed the performance of deep neural networks while remaining fully transparent and debuggable.
Introduction: The Interpretability-Performance Trade-off
In the current AI landscape, practitioners often must choose between two extremes. Classical models, such as decision trees, offer clear logic but typically require extensive manual feature engineering to handle complex, high-dimensional data like images or text. Conversely, deep neural networks (DNNs) excel at learning features automatically but operate as opaque "black boxes," making their internal reasoning nearly impossible for humans to audit. Furthermore, DNNs are computationally intensive and data-hungry.
The LeaPR framework addresses this challenge by asking: Can we use the domain knowledge and coding proficiency of LLMs to automate the creation of interpretable features?
Methods: The LeaPR Framework
The researchers developed two primary algorithms to construct LeaPR models, both of which utilize LLMs to bridge raw data and structured prediction.
1. Features FunSearch (F2)
F2 is a global optimization approach. An LLM iteratively proposes Python functions that compute specific features from input data. These features are evaluated by training a Random Forest; the resulting "feature importance" scores are then fed back to the LLM. This evolutionary loop allows the system to refine its programmatic representations over time, focusing on the most predictive code snippets.
2. Dynamic ID3 (D-ID3)
D-ID3 is a local, on-demand approach that integrates feature generation directly into the tree-building process. As a decision tree grows, it may reach a point where existing features cannot adequately split a group of examples. At these "leaf" nodes, D-ID3 queries an LLM to write a custom feature tailored to distinguish between the remaining data points. The LLM is provided with the decision path and specific examples to guide its "brainstorming" process.
Key Insights: Transparency by Construction
Unlike "post-hoc" interpretability methods that attempt to explain a neural network after training, LeaPR models are interpretable by design. Every decision split in the model corresponds to a human-readable Python function.
- LLMs as Domain Experts: LeaPR taps into the vast prior knowledge of LLMs regarding specialized fields (e.g., chess theory) and technical libraries (e.g.,
numpyorchess.py). - Debugging and Auditing: Because the features are code, developers can directly inspect why a model failed. In a case study involving the Waterbird dataset, researchers used SHAP values to identify that the model was relying on "background color" features written by the LLM, allowing for immediate identification of spurious correlations.
Experimental Results
The efficacy of LeaPR was tested across three distinct domains:
- Chess Position Evaluation: LeaPR models trained on 200,000 positions were competitive with a 270-million parameter Transformer trained on 50 million positions (250x more data). In move prediction, D-ID3 + GPT-5-mini achieved 33.5% accuracy, surpassing the Transformer baseline of 30.3%.
- Text Classification: On the Ghostbuster dataset (detecting AI-generated text), LeaPR achieved an F1 score of 98.8%, nearly matching the state-of-the-art neural model (99.0%) without requiring a neural predictor.
- Image Classification: On MNIST, LeaPR reached 96.91% accuracy. While slightly below specialized ResNets, it achieved this through interpretable pixel-analysis code rather than opaque weight matrices.
Limitations and Future Directions
While promising, LeaPR faces several hurdles. Currently, it lacks feature hierarchy; it does not yet build complex features on top of simpler ones, a key advantage of deep learning. Additionally, the programmatic search process is computationally more expensive than standard gradient descent. Finally, while LLMs are excellent at writing code, their ability to "conceptualize" features for complex visual data without direct pixel-level perception remains a bottleneck. Future research will focus on developing "deep" programmatic hierarchies and improving search efficiency.
Summary updated