An Initial Exploration of Contrastive Prompt Tuning to Generate Energy-Efficient Code
Sophie Weidmann, Fernando Castor

TL;DR
This paper explores using Contrastive Prompt Tuning to enhance the energy efficiency of code generated by large language models, aiming to support Green Software Development efforts.
Contribution
It introduces Contrastive Prompt Tuning as a novel, cost-effective method to improve energy efficiency in code generation by LLMs.
Findings
CPT improves code accuracy in two models.
Efficiency gains vary by language and task.
Improvements are not consistently reliable.
Abstract
Although LLMs are capable of generating functionally correct code, they also tend to produce less energy-efficient code in comparison to human-written solutions. As these inefficiencies lead to higher computational overhead, they are in direct conflict with Green Software Development (GSD) efforts, which aim to reduce the energy consumption of code. To support these efforts, this study aims to investigate whether and how LLMs can be optimized to promote the generation of energy-efficient code. To this end, we employ Contrastive Prompt Tuning (CPT). CPT combines Contrastive Learning techniques, which help the model to distinguish between efficient and inefficient code, and Prompt Tuning, a Parameter-Efficient Fine Tuning (PEFT) approach that requires only a fraction of the cost of traditional fine tuning. This study evaluates CPT on Python, Java and C++ coding problems across three…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
