Skip to main content
QUICK REVIEW

[Paper Review] Enhancing Computer Programming Education with LLMs: A Study on Effective Prompt Engineering for Python Code Generation

Tianyu Wang, Nianjun Zhou|arXiv (Cornell University)|Jul 7, 2024
Online Learning and AnalyticsComputer Science10 citations
TL;DR

The paper systematically categorizes prompt engineering strategies for LLM-driven Python code generation, evaluates their impact across LeetCode and USACO datasets, and proposes a framework and guidelines for educators.

ABSTRACT

Large language models (LLMs) and prompt engineering hold significant potential for advancing computer programming education through personalized instruction. This paper explores this potential by investigating three critical research questions: the systematic categorization of prompt engineering strategies tailored to diverse educational needs, the empowerment of LLMs to solve complex problems beyond their inherent capabilities, and the establishment of a robust framework for evaluating and implementing these strategies. Our methodology involves categorizing programming questions based on educational requirements, applying various prompt engineering strategies, and assessing the effectiveness of LLM-generated responses. Experiments with GPT-4, GPT-4o, Llama3-8b, and Mixtral-8x7b models on datasets such as LeetCode and USACO reveal that GPT-4o consistently outperforms others, particularly with the "multi-step" prompt strategy. The results show that tailored prompt strategies significantly enhance LLM performance, with specific strategies recommended for foundational learning, competition preparation, and advanced problem-solving. This study underscores the crucial role of prompt engineering in maximizing the educational benefits of LLMs. By systematically categorizing and testing these strategies, we provide a comprehensive framework for both educators and students to optimize LLM-based learning experiences. Future research should focus on refining these strategies and addressing current LLM limitations to further enhance educational outcomes in computer programming instruction.

Motivation & Objective

  • Categorize prompt engineering strategies tailored to different educational requirements and question types.
  • Evaluate how prompts influence LLMs’ ability to solve programming problems beyond their default capabilities.
  • Develop a robust framework to test prompt strategies and provide practical guidelines for educators and students.

Proposed method

  • Categorize questions by educational level: Knowledge/Skills, Competitions, Advanced Complex Problems.
  • Apply three prompt strategies: Without Prompt Engineering, General Prompt Engineering, Specific Prompt Engineering.
  • Evaluate LLM outputs using correctness, effectiveness (time/memory), and code quality metrics; analyze results across datasets.

Experimental results

Research questions

  • RQ1Can prompt engineering strategies be systematically categorized for different educational needs and question types?
  • RQ2Do tailored prompt strategies enable LLMs to tackle problems beyond their immediate capabilities?
  • RQ3Can a robust evaluation framework and practical guidelines be established for implementing these strategies in education?

Key findings

  • GPT-4 and GPT-4o outperform other models on LeetCode across prompts, with GPT-4o achieving 100% pass rate under the multi prompt strategy.
  • Multi-step prompts provide strong gains for complex problems, e.g., GPT-4o reaching 100% pass rate with multi prompts on LeetCode.
  • On LeetCode, base pass rates ranged from 97–99% for GPT-4o across prompts and 98–99% for GPT-4, while Llama3-8b and Mixtral-8x7b lag behind.
  • Time efficiency favors GPT-4 variants, with the fastest times around 3959–4604 ms across prompts; GPT-4 generally fastest.
  • Code quality (Pylint) is highest for GPT-4, especially under the multi prompt; other models show more variability.
  • USACO results show multi prompts improve solvable problems from 30% (base) to 55% (multi) and 75% (multi+spec), though some problems remain unsolved.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.