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

Developing a LLMs-Driven System Based on Human-AI Progressive Code Generation Framework to Assist Mathematics Learning

Cindy H. P. Sit, Yin Yang, Wing Kei Yeung, Siu Cheung KongInternational Conference on Computers in Education 2024

Abstract

This paper proposes a system interface based on a novel progressive code generation framework to produce verified programming codes using natural language for mathematics learning. While Large Language Models (LLMs) like GPT-4 can generate code, the output is often non-executable or misaligned with user goals. Existing evaluation metrics often ignore the value of iterative feedback. The proposed framework allows code to progressively improve by re-prompting LLMs with error feedback until the code is executable and correct within a set number of iterations. This study tests the framework's ability to enhance accuracy in complex mathematical problem-solving.

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language processing, yet they frequently struggle with precise arithmetic and logical reasoning—a phenomenon often leading to "hallucinations." To mitigate this, users often prompt LLMs to generate scripts (e.g., JavaScript or Python) to perform calculations. However, standard evaluation metrics like BLEU or pass@n typically measure only the success of the initial attempt. This paper introduces the Human-AI Progressive Code Generation (ProG) Framework, which moves beyond "one-shot" generation toward an iterative loop of error feedback and human evaluation.

The ProG Framework

The ProG framework transforms code generation into a dynamic, multi-stage conversation designed to bridge the gap between natural language and executable logic.

The Progressive Code Generation (ProG) framework illustrating iterative execution and human evaluation loops.

The process consists of several key stages:

  1. Initial Prompting: The user inputs a mathematical word problem.
  2. Execution Loop ($r$): If the generated code fails to execute, the system automatically feeds the error message back to the LLM for correction.
  3. Human Evaluation Loop ($h$): Once executable, a human evaluator verifies if the output meets the intended goal. If incorrect, natural language feedback is provided for further refinement.

To quantify efficiency, the authors propose the ProG Metric: $$ProG = \frac{1}{e^{(r+h-o)}}$$ where $r$ represents execution iterations, $h$ represents human evaluation iterations, and $o$ is an offset. A higher score indicates a more efficient generation process requiring less intervention.

System Implementation

The framework is realized through a specialized three-panel interface designed for educational contexts, allowing students to interact with the model while tracking their progress.

The three-panel system interface featuring question tracking, note-taking, and interactive LLM chat.

The interface includes:

  • Context Track: A list of mathematical questions for the student to navigate.
  • Notes Taking: A dedicated area for students to document their reasoning and observations.
  • Interacting with the LLM: A chat interface where the LLM generates and executes JavaScript code in real-time, providing immediate feedback.

Experimental Evaluation

The study utilized a targeted benchmark of 10 situational math word problems involving multi-digit operations (e.g., calculating revenue from 8,123,456 units at $567,890 each). These problems typically result in answers exceeding 13 digits, testing the limits of LLM internal calculation.

In a usability test with four researchers (40 total trials), GPT-4 achieved 0% accuracy when prompted directly without the framework. While the model often correctly identified the first few digits, it lacked the precision required for large-scale arithmetic. The ProG framework addresses this by offloading the "logic" to a deterministic JavaScript engine while the LLM serves as the natural language translator.

Conclusion

The ProG framework demonstrates that iterative debugging is essential for using LLMs in high-precision domains like mathematics. By treating failures as data, the system not only solves immediate problems but also identifies high-value prompts for future model fine-tuning. Future work will expand testing to classroom settings to evaluate the framework's impact on diverse mathematical disciplines and student learning outcomes.

Summary updated

BibTeX
@inproceedings{sit2024developing,
  author = {Cindy H. P. Sit and Yin Yang and Wing Kei Yeung and Siu Cheung Kong},
  title = {{Developing a LLMs-Driven System Based on Human-AI Progressive Code Generation Framework to Assist Mathematics Learning}},
  booktitle = {International Conference on Computers in Education},
  year = {2024},
  doi = {10.58459/icce.2024.4815},
}
Figure