For example, chain-of-thought prompting asks the model to produce intermediate reasoning steps in
natural language, which can be accomplished either with few-shot exemplars [55] or in a zero-shot
manner [29]. Meanwhile, several prompting techniques explicitly direct the model to break down a
problem into subproblems [68, 27]. For example, decomposed prompting [27] delegates subproblems

13

to other LLM instances that are prompted to specialize in speciﬁc tasks. Our prompting format
of code explanation is relevant in spirit to chain-of-thought prompting, as the line-by-line code
explanation in natural language facilitates analysis of the code that is useful for the debugging task.
On the other hand, SELF-DEBUGGING also decomposes the debugging process into several stages,
and triggers separate prompts for code explanation and feedback generation.
Teaching Large Language Models to Self-Debug