arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.14834cs.SEcs.AI
收藏

大型语言模型在面向对象编程中的策略优化与挑战

Strategic Optimization and Challenges of Large Language Models in Object-Oriented Programming

Institute for Clarity in Documentation(文献清晰度研究所);Inria Paris-Rocquencourt(法国国家信息与自动化研究所巴黎-罗康库尔中心);Rajiv Gandhi University(拉吉夫·甘地大学);Tsinghua University(清华大学);Palmer Research Laboratories(帕尔默研究实验室)

Zinan Wang

AI总结:

本研究聚焦面向对象编程框架内的方法级代码生成,基于CoderEval设计实验并引入“提示词Token成本效益”指标,发现富含方法调用细节的提示成本效益最高,且应根据任务耦合度选择合适的LLM以优化代码质量与成本。

摘要:

在代码生成研究领域,重点已从编写单个函数转向开发整合上下文信息的类级方法代码。这一转变催生了ClassEval和CoderEval等考虑类级上下文的基准。然而,方法级特定上下文因素的影响仍较少被探索。本研究聚焦于面向对象编程(OOP)框架内的方法级代码生成。基于CoderEval,我们设计了实验,改变提示中上下文信息的范围,从方法特定细节到项目级详情。我们引入了“提示词Token成本效益”这一创新指标,以评估增加额外上下文层的经济可行性。研究结果表明,富含方法调用细节的提示产生最高的成本效益。此外,研究揭示了大型语言模型(LLMs)在错误类型分布及为开发者提供辅助水平方面存在差异。值得注意的是,更大的LLM并不总是表现更好。我们还观察到,耦合度较高的任务带来更严峻的挑战,表明LLM的选择应根据任务的耦合度进行定制。例如,GPT-4在低耦合场景中表现更佳,而GPT-3.5似乎更适合高耦合任务。通过精心策划提示内容并选择合适的LLM,开发者可以在开发过程中优化代码质量,同时最大化成本效益。

英文摘要:

In the area of code generation research, the emphasis has transitioned from crafting individual functions to developing class-level method code that integrates contextual information. This shift has brought several benchmarks such as ClassEval and CoderEval, which consider class-level contexts. Nevertheless, the influence of specific contextual factors at the method level remains less explored. This research focused on method-level code generation within the Object-Oriented Programming (OOP) framework. Based on CoderEval, we devised experiments that varied the extent of contextual information in the prompts, ranging from method-specific to project-wide details. We introduced the innovative metric of "Prompt-Token Cost-Effectiveness" to evaluate the economic viability of incorporating additional contextual layers. Our findings indicate that prompts enriched with method invocation details yield the highest cost-effectiveness. Additionally, our study revealed disparities among Large Language Models (LLMs) regarding error type distributions and the level of assistance they provide to developers. Notably, larger LLMs do not invariably perform better. We also observed that tasks with higher degrees of coupling present more substantial challenges, suggesting that the choice of LLM should be tailored to the task's coupling degree. For example, GPT-4 exhibited improved performance in low-coupling scenarios, whereas GPT-3.5 seemed better suited for tasks with high coupling. By meticulously curating prompt content and selecting the appropriate LLM, developers can optimize code quality while maximizing cost-efficiency during the development process.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑