Leveraging Print Debugging to Improve Code Generation in Large Language Models

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Hu, Xueyu, Kuang, Kun, Sun, Jiankai, Yang, Hongxia, Wu, Fei
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911754124001280
author Hu, Xueyu
Kuang, Kun
Sun, Jiankai
Yang, Hongxia
Wu, Fei
author_facet Hu, Xueyu
Kuang, Kun
Sun, Jiankai
Yang, Hongxia
Wu, Fei
contents Large language models (LLMs) have made significant progress in code generation tasks, but their performance in tackling programming problems with complex data structures and algorithms remains suboptimal. To address this issue, we propose an in-context learning approach that guides LLMs to debug by using a "print debugging" method, which involves inserting print statements to trace and analysing logs for fixing the bug. We collect a Leetcode problem dataset and evaluate our method using the Leetcode online judging system. Experiments with GPT-4 demonstrate the effectiveness of our approach, outperforming rubber duck debugging in easy and medium-level Leetcode problems by 1.5% and 17.9%.
format Preprint
id arxiv_https___arxiv_org_abs_2401_05319
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Leveraging Print Debugging to Improve Code Generation in Large Language Models
Hu, Xueyu
Kuang, Kun
Sun, Jiankai
Yang, Hongxia
Wu, Fei
Computation and Language
Software Engineering
Large language models (LLMs) have made significant progress in code generation tasks, but their performance in tackling programming problems with complex data structures and algorithms remains suboptimal. To address this issue, we propose an in-context learning approach that guides LLMs to debug by using a "print debugging" method, which involves inserting print statements to trace and analysing logs for fixing the bug. We collect a Leetcode problem dataset and evaluate our method using the Leetcode online judging system. Experiments with GPT-4 demonstrate the effectiveness of our approach, outperforming rubber duck debugging in easy and medium-level Leetcode problems by 1.5% and 17.9%.
title Leveraging Print Debugging to Improve Code Generation in Large Language Models
topic Computation and Language
Software Engineering
url https://arxiv.org/abs/2401.05319