Table of Contents
Fetching ...

Greening Large Language Models of Code

Jieke Shi, Zhou Yang, Hong Jin Kang, Bowen Xu, Junda He, David Lo

TL;DR

Avatar addresses the need to deploy large language models of code on developer devices by formulating a multi-objective configuration-tuning problem that jointly minimizes size, latency, energy, and carbon footprint while preserving effectiveness. It combines SMT-based configuration-space pruning, a regression-based effectiveness indicator, and a tailored multi-objective search with knowledge distillation to produce Pareto-optimal small models. On CodeBERT and GraphCodeBERT, Avatar yields 3 MB models with up to 76× latency reduction, up to 184× energy savings, and up to 157× carbon reduction, with only about 1.67% loss in accuracy, surpassing the Compressor baseline. The approach also demonstrates substantial cloud deployment gains and offers a scalable path toward greener, on-device code intelligence with practical applicability across software engineering tasks.

Abstract

Large language models of code have shown remarkable effectiveness across various software engineering tasks. Despite the availability of many cloud services built upon these powerful models, there remain several scenarios where developers cannot take full advantage of them, stemming from factors such as restricted or unreliable internet access, institutional privacy policies that prohibit external transmission of code to third-party vendors, and more. Therefore, developing a compact, efficient, and yet energy-saving model for deployment on developers' devices becomes essential. To this aim, we propose Avatar, a novel approach that crafts a deployable model from a large language model of code by optimizing it in terms of model size, inference latency, energy consumption, and carbon footprint while maintaining a comparable level of effectiveness. The key idea of Avatar is to formulate the optimization of language models as a multi-objective configuration tuning problem and solve it with the help of a Satisfiability Modulo Theories (SMT) solver and a tailored optimization algorithm. The SMT solver is used to form an appropriate configuration space, while the optimization algorithm identifies the Pareto-optimal set of configurations for training the optimized models using knowledge distillation. We evaluate Avatar with two popular language models of code, i.e., CodeBERT and GraphCodeBERT, on two popular tasks, i.e., vulnerability prediction and clone detection. We use Avatar to produce optimized models with a small size (3 MB), which is 160$\times$ smaller than the original large models. On the two tasks, the optimized models significantly reduce the energy consumption (up to 184$\times$ less), carbon footprint (up to 157$\times$ less), and inference latency (up to 76$\times$ faster), with only a negligible loss in effectiveness (1.67\% on average).

Greening Large Language Models of Code

TL;DR

Avatar addresses the need to deploy large language models of code on developer devices by formulating a multi-objective configuration-tuning problem that jointly minimizes size, latency, energy, and carbon footprint while preserving effectiveness. It combines SMT-based configuration-space pruning, a regression-based effectiveness indicator, and a tailored multi-objective search with knowledge distillation to produce Pareto-optimal small models. On CodeBERT and GraphCodeBERT, Avatar yields 3 MB models with up to 76× latency reduction, up to 184× energy savings, and up to 157× carbon reduction, with only about 1.67% loss in accuracy, surpassing the Compressor baseline. The approach also demonstrates substantial cloud deployment gains and offers a scalable path toward greener, on-device code intelligence with practical applicability across software engineering tasks.

Abstract

Large language models of code have shown remarkable effectiveness across various software engineering tasks. Despite the availability of many cloud services built upon these powerful models, there remain several scenarios where developers cannot take full advantage of them, stemming from factors such as restricted or unreliable internet access, institutional privacy policies that prohibit external transmission of code to third-party vendors, and more. Therefore, developing a compact, efficient, and yet energy-saving model for deployment on developers' devices becomes essential. To this aim, we propose Avatar, a novel approach that crafts a deployable model from a large language model of code by optimizing it in terms of model size, inference latency, energy consumption, and carbon footprint while maintaining a comparable level of effectiveness. The key idea of Avatar is to formulate the optimization of language models as a multi-objective configuration tuning problem and solve it with the help of a Satisfiability Modulo Theories (SMT) solver and a tailored optimization algorithm. The SMT solver is used to form an appropriate configuration space, while the optimization algorithm identifies the Pareto-optimal set of configurations for training the optimized models using knowledge distillation. We evaluate Avatar with two popular language models of code, i.e., CodeBERT and GraphCodeBERT, on two popular tasks, i.e., vulnerability prediction and clone detection. We use Avatar to produce optimized models with a small size (3 MB), which is 160 smaller than the original large models. On the two tasks, the optimized models significantly reduce the energy consumption (up to 184 less), carbon footprint (up to 157 less), and inference latency (up to 76 faster), with only a negligible loss in effectiveness (1.67\% on average).
Paper Structure (18 sections, 3 equations, 1 figure, 4 tables)