3.2 SELF-DEBUGGING with Unit Tests (UT)

For code generation tasks where the problem description includes unit tests, besides utilizing code
execution to check code correctness, we can also present the execution results in the feedback
message, which provides richer information for debugging. Figure 5 presents a sample unit test
feedback message for code translation. Intuitively, inspecting runtime error messages and execution
results of failed unit tests also helps human programmers debug more effectively. In our experiments,
we will demonstrate that leveraging unit tests considerably improves the debugging performance.

3.3 SELF-DEBUGGING via Code Explanation (Expl.)

Despite recent promising progress showing that large language models can generate critiques to
avoid harmful model outputs [18, 3] and improve their performance on some natural language and

3
Teaching Large Language Models to Self-Debug