NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Generating Pragmatic Examples to Train Neural Program Synthesizers

Saujas Vaduguru, Daniel Fried, Yewen Pu

TL;DR

PRAX is a novel training framework that teaches neural program synthesizers to resolve ambiguity by training them on "pragmatic" (highly informative) examples. By using self-play and the Rational Speech Acts (RSA) framework to generate synthetic training data, PRAX achieves human-level performance in regular expression synthesis without requiring any human-labeled data for training.

What Problem Does This Paper Address?

Programming-by-example (PBE) allows users to create software by simply providing input-output pairs (e.g., showing a system that abc should match a pattern while 123 should not). However, a few examples are almost always an "under-specification" of what the user actually wants.

For instance, if a user provides the example (ab, ✓) to describe a regular expression, a "literal" synthesizer might suggest a+b* (one or more 'a's followed by 'b's) or it might suggest a*b+c? (any 'a's followed by one or more 'b's and an optional 'c'). Both are technically correct based on the example, but they represent very different intents.

Previous research used a framework called Rational Speech Acts (RSA) to solve this. RSA treats synthesis as a cooperative game: the user (the "Speaker") chooses examples they think will be most helpful, and the synthesizer (the "Listener") assumes the user is being helpful.

Rational Speech Acts (RSA) matrix reasoning.

The catch? RSA is computationally expensive. It requires the system to reason over thousands of possible programs and examples simultaneously at "inference time" (while the user is waiting). This makes it nearly impossible to scale to complex, real-world programming tasks.

Methods

The authors introduce PRAX (Pragmatic Amortization), which moves the expensive reasoning from the user-interaction phase to the training phase.

The PRAX iterative training framework.
  1. Self-Play & Data Generation: The system starts with a "Literal Speaker" (which generates any valid example) and a "Literal Listener" (which finds any consistent program). These models play against each other to generate a large pool of candidate programs and examples.
  2. Pragmatic Filtering: PRAX uses the RSA framework to look at this pool and select the examples that are the most "informative"—those that best distinguish the target program from "distractor" programs.
  3. Iterative Bootstrapping: These high-quality, pragmatic pairs are added to a training set. The models are then retrained on this better data. As the models improve, they generate even more sophisticated examples, creating a virtuous cycle.
  4. Amortization: Because the "pragmatic reasoning" is baked into the neural network's weights during training, the final model can make "smart" guesses instantly during a live interaction without needing to run the heavy RSA math.

Datasets

  • Synthetic Regex Data: 300,000 randomly generated regular expression-specification pairs used to initialize the base models.
  • Human-Annotated Dataset (New): The authors collected a novel dataset of 440 regular expressions where human participants provided the examples they felt were most descriptive.
  • Ye et al. (2020) Templates: The study used regex templates derived from real-world questions on StackOverflow to ensure the tasks were representative of actual user needs.

Key Insights and Ideas

  • Amortizing Pragmatics: The most significant insight is that you don't need to do complex "counterfactual reasoning" (thinking about what the user didn't say) at runtime if you train the model on data that already reflects that logic.
  • The Power of Self-Play: The model can effectively "teach itself" what a good example looks like. By simulating the communication game, the Speaker model learns to provide examples that are likely to clear up the Listener's confusion.
  • Matching Humans with Zero Data: Perhaps the most surprising finding is that a model trained on zero human examples (using only its own pragmatically-filtered synthetic data) can perform as well as, or better than, a model fine-tuned on actual human data. This suggests that the RSA framework successfully captures the underlying logic of human communication.

Key Results

The researchers tested PRAX on the task of synthesizing regular expressions from strings and compared it against "Literal" models and models fine-tuned on human data (HFT).

  • Accuracy Boost: PRAX outperformed the literal baseline by 23% absolute (a 51% relative increase) in terms of finding the correct program within 10 turns of interaction.
  • Human-Level Performance: PRAX achieved a success rate of 66.1%, effectively matching (and slightly exceeding) the performance of the model trained on human-provided examples (58.7%).
  • Efficiency: In user studies with 11 human participants, PRAX was able to recover the intended program faster and more reliably than the other models, showing that it truly understood the "pragmatic" intent behind the users' choices.

Limitations and Future Work

  • Domain Specificity: The current work is limited to regular expressions. While regex is a classic PBE benchmark, it is a Domain-Specific Language (DSL) with relatively constrained logic.
  • Scaling to General Code: The authors note that the next big challenge is applying PRAX to open-ended programming languages like Python.
  • Multimodal Specifications: Future versions could combine input-output examples with natural language descriptions (e.g., "Give me a regex for email addresses") to further reduce ambiguity.
  • Computational Cost of Training: While PRAX saves time at inference, the iterative bootstrapping and RSA filtering during training are still computationally intensive.

Summary updated

BibTeX
@inproceedings{vaduguru2024generating,
  author = {Saujas Vaduguru and Daniel Fried and Yewen Pu},
  title = {{Generating Pragmatic Examples to Train Neural Program Synthesizers}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=yxKZGQLzOP},
}
Figure