arXiv:2501.07892cs.SEcs.AI2025-01被引 3

用记忆自检机制让大模型在无数据时也能写出可靠代码。

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

  • 引入元记忆代理,让模型自我回忆并评估知识可信度。
  • 在8个公开基准上显著提升无数据场景下的代码生成质量。
  • 适合需要零样本编程的工程自动化场景,如快速原型开发。

大型语言模型在自动化代码生成中表现优异,少样本提示因其简洁有效而广泛应用。然而,少样本方法依赖精心筛选或人工编写的参考示例,在真实世界无训练数据的编码场景中适用性受限。现有通过复述或类比生成参考示例的方法无法保证其真实性与准确性。受人类元记忆启发,本文提出一种新型元记忆代理,用于增强无数据编码场景下的一次性代码生成。该代理引导大模型回忆相关先验知识,评估回忆内容的置信度,并选择可靠信息用于问题求解。该机制无需外部参考示例,提升了回忆知识的真实性与准确性,并能根据任务动态调整回忆与评估过程。大量实验表明,所提元记忆代理在多种无数据编码场景中显著提升一次性代码生成质量。人工智能贡献在于通过置信度评估与筛选使自回忆示例可靠;工程应用价值体现在无数据自动化代码生成,已在八个公共基准上验证。

原文摘要 · Abstract (English)

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.

代码生成元记忆零样本大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。