Introduction
Programming-by-Example (PBE) systems, such as Excel's Flash Fill, have revolutionized how non-programmers handle data. However, these systems often struggle with ambiguity—the state where a single user example can be explained by thousands of different underlying programs. Traditional PBE systems rely on a "syntactic bias," preferring the shortest or simplest code. This paper introduces a machine learning approach that looks beyond code structure to analyze outputs and execution traces, significantly improving accuracy in complex string transformation and text extraction tasks.
The Challenge of Ambiguity
The fundamental hurdle in PBE is that a single example is rarely enough to specify a unique intent. For instance, if a user extracts "1993" from a string containing multiple numbers, the system must decide if the rule is "the last four digits," "the first number after a comma," or specifically a "year."
While traditional systems might pick the simplest program (e.g., "extract the first number"), that program often fails on subsequent rows. To resolve this, the authors propose leveraging the abundance of unlabeled data typically found in spreadsheets to rank candidate programs more intelligently.
Methodology: Beyond Syntax
The authors integrated their approach into PROSE, a Microsoft framework for PBE. Their method ranks a "frontier" of the top $K$ programs consistent with user examples using three distinct feature sets:
- Output Features (The "Smoothness" Bias): The system analyzes what a program predicts for unlabeled rows. Using an unsupervised clustering technique (Chinese Restaurant Process), it builds a descriptor of the output. A program is preferred if its outputs follow a consistent, recognizable pattern (like
FirstNameorDigits) without outliers. - Execution Trace Features: The model examines the internal logic of the program. For example, a program that extracts overlapping parts of the same input string to construct an output is flagged as "pathological" and down-ranked.
- Program Structure Features: Traditional syntactic features, such as the count of specific code primitives, are still utilized but are treated as just one component of a broader discriminative probabilistic model.
This model is trained to maximize the expected number of correct problems solved, requiring only final desired outputs for training rather than manually annotated ground-truth programs.
Evaluation and Results
The system was evaluated on two major benchmarks: String Transformation (447 problems from Excel and PowerShell users) and Text Extraction (488 problems involving log files). These datasets represent real-world "messy" data where users typically provide only one to three examples.
The combined model outperformed the standard PROSE implementation across the board:
- String Transformation: Accuracy rose from 76.4% to 83.5%.
- Text Extraction: Accuracy rose from 65.8% to 69.2%.
Crucially, the system excelled at the "holy grail" of PBE: reaching the correct result from just a single example. Despite the added complexity of analyzing outputs and traces, the system remains efficient, with descriptor computation taking approximately 1 second and program enumeration taking 2–3 seconds.
Conclusion
By shifting the focus from how a program is written to what it actually computes, the authors have created a more robust PBE system. This "output-based" bias allows the system to use unlabeled data to verify its logic, making it far more effective at resolving ambiguity in real-world data tasks. Future work may involve incorporating deeper world knowledge and using these biases to guide the initial program search rather than just ranking the results.
Summary updated