Toward Green Code: Prompting Small Language Models for Energy-Efficient Code Generation
Not on the map. Why?
Abstract (arXiv)
There is a growing concern about the environmental impact of large language models (LLMs) in software development, particularly due to their high energy use and carbon footprint. Small Language Models (SLMs) offer a more sustainable alternative, requiring fewer computational resources while remaining effective for fundamental programming tasks. In this study, we investigate whether prompt engineering can improve the energy efficiency of SLMs in code generation. We evaluate four open-source SLMs, StableCode-Instruct-3B, Qwen2.5-Coder-3B-Instruct, CodeLlama-7B-Instruct, and Phi-3-Mini-4K-Instruct, across 150 Python problems from LeetCode, evenly distributed into easy, medium, and hard categories. Each model is tested under four prompting strategies: role prompting, zero-shot, few-shot, and chain-of-thought (CoT). For every generated solution, we measure runtime, memory usage, and energy consumption, comparing the results with a human-written baseline. Our findings show that CoT prompting provides consistent energy savings for Qwen2.5-Coder and StableCode-3B, while CodeLlama-7B and Phi-3-Mini-4K fail to outperform the baseline under any prompting strategy. These results highlight that the benefits of prompting are model-dependent and that carefully designed prompts can guide SLMs toward greener software development.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). First posted on arXiv 12 Sep 2025.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2026: 2.
2 papers.
Similar, not cited
Close in wording, no citation either way
- 2026Evaluating the Environmental Impact of using SLMs and Prompt Engineering for Code Generation ↗
- 2025GREEN-CODE: Learning to Optimize Energy Efficiency in LLM-based Code Generation
- 2025Prompt engineering and framework: implementation to increase code reliability based guideline for LLMs
- 2024Green My LLM: Studying the key factors affecting the energy consumption of code assistants
- 2024Low-Cost Language Models: Survey and Performance Evaluation on Python Code Generation
- 2024Mercury: A Code Efficiency Benchmark for Code Large Language Models
- 2026Sustainability Analysis of Prompt Strategies for SLM-based Automated Test Generation ↗
- 2024The Impact of Prompt Programming on Function-Level Code Generation