Chain of Grounded Objectives: Bridging Process and Goal-oriented Prompting for Code Generation
Sangyeop Yeo, Seung-won Hwang, Yu-Seung Ma
TL;DR
This paper addresses prompt design for large language models in code generation by introducing Chain of Grounded Objectives (CGO), a concise, two-stage prompting framework that first derives compact functional objectives and then uses them to guide code generation. CGO expresses objectives as comment-style statements, aligning with programming language conventions to improve interpretability and reduce token costs. Empirical results on HumanEval, MBPP variants, and LiveCodeBench show CGO yields higher accuracy (via metrics like $pass@1$ and $pass ext{-}ratio@10$) and greater token efficiency compared with baseline prompting methods, with pronounced gains on larger models such as GPT-3.5-Turbo and LLaMA-3.1-70B-Instruct. The approach demonstrates real-world applicability and offers a scalable, cost-effective alternative to more verbose chain-of-thought or self-planning prompts, suggesting practical value for AI-assisted programming tasks.
Abstract
The use of Large Language Models (LLMs) for code generation has gained significant attention in recent years. Existing methods often aim to improve the quality of generated code by incorporating additional contextual information or guidance into input prompts. Many of these approaches adopt sequential reasoning strategies, mimicking human-like step-by-step thinking. However, such strategies may constrain flexibility, as they do not always align with the structured characteristics of programming languages. This paper introduces the Chain of Grounded Objectives (CGO), a method that embeds functional objectives into input prompts to enhance code generation. By leveraging appropriately structured objectives as input and avoiding explicit sequential procedures, CGO adapts effectively to the structured nature of programming tasks. Empirical evaluations demonstrate that CGO effectively enhances code generation, addressing limitations of existing approaches.
