Towards Better Understanding of Program-of-Thought Reasoning in Cross-Lingual and Multilingual Environments

Patomporn Payoungkhamdee, Pume Tuchinda, Jinheon Baek, Samuel Cahyawijaya, Can Udomcharoenchaikit, Potsawee Manakul, Peerat Limkonchotiwat, Ekapol Chuangsuwanich, Sarana Nutanong · DOI

TL;DR

Large Language Models often struggle with complex math problems in non-English languages because standard Chain-of-Thought (CoT) prompting entangles natural language reasoning with exact computation. This paper demonstrates that Program-of-Thought (PoT) fine-tuning—which decouples reasoning from execution by generating Python code—significantly enhances multilingual math performance. Furthermore, by using code quality (ICE-Score) to guide a test-time "Soft Self-Consistency" voting mechanism, the authors achieve massive accuracy boosts across diverse languages.

What Problem Does This Paper Address?

While Large Language Models (LLMs) excel at multi-step reasoning in English, their performance drops sharply in non-English languages due to structural linguistic disparities and limited training data. Traditional Chain-of-Thought (CoT) prompting requires the model to generate both the text-based reasoning steps and perform the arithmetic calculations simultaneously. In multilingual settings, this dual burden frequently leads to cascading errors.

Program-of-Thought (PoT) prompting offers an elegant alternative: the LLM focuses purely on reasoning by generating a computer program (e.g., Python code), and an external interpreter handles the actual computation. However, how to effectively fine-tune models for PoT in multilingual environments remained underexplored. This paper tackles two core challenges:

  1. Question-Reasoning (Q-R) Alignment: How to best align multilingual questions with structured code generation, particularly regarding the use of inline code comments.
  2. Reasoning-Answer (R-A) Association: How the structural quality of the generated code correlates with final answer correctness, and how to exploit this relationship at inference time.
Figure 1: Proposed experimental framework under the PoT workflow Q →R →A. P1: Aligning multilin- gual questions (Q) with reasoning steps (R) through fine-tuning and inline comments. P2: Assessing the cor- relation between reasoning steps (R) and final answers (A) through code quality and test-time inference.

Methods

The authors formalize multilingual PoT into a two-stage pipeline: $Q \rightarrow R$ (LLM generates Python code $R$ from a question $Q$) and $R \rightarrow A$ (an external Python interpreter executes $R$ to output answer $A$).

To optimize this process, they explore two fine-tuning paradigms:

  • Cross-lingual Setup: Training exclusively on English data and evaluating zero-shot performance on target languages.
  • Multilingual Setup: Training on parallel data across multiple target languages.

A key focus of their methodology is the treatment of inline comments within the generated code. They experiment with keeping English comments, removing comments entirely, or translating comments into the target language.

Finally, they introduce Soft Self-Consistency (Soft-SC) for test-time scaling. Instead of standard majority voting (hard voting) over multiple generated code samples, Soft-SC weights each candidate's vote based on its ICE-Score—a metric that quantifies the functional correctness of intermediate steps within the code, evaluated via an Oracle LLM.

Datasets

  • GSM8K: The standard Grade School Math benchmark used as the foundational English dataset.
  • GSM8KPoT / MGSM8KPoT: New high-quality datasets created by the authors. They developed a pipeline using an Oracle LLM (Llama 3.1 405B) driven by "few-shot prompting + CoT guidance" to synthesize correct Python programs for GSM8K questions, achieving a 96.1% correctness rate.
  • MGSM (Multilingual Grade School Math): Used for evaluation across 10 diverse languages: English (en), German (de), French (fr), Spanish (es), Russian (ru), Chinese (zh), Japanese (ja), Thai (th), Swahili (sw), and Bengali (bn).

Key Insights and Ideas

  • Comments act as a distraction in cross-lingual transfer: When an LLM is fine-tuned only in English, keeping English inline comments hurts its ability to generalize to other languages. Removing comments entirely (nc) yields much better cross-lingual generalization.
  • Parallel alignment is vital for multilingual setups: If target-language training data is available, translating the inline comments to match the question's language (PoT Parallel) provides the strongest semantic alignment and highest accuracy.
  • Code quality mirrors truth: The authors discovered a remarkably high system-level correlation between code quality (ICE-Score) and final answer accuracy. If the intermediate logic of the code is sound, the final answer is almost certainly correct.
  • Code pre-training empowers abstract reasoning: Code-specific models (like CodeLlama) consistently beat standard base models of the same size on multilingual math, proving that pre-training on code enhances structural reasoning across language barriers.
Figure 3: The relationship between code quality and an- swer accuracy in cross-lingual and multilingual settings. Each point represents a given language, considering a specific system and model combination.

Key Results

  • PoT consistently beats CoT: Across 40 different language and model combinations tested, PoT fine-tuning outperformed CoT in 39 cases.
  • Massive Test-Time Scaling Gains: Using Soft Self-Consistency (Soft-SC) powered by the ICE-Score yielded dramatic improvements over baseline greedy decoding and standard hard-voting Self-Consistency (SC).
  • For Llama2-7B in the cross-lingual setup, accuracy surged from 39.2% to 56.6%.
  • In the multilingual setup, Llama2-7B jumped from 57.2% to 71.2%.
  • CodeLlama-7B achieved the highest overall performance in the multilingual setup, reaching 75.6% accuracy using Soft-SC.

Limitations and Future Work

  • Task Scope: The framework was evaluated exclusively on grade-school mathematics (GSM8K/MGSM). It remains unproven whether these insights transfer to other complex reasoning domains like symbolic logic or non-mathematical code generation.
  • Data Contamination: The authors note growing concerns in the NLP community regarding data contamination within the widely used GSM8K benchmark.
  • Computational Overhead: Calculating the ICE-Score at test time requires calling a massive Oracle LLM (Llama 3.1 405B), which is computationally expensive and slow for real-time deployment. Future work will focus on finding lighter, more efficient code-validation heuristics.

Summary updated

BibTeX
@inproceedings{payoungkhamdee2025towards,
  author = {Patomporn Payoungkhamdee and Pume Tuchinda and Jinheon Baek and Samuel Cahyawijaya and Can Udomcharoenchaikit and Potsawee Manakul and Peerat Limkonchotiwat and Ekapol Chuangsuwanich and Sarana Nutanong},
  title = {{Towards Better Understanding of Program-of-Thought Reasoning in Cross-Lingual and Multilingual Environments}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure