通过有效提示提升LLM生成代码的能效
原标题:Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting
AI 摘要
该研究系统评估了21种提示策略对LLM生成代码能效的影响,并在10个开源与专有模型上测试了其中8种策略,覆盖Python和C++。结果显示,相比基线提示,这些策略可使Python代码能耗最多降低25%、C++最多降低17%;模型层面,Granite-4.0-H-Small的Python能耗降低达50%、C++达56%。研究强调应将能效纳入LLM代码生成的评估与优化,并指出提示策略效果因模型和编程语言而异。
正文节选
Improving the Energy-Efficiency of the Code Generated by LLMs through Effective Prompting Abstract As AI-assisted programming becomes increasingly mainstream, the environmental impact of AI-generated software has emerged as an important consideration. This motivates evaluating LLM-generated code beyond functional correctness by considering execution efficiency and energy consumption. However, despite substantial advances in code generation, frontier LLMs are rarely evaluated based on the energy