Program-Aided Reasoners (better) Know What They Know

Anubha Kabra, Sanketh Rangreji, Yash Mathur, Aman Madaan, Emmy Liu, Graham Neubig · DOI

While Large Language Models (LLMs) have made significant strides in complex reasoning, they often suffer from overconfidence—a tendency to be "confidently wrong." This paper explores a solution: Program-Aided Language (PAL) models. By generating Python code instead of natural language steps, these models not only improve accuracy but also become significantly better calibrated, meaning their internal confidence levels more accurately reflect their actual performance.

The Challenge of Calibration

In machine learning, calibration is as vital as accuracy. A well-calibrated model is one where a 90% confidence score translates to a 90% success rate. Standard Chain-of-Thought (CoT) reasoning, while effective for breaking down problems, often fails this test. CoT models can produce elaborate, plausible-sounding explanations that lead to incorrect answers, yet remain highly consistent (and thus confident) in their errors.

Methodology: From Language to Logic

The researchers compared two primary prompting strategies across five diverse datasets, including GSM8K and Object Counting:

  1. Chain-of-Thought (CoT): The model generates a sequence of natural language sentences to reach an answer.
  2. Program-Aided Language (PAL): The model generates Python code, which is then executed by an external interpreter to calculate the final result.
Figure 1: A comparison between Chain-of-Thought (CoT) and Program-Aided Language (PAL). While CoT can make arithmetic errors in natural language, PAL offloads calculation to a Python interpreter, ensuring logical consistency.

To quantify confidence, the study employed Self-Consistency. By generating multiple reasoning paths (e.g., 10) for a single question, the "confidence" was defined as the frequency of the most common answer. The primary metric for evaluation was the Expected Calibration Error (ECE), which measures the gap between confidence and accuracy.

Why Programs Improve Calibration

The core insight of the paper is that code is structurally more constrained than natural language. While there are infinite ways to explain a math problem in English, the functional ways to write a Python script for it are far fewer. This reduced "generation diversity" means that when a model reaches a consensus in code, that consensus is a much more reliable indicator of correctness. Even when controlling for accuracy, the PAL prompting style itself contributes to lower calibration error.

Key Results

The findings were consistent across both OpenAI and LLaMA architectures:

  • Widespread Gains: PAL improved calibration in 75% of the experimental settings tested.
  • Error Reduction: On OpenAI models like GPT-3.5-Turbo, PAL achieved a relative reduction in calibration error (ECE) of approximately 50% and an average 18.4% improvement in accuracy over CoT.
  • Reliability Alignment: Visual analysis of reliability diagrams showed that PAL's performance curves aligned much more closely with the "ideal" diagonal line than CoT's erratic outputs.
Figure 6: Reliability plot for PAL on the GSM-8K dataset. The green line closely tracks the blue dashed line (perfect reliability), showing that the model's confidence is a strong predictor of its accuracy.

Conclusion

The shift from natural language reasoning to program-based reasoning offers a dual benefit: it makes models smarter and more self-aware. By leveraging the inherent structure of code, PAL models provide a path toward more reliable and trustworthy AI systems in real-world deployments. Future work will look to extend these findings to more open-ended tasks where the boundaries of logical reasoning are less defined.

Summary updated

BibTeX
@inproceedings{kabra2024program,
  author = {Anubha Kabra and Sanketh Rangreji and Yash Mathur and Aman Madaan and Emmy Liu and Graham Neubig},
  title = {{Program-Aided Reasoners (better) Know What They Know}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.naacl-long.125},
}
Figure