Table of Contents
Fetching ...

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.

Chain of Grounded Objectives: Bridging Process and Goal-oriented Prompting for Code Generation

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 and ) 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.
Paper Structure (22 sections, 6 equations, 7 figures, 12 tables)

This paper contains 22 sections, 6 equations, 7 figures, 12 tables.

Figures (7)

  • Figure 1: CGO's Workflow.
  • Figure 2: Code example generated with the Chain of Grounded Objectives and Chain of Thought.
  • Figure 3: Context example generated with the Chain of Grounded Objectives and Self-Planning.
  • Figure 4: pass@1 and pass-ratio@10 scores by difficulty level on the GPT-3.5-turbo experiment.
  • Figure 5: Average number of generated tokens by LLaMA3.1-8B-Instruct and LLaMA3.1-70B-Instruct on the HumanEval and LiveCodeBench across 5 baseline prompts (lower is better).
  • ...and 2 more figures