cs.SEJan 14, 2025

Leveraging Metamemory Agent for Enhanced Data-Free Code Generation in Large Language Models

Authors: Shengsheng ZhouShuai WangLiang DingYibing ZhanYong LuoZheng HeFu LinDapeng Tao

Organizations: College of Computing and Data Science, Nanyang Technological University, Singapore · School of Computer Science, National Engineering Research Center for Multimedia Software, Wuhan University, Wuhan, China · The University of Sydney, Sydney, Australia · Yunnan United Vision Technology Company Ltd., China · School of Computer Science, Wuhan University, Wuhan, China · School of Information Science and Engineering, Yunnan University, Kunming, China

Abstract

Large language models (LLMs) have shown strong performance in automated code generation, with few-shot prompting widely used for its simplicity and effectiveness. However, few-shot methods depend on curated or manually crafted reference examples, limiting their applicability in data-free coding scenarios such as real-world data-free coding scenarios and benchmarks without training sets. Existing methods that generate reference examples via recitation or analogy cannot guarantee their authenticity or accuracy. Inspired by human metamemory, we propose a novel metamemory agent to enhance one-time code generation in data-free coding scenarios. The agent guides LLMs to recall relevant prior knowledge, evaluate confidence in recalled information, and selectively exploit reliable content for problem solving. This agent removes the need for external reference examples, improves the authenticity and accuracy of recalled knowledge, and adaptively tailors the recall&evaluation process to each task. Extensive experiments demonstrate that the proposed metamemory agent significantly improves one-time code generation quality across data-free coding scenarios. The AI contribution is the metamemory agent, which makes self-recalled examples reliable through confidence evaluation and selection; the engineering application is data-free automated code generation, validated on eight public benchmarks.

Explore similar work

CardsList