Balcony: A Lightweight Approach to Dynamic Inference of Generative Language Models

Benyamin Jamialahmadi, Parsa Kavehzadeh, Mehdi Rezagholizadeh, Parsa Farinneya, Hossein Rajabzadeh +3 more
3/6/2025
cs.CLcs.AIcs.LG

No official code found. Best implementation: benyaminjami/Balcony-LLaMA (7 stars, Apache-2.0, last commit 2025-05-13).

Abstract

Deploying large language models (LLMs) in real-world applications is often hindered by strict computational and latency constraints. While dynamic inference offers the flexibility to adjust model behavior based on varying resource budgets, existing methods are frequently limited by hardware inefficiencies or performance degradation. In this paper, we introduce Balcony, a simple yet highly effective framework for depth-based dynamic inference. By freezing the pretrained LLM and inserting additional transformer layers at selected exit points, Balcony maintains the full model's performance while enabling real-time adaptation to different computational budgets. These additional layers are trained using a straightforward self-distillation loss, aligning the sub-model outputs with those of the full model. This approach requires significantly fewer training tokens and tunable parameters, drastically reducing computational costs compared to prior methods. When applied to the LLaMA3-8B model, using only 0.2% of the original pretraining data, Balcony achieves minimal performance degradation while enabling significant speedups. Remarkably, we show that Balcony outperforms state-of-the-art methods such as Flextron and Layerskip as well as other leading compression techniques on multiple models and at various scales, across a variety of benchmarks.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Balcony-LLaMA implements early exit mechanisms in transformer-based models to improve computational efficiency without sacrificing performance quality, specifically targeting the Llama family of models.

71Shell, PythonDec 25, 20241 years agoApache-2.0

Similar Papers

Cite this paper

@article{jamialahmadi2025balcony,
  title  = {Balcony: A Lightweight Approach to Dynamic Inference of Generative Language Models},
  author = {Benyamin Jamialahmadi and Parsa Kavehzadeh and Mehdi Rezagholizadeh and Parsa Farinneya and Hossein Rajabzadeh and Aref Jafari and Boxing Chen and Marzieh S. Tahaei},
  year   = {2025},
  eprint = {2503.05005},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.05005v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.05005.svg)](https://codeofpaper.com/paper/2503.05005)

Discussion