Pimp My LLM: Leveraging Variability Modeling to Tune Inference Hyperparameters Nada Zine, Clément Quinton, Romain Rouvoy Abstract . Large Language Models (LLMs) are being increasingly used across a wide range of tasks. However, their substantial computational demands raise concerns about the energy efficiency and sustainability of both training and inference. Inference, in particular, dominates total compute usage, making its optimization crucial. Recent research has explored optimization techniques and analyzed how configuration choices influence energy consumption. Yet, the vast configuration space of inference servers makes exhaustive empirical evaluation infeasible due to combinatorial explosion. In this paper, we introduce a new perspective on this problem by treating LLMs as configurable systems and applying variability management techniques to systematically analyze inference-time configuration choices. We evaluate our approach on the Hugging Face Transformers library by representing generation hyperparameters and their constraints using a feature-based variability model, sampling representative configurations, measuring their energy consumption, latency, accuracy, and learning predictive models from the collected data. Our results show that variability modeling effectively manages the complexity of LLM inference configurations. It enables systematic analysis of hyperparameters effects and interactions, reveals trade-offs, and supports accurate prediction of inference behavior from a limited number of measurements. Overall, this work opens a new research direction that bridges software engineering and machine learning by leveraging variability modeling for the efficient and sustainable configuration of LLMs . 1. Introduction Large Language Models (LLMs) have transformed both research and industrial practices ( 65 ) , particularly in software engineering, where they now assist with code generation, bug fixing, documentation, and numerous other tasks ( 66 ) . To support their growing adoption and further improve performance, major efforts have been invested in scaling computational infrastructure and deploying optimized inference systems ( 57 ) . However, this growth raises concerns about energy efficiency and environmental impact, as LLMs and other Artificial Intelligence (AI) workloads are highly resource-intensive ( 64 ) . Recent research has sought to better characterize and mitigate the environmental footprint of LLMs during its training and inference phases. In particular, improving inference efficiency is essential for reducing costs and carbon emissions ( 67 ) , as LLMs are executed millions of times per day at a large scale, with inference accounting for over 90 % of total LLM compute cycles ( 23 ; 50 ) . Inference efficiency has thus become a central research focus, and researchers have investigated various inference parameters and their impact on diverse metrics related to energy consumption, performance and accuracy ( 53 ; 44 ; 45 ; 61 ; 17 ; 56 ; 22 ; 50 ; 57 ; 31 ; 63 ; 41 ; 23 ; 47 ; 13 ) . Some studies have focused more specifically on generation hyperparameters— i.e. , parameters that control generation behavior such as beam width, temperature, top-p or caching strategy ( 55 ; 7 ; 48 ) . However, inference servers such as Hugging Face Transformers ( 62 ) , virtual Large Language Model (vLLM) ( 40 ) , and Text Generation Inference (TGI) 1 1 1 https://github.com/huggingface/text-generation-inference exhibit a wide range of such parameters ( 49 ) . The possible combinations of these parameters result in an enormous configuration space, where interactions between options are often non-linear or implicit. This results in two main challenges: (i) configuring inference systems manually in practice is challenging, as many parameter configurations are invalid, redundant, or interdependent; and (ii) exhaustive empirical evaluation is computationally infeasible. Consequently, most recent studies focus primarily on a limited set of commonly used parameters and analyze them in isolation, without systematically exploring or modeling parameter combinations. These limitations mirror a long-standing challenge in software engineering: reasoning about highly configurable systems. Such systems are characterized by built-in variability, offering a set of configuration options that can be combined in different ways to adapt their functional behavior and performance to diverse user requirements ( 6 ; 3 ) . To manage this variability, various techniques have been developed for modeling and reasoning about large configuration spaces ( 14 ; 20 ; 54 ) . Among these, feature modeling has emerged as a foundational formalism ( 21 ; 8 ; 46 ; 9 ) . Feature Models (FMs) describes configurable systems through hierarchical features, dependencies, and constraints, and can be translated into propositional logic for automated reasoning ( 24 ) . While feature modeling has been successfully applied in domains such as cloud configuration and performance optimization, it has not, to the best of our knowledge, been used to explore the configuration space of LLMs . Instead, recent work has primarily explored the opposite direction, using LLMs to assist with variability-related tasks such as feature modeling and configuration analysis ( 2 ; 58 ; 1 ; 25 ; 36 ; 69 ; 43 ) . In this paper, we consider Hugging Face Transformers as a highly configurable system. In particular, we focus on the inference phase and its generation hyperparameters. Our goal is threefold: (i) to ease configuration by grouping all relevant generation hyperparameters and explicitly modeling their constraints; (ii) to complement existing analyses by studying how generation hyperparameters and their interactions affect energy, latency, accuracy, and the trade-offs among these measurements; and (iii) to propose predictive models for unseen configurations. Our main contributions are as follows: • Feature-based modeling of LLM inference: We encode the variability of the Hugging Face Transformers library in a publicly available feature model, and report how such a model supports systematic exploration over its vast inference configuration space. • Optimal trade-offs: Leveraging the feature model and our systematic exploration methodology, we identify configurations that achieve the best trade-off between energy consumption, latency, and accuracy in our case-study. • Prediction methodology: We develop a four-step approach—modeling, sampling, measurement, and learning—to predict energy consumption, latency, and accuracy of unseen configurations. The remainder of the paper is structured as follows. In Section 2 , we review related work. In Section 3 , we present our proposed approach. Section 4 describes the methodology used to evaluate the approach, and Section 5 reports the obtained results. Broader discussion and limitations are provided in Section 6 . Finally, we conclude the paper and outline directions for future work in Section 7 . 2. Related Work 2.1. Impact of Generation Hyperparameters on LLM Inference Performance & Energy Consumption Several studies have investigated how the inference performance, energy consumption and accuracy of LLMs are influenced by configuration choices ( 53 ; 44 ; 45 ; 61 ; 23 ; 17 ; 56 ; 22 ; 31 ; 63 ; 50 ; 57 ; 41 ; 47 ; 13 ) . Collectively, these works show that LLMs inference efficiency depends on a wide range of parameters, from model- and input-level factors to system- and hardware-level configurations. Within this body of work, generation hyperparameters are sometimes varied as part of broader experimental setups, but they are rarely the primary object of study. More recent efforts have instead focused explicitly on understanding the role of these hyperparameters. Shi et al. provide a thorough empirical evaluation of decoding hyperparameters, examining their effects on generation quality and performance across a wide range of tasks and models ( 55 ) . Arias et al. extended this work by analyzing additional hyperparameter combinations across more models and evaluating text quality with multiple metrics ( 7 ) . Finally, Nik et al. complemented these analyses by focusing specifically on how generation hyperparameters influence GPU energy consumption alongside output quality across diverse tasks and configurations ( 48 ) . Together, these studies show that LLMs inference efficiency depends on numerous parameters across different levels. However, existing work typically examines only limited subsets of parameters at each level, without considering interactions or constraints between them. This limitation can make it difficult to configure models or apply recommendations in practice, and may hide insights that could be revealed by studying such interactions. Furthermore, studies focusing particularly on generation hyperparameters still lack a comprehensive analysis of their impact on overall resource consumption, the trade-offs between latency, energy consumption, accuracy, and the development of predictive models for unseen configurations. 2.2. Application Domains of Variability Modeling Variability modeling has been widely applied in numerous domains to manage configurable software systems ( 24 ) . For instance, variability management has been particularly important for operating systems such as the Linux kernel. Kuiter et al. analyzed the evolution of its feature models over twenty years to evaluate configurations, compare metrics, and predict the future of the kernel’s configurability ( 38 ) . In the cloud domain, Quinton et al. proposed a platform relying on feature models combined with a domain model to select the most suitable cloud environment ( 52 ) . In robotics, Brugali et al. discussed software variability, domain analysis and modeling, and reference architectures for configurable robotic systems ( 11 ) . Similarly, in Internet of Things (IoT), Trujillo et al. proposed a method to manage variability across multiple SPLs and generate new product portfolios for IoT applications ( 60 ) . Even in areas such as browser fingerprinting, Huyghe et al. introduced a tool based on feature models to reason over the relationships between configuration parameters and browser fingerprints ( 32 ; 33 ) . Applications of variability modeling have also been extended to machine learning. Camillieri et al. and Ghofrani et al. applied variability management concepts to manage variability in machine learning workflows and deep neural network architectures, respectively ( 12 ; 26 ) . Finally, Gomez et al. explored the use of variability to study the creation of combined ML models ( 27 ) . However, despite these advances, the application of variability modeling to represent the configuration space of LLMs themselves remains largely unexplored. To the best of our knowledge, our work is the first to explicitly model and analyze LLMs variability using feature modeling techniques. 2.3. Learning Software Configuration Spaces A major research direction emerging from variability modeling is the sampling–measuring–learning pattern. This approach consists of learning from a small set of sampled configurations rather than exhaustively exploring the entire configuration space, which is infeasible for highly configurable systems. Pereira et al. presented a systematic literature review of the different methods proposed for each step of this pattern and highlighted applications such as prediction, optimization, and dynamic configuration ( 51 ) . Following this idea, several studies have applied the pattern across different contexts and for diverse applications. Guégain et al. explored the impact of web stack configurations on performance relying on feature models, and developed a predictive model to automate optimized configurations ( 28 ) . Kumara et al. modeled the variability of cloud environments to build performance prediction models and leveraged explainable AI to interpret model outputs ( 39 ) . Similarly, Couto et al. used the pattern to predict the energy consumption of a single software product ( 19 ) . Overall, these studies show the power of learning from configuration samples to predict performance and energy consumption in configurable systems. Our work extends these principles to the inference phase of LLMs , enabling a systematic exploration of a larger configuration space. 3. Variability-Driven Energy Prediction of LLM Inference This section presents our approach for systematically exploring the configuration space of LLM inference by leveraging variability modeling. An overview of the workflow is shown in Figure 1 . Figure 1 . Overview of the proposed approach. 3.1. Hugging Face Transformers as a Case Study For our case study, we chose the Hugging Face Transformers library ( 62 ) , an open-source library providing pretrained models for a wide range of machine learning tasks and support for both training and inference. While other inference servers optimized for production, such as vLLM ( 40 ) , could also be considered, their primary focus on performance optimization does not align with the main objective of this work. In contrast, Hugging Face Transformers offers two key advantages that are important for our investigation: (i) it is well-documented and widely adopted, and (ii) it exposes a larger set of configurable hyperparameters, which is essential for exploring the inference configuration space. 3.2. Modeling Hugging Face Transformers To systematically analyze and predict the behavior of LLMs under different inference configurations, we first need to make their variability explicit. Inference frameworks, such as Hugging Face Transformers, expose a large number of hyperparameters with complex dependencies. Given the combinatorial explosion of possible parameter combinations and their complex interdependencies, manual exploration or ad-hoc tuning is impractical. Moreover, these relationships are often scattered across documentation and source code, making systematic exploration and automated analysis impractical. To address this challenge, we represent LLM inference variability using FMs , the most widely adopted formalism for modeling configurable software systems ( 21 ; 8 ; 46 ; 9 ; 20 ) . A FM captures variability in terms of features , which can be mandatory, optional, or organized into feature groups, and expresses dependencies through cross-tree constraints ( e.g. , selecting one feature requires or excludes another). Importantly, feature models can be translated into propositional formulas, enabling automated reasoning tasks such as enumerating valid configurations, detecting invalid or dead features, and filtering configurations that satisfy given properties ( 24 ) . These capabilities are essential in our context, as the inference configuration space grows exponentially with the number of parameters. Figure 2 . The variability of Hugging Face Transformers explored in this paper. Cross-tree constraints are partially shown. Figure 2 presents the resulting feature model for Hugging Face Transformers inference. The model contains 96 features, of which 67 are concrete, resulting in approximately 9.37\times 10^{12} valid configurations, illustrating the infeasibility of exhaustive exploration without automated reasoning. Each feature corresponds either to a Boolean parameter or to a discretized value of a numerical parameter. For example, temperature_0.7 denotes that the temperature parameter is fixed to 0.7 , and do_sample enables sampling. Dependencies and constraints between features were extracted from official documentation, source code inspection, and empirical testing, ensuring that all configurations generated from the model are valid and executable. We modeled a large subset of generation hyperparameters exposed by Hugging Face Transformers, 2 2 2 https://huggingface.co/docs/transformers/main_classes/text_generation while excluding or fixing those not relevant to our study. For example, parameters such as max_length and stop_strings were fixed to prevent truncated or excessively long outputs. Because many parameters admit a wide range of values, encoding all possible values would lead to an intractable configuration space. We, therefore, discretized parameter domains following recommendations from prior work and from Hugging Face Transformers documentation ( 55 ; 7 ; 48 ) , ensuring representative variability while maintaining tractability. By explicitly modeling Hugging Face Transformers inference variability as a feature model, we make its configuration space analyzable and amenable to automation. This model serves as the foundation for the subsequent phases of our approach: systematic sampling of representative configurations, empirical measurement of energy consumption, latency, accuracy, and learning predictive models from the collected data. 3.3. Sampling LLM Configurations Given the exponential size of the configuration space, exhaustively measuring all valid LLM inference configurations is infeasible. Instead, we rely on sampling techniques to select a small yet representative subset of configurations. Prior work in the variability community has shown that such samples are sufficient to support meaningful analysis, optimization, and the construction of accurate predictive models ( 29 ; 39 ) . Several sampling strategies have been proposed to address this challenge. Among the most widely used are random sampling and interaction-aware ( t-wise ) sampling approaches. While random sampling generates valid configurations randomly, t-wise sampling explicitly targets interactions between configuration options, ensuring that combinations of up to t features are covered at least once ( 4 ) . This property is particularly important when configuration options interact in non-trivial ways, as is the case for LLM inference parameters. In this study, we adopted three complementary sampling strategies: two interaction-aware strategies based on 2-wise coverage, and one random strategy used as a point of comparison. Among the available t-wise sampling algorithms, we chose YASA ( 37 ) and ICPL ( 35 ) , both of which achieve state-of-the-art coverage efficiency. For the random strategy, we used the implementation provided by the FeatureIDE platform 3 3 3 Which we used to encode the feature model depicted in Figure 2 . and set the number of generated configurations equal to the number of features, as recommended in other studies ( 30 ; 39 ) . 3.4. Measuring LLM Inference Performance Each sampled configuration is executed and measured according to three main metrics: energy consumption, performance, and accuracy. Energy consumption We relied on software-based measurement tools commonly used in recent LLM studies ( 17 ; 50 ; 18 ; 5 ; 48 ) : perf (via the Running Average Power Limit (RAPL) interface) for CPU measurements, and nvidia-smi for GPU power draw estimation. This approach ensured full control over the measurement process and compatibility with any GPU, facilitating future extensions of this work. Code evaluation To evaluate the generated code, we assessed the functional correctness of the generated code. The functional correctness of an LLM assesses the extent to which the generated code satisfies the specification provided in the prompt. We thus adopted the pass@k metric based on the unbiased estimator introduced by Chen et al. ( 15 ) , which measures the probability that at least one of k generated samples passes all test cases. Formally, for n total samples, c correct samples, and E denoting the expectation over all problems, pass@k is defined as: \text{pass@}k:=\mathbb{E}_{\text{Problems}}\left[1-\frac{\binom{n-c}{k}}{\binom{n}{k}}\right] We used n=1 sample per problem to compute pass@1. Performance We evaluated performance by measuring latency, defined here as the time elapsed between submitting a request and receiving its response. 3.5. Learning & Validation After collecting measurements across all sampled configurations, we use the resulting dataset to train and validate predictive models of LLM inference behavior. Our goal is to assess whether models trained on a limited yet representative set of configurations can accurately predict energy consumption and accuracy for unseen configurations. We relied on Random Forest Regression (RFR) ( 10 ) , a tree-based learning technique that has been widely adopted for learning software configuration spaces ( 51 ) . Model selection was performed through grid search combined with k -fold cross-validation on the training set. Once the best configuration was selected, the model was retrained on the full training set and evaluated on a test set obtained from a 80 % / 20 % train–test split. To evaluate prediction accuracy, we used two complementary and widely adopted standard metrics ( 16 ) : • Coefficient of Determination (R²) : quantifies the proportion of variance in the target metric explained by the model. Values range from 0 to 1 , with higher values indicating better model performance; however, R² can be negative if the model performs worse than a simple baseline predicting the mean. • Mean Absolute Error (MAE) : calculates the average absolute difference between predicted and observed values. It provides a linear measure of prediction error in the same units as the target variable. Lower MAE values indicate higher predictive accuracy. • Mean Absolute Percentage Error (MAPE) : extends MAE by expressing the error as a percentage of the observed values, effectively normalizing the absolute error relative to the magnitude of the target. Lower MAPE values indicate higher predictive accuracy. 4. Methodology This section describes the methodology employed to evaluate our proposed approach. We first present the addressed research questions, followed by a description of the dataset. We then introduce the selected LLMs , outline the experimental setup, and detail the conducted experiments. 4.1. Research Questions RQ1 : To what extent does variability modeling enable the systematic identification of LLM inference configuration, options, and interactions that impact energy consumption, performance, and accuracy? RQ2 : Which Pareto-optimal trade-offs between energy consumption, performance, and accuracy can be identified? RQ3 : To what extent can machine learning models accurately predict energy consumption, performance, and accuracy for unseen LLM inference configurations? 4.2. Dataset To evaluate our approach, we focused on LLM tasks involving code generation, as they naturally support quantitative evaluation through automated testing. Among existing datasets, HumanEval ( 15 ) is the most widely adopted benchmark for this purpose. 4 4 4 https://huggingface.co/datasets?other=code-generation It contains 164 hand-written Python programming problems, each associated with reference implementations and unit tests, which make it well-suited for evaluating functional correctness via the pass@k metric. For this study, we used HumanEval+ ( 42 ) , an extended version of HumanEval that provides more rigorous and comprehensive test cases. We used the original problem prompts without applying any additional prompt engineering or task-specific prompting strategies. 4.3. Selected LLMs We selected LLMs from the BigCodeBench leaderboard, 5 5 5 https://bigcode-bench.github.io/ a benchmark designed to evaluate LLMs on its true programming capabilities ( 68 ) . We applied three selection criteria: (i) open-source availability, (ii) model size under 8B parameters, and (iii) full access to the decoding hyperparameters evaluated in this study. We focused on open-source LLMs to ensure accessibility and facilitate reproducible experimentation. We also limited our selection to models with fewer than 8B parameters, as experiments with larger models would have been slower and more resource-intensive with Hugging Face Transformers, without offering additional value to this study. From the leaderboard, we selected the two highest-performing models that satisfied these criteria at the time of our experiments. To enable comparative analysis, we included one additional model: the smaller counterpart of the first model. The selected models are listed in Table 1 . For clarity, throughout the remainder of the paper, we refer to each model by its family name and size only, e.g. , Qwen-7B for Qwen2.5-Coder-7B-Instruct . Table 1 . LLMs considered in our study. Size is in billions of parameters. LLM Model Model family Sizes OpenCoder-8B-Instruct infly 8 B Qwen2.5-Coder-7B-Instruct Qwen 7.62 B Qwen2.5-Coder-3B-Instruct Qwen 3.09 B 4.4. Experimental Setup By following the approach described above, we evaluated each of the 254 configurations ( 77 YASA, 81 ICPL, and 96 RANDOM) produced by our sampling algorithms using the 164 prompts of HumanEval+ and our three selected LLMs . Each configuration was executed ten times, resulting in 7{,}620 runs and 1{,}249{,}680 prompts. To mitigate potential hardware-induced bias, the 7{,}620 configurations were randomly distributed across our machines. To run our experiments with Hugging Face Transformers, we used device_map="auto" to load the model across our GPUs. All models were run with bfloat16 precision, a fixed batch size of 32 , and a maximum token of 512 . Before evaluating each configuration, we performed an internal calibration phase of 30 seconds ( 18 ) . This calibration serves two purposes: (i) adjusting the measurement coefficient that converts raw hardware counters into actual energy units, ensuring that subsequent energy measurements are accurate; and (ii) capturing the idle consumption, during which the system remains at rest, providing a baseline energy level and allowing a short cool-down before launching the next configuration. Across all experiments, idle consumption measurements exhibited a coefficient of variation of 0.02 , indicating high measurement stability. In addition to this internal calibration, we introduced a warm-up phase before measuring energy consumption for GPU workloads. This phase mitigates cold-start effects such as memory allocation, CUDA graph capture, and just-in-time (JIT) kernel compilation ( 22 ) . Without this warm-up, the first iterations would include overheads, potentially biasing energy and performance measurements. The warm-up phase used the experiment’s batch size with the longest prompts to simulate worst-case inference. Each configuration was warmed up six times with identical hyperparameters, a number determined by a preliminary benchmark to ensure energy measurements stabilized within a 3% threshold over three consecutive runs. In our results, the measured energy consumption of each configuration therefore corresponds to the execution of all 164 prompts, reported as the mean value over the ten repetitions. We report the absolute energy consumption— i.e. , total power usage including background processes. Nevertheless, the idle power, together with the energy measured during the evaluation of each configuration, can be used to compute the marginal energy consumption of the samples— i.e. , the additional energy solely caused by the execution of the workload, excluding baseline consumption ( 34 ) . All experiments were conducted on a node equipped with an AMD EPYC 7513 (Zen 3) processor, 512 GiB of memory, and 4 Nvidia A100-SXM4-40GB (40 GiB) GPUs. The system ran Debian 11 (Bullseye) with the Linux 5.10.0-28-amd64 kernel. 5. Results This section presents the experimental results addressing the three research questions introduced in this study. RQ1 : To what extent does variability modeling enable the systematic identification of LLM inference configuration, options, and interactions that impact energy consumption, performance, and accuracy? Figure 3 shows variations in energy consumption and accuracy across all configurations generated by all sampling methods for each selected LLMs . Qwen-3B and OpenCoder-8B align closely in terms of energy consumption and latency for approximately 85% of configurations, indicating similar efficiency. After 40%, OpenCoder-8B starts diverging slightly from Qwen models, consuming more resources. Beyond 80%, the gap widens: Qwen models remain tight, while OpenCoder-8B shifts sharply to the right, indicating higher energy costs and latency. Regarding accuracy (Pass@1), the distributions are similar up to 60% of configurations. At the upper end, Qwen-3B and OpenCoder-8B reach the same maximum accuracy, with Qwen-7B surpassing them by a small margin. Figure 3 . Cumulative Distribution Function (CDF) of energy consumption, performance and accuracy across different configurations for each evaluated LLM . Feature-wise Analysis . To assess the impact of individual inference hyperparameters on energy consumption and accuracy, we adopt the feature-wise analysis proposed by Guégain et al. ( 29 ) . This method isolates the contribution of each feature to a given metric by aggregating measurements across sampled configurations. Concretely, a matrix of size n\times m is constructed, where n denotes the number of features and m the configurations. For each configuration, the observed metric value is assigned to the columns corresponding to the features it contains, while all other entries remain zero. For example, if a configuration C includes features F1 and F3 and consumes 50 kJ, the corresponding entries for F1 and F3 are set to 50 kJ. This method provides an aggregated, feature-level view of their impact. Table 2 reports five hyperparameters values with the strongest impact on energy consumption, latency, and accuracy as identified by feature-wise analysis. On the energy and latency dimensions, the same features consistently appear as the most influential, showing a strong correlation between energy consumption and latency. In both measurements, using an offloaded cache leads to the largest increase in energy consumption. The cache implementation feature determines how key–value (KV) pairs are stored and reused during generation. Offloading the cache transfers KV data between GPU and CPU memory to reduce GPU memory usage, but this mechanism introduces significant data transfer overhead. In contrast, alternative cache implementations—such as dynamic ( C1 ), hybrid ( C2 ), and static ( C4 )—exhibit consistently lower energy consumption, as illustrated in Figure 4 . These cache strategies exhibit similar trends across all evaluated LLMs . Beyond cache implementation, the number of beams and beam groups, both fixed at 4 , are also among the features with the strongest impact on energy and latency. The number of beams controls how many parallel hypotheses are explored during generation, while beam groups further partition the beams into independent groups, which require additional forward passes. Both mechanisms increase the number of forward passes per token, leading to higher computational cost, and increased latency and energy consumption. Figure 4 . Feature-wise analysis of energy consumption per cache implementation. C1 , C2 , C3 and C4 correspond to the dynamic , hybrid , offloaded , and static configurations, respectively. Table 2 . Top five features with the strongest impact (absolute value) on energy consumption, latency and accuracy, identified by the feature-wise analysis. (a) Energy consumption ( \Delta Energy, in kJ). Feature Value \boldsymbol{\Delta} Energy cache offloaded +89.48 num-beam-group 4 +58.03 num-beams 4 +50.30 diversity-penalty 0.4 +46.81 decoding diverse +45.69 (b) Latency ( \Delta Latency, in s). Feature Value \boldsymbol{\Delta} Latency cache offloaded +233.51 num-beam-group 4 +129.35 num-beams 4 +111.83 diversity-penalty 0.4 +100.66 decoding diverse +100.37 (c) Accuracy ( \Delta Pass@1). Feature Value \boldsymbol{\Delta} Pass@1 no-repeat-ngram-size 0 +0.68 decoding greedy +0.46 encoder-repetition 1.0 +0.41 repetition-penalty 1.0 +0.24 low-memory True -0.23 Table 3 . Top-5 feature combinations with greedy search that have the strongest impact (absolute value) on energy consumption and accuracy, identified by the pair-wise analysis. (a) Energy consumption ( \Delta Energy, in kJ). Feature Value \boldsymbol{\Delta} Energy cache static +13.76 encoder-repetition-p 1.3 +13.76 do-sample True -8.59 top-k 5 +7.04 temperature 0.3 -2.2 (b) Latency ( \Delta Latency, in s). Feature Value \boldsymbol{\Delta} Latency cache static +48.12 encoder-repetition-p 1.3 +48.12 do-sample True -21.79 top-k 5 +20.87 top-p 0.8 -7.46 (c) Accuracy ( \Delta Pass@1). Features Value \boldsymbol{\Delta} Pass@1 repetition-penalty 0.6 -0.65 do-sample True +0.37 encoder-repetition-p 1.3 -0.36 top-p 0.8 +0.23 temperature 1.2 -0.20 Regarding accuracy, hyperparameters related to repetition control, decoding strategy, and memory usage dominate. The no-repeat-ngram parameter prevents the model from generating repeated sequences of n consecutive tokens. Setting it to 0 allows the most freedom and is efficient for accuracy in our use-case. The low-memory parameter reduces memory usage during generation by recomputing certain operations instead of keeping them in GPU memory. While this saves resources, its activation can slightly degrade the quality of token predictions and therefore impact negatively the accuracy. Finally, the decoding strategy, which determines how the next token is selected, is also present among the most impactful feature on accuracy. Greedy decoding, which always selects the token with the highest predicted probability at each step, improves accuracy in our experiments. Figure 5(b) confirms this observation, showing that greedy search ( D4 ) decoding achieves the highest accuracy among the tested strategies, beam search multinomial sampling ( D1 ), contrastive search ( D2 ), diverse beam search ( D3 ) and multinomial sampling ( D5 ). At the same time, it is also the least energy-intensive decoding implementation according to Figure 5(a) , making it the most efficient decoding strategy overall. Pairwise Analysis . To analyze interactions between generation hyperparameters, we apply the second method proposed by Guégain et al. ( 29 ) , referred to as pairwise analysis . Unlike feature-wise analysis, which considers features independently, this method captures the combined effect of feature pairs on a given metric. Concretely, a matrix is constructed with one column per valid pair of features. For each sampled configuration, the measured metric value is assigned to all columns representing pairs of features included in that configuration. While the feature-wise analysis identified several hyperparameters with individual effects—such as dynamic caching and greedy decoding—the pairwise analysis allows us to assess whether these effects depend on specific combinations with other parameters or can be further amplified through interactions. To illustrate this, we focus on configurations using greedy search decoding 6 6 6 Similar analysis can be performed for any other feature using the replication package described in Section 4 . . We fix the decoding strategy to greedy search and report, in Table 3 , the top five feature combinations, whose values differ from the default configuration, and exhibit the strongest impact on energy consumption, latency, and accuracy. For energy consumption and latency, we again observe nearly identical rankings, reinforcing the strong correlation between these two metrics. Combinations of greedy search decoding with hyperparameters such as cache , encoder-repetition-penalty , do_sample , top-k , and top-p show the strongest impact. For instance, a static cache increases the energy consumption by 13.76 kJ and latency by over 48.12 , while enabling do_sample reduce them by 8.59 kJ and 21.79 s, respectively. Regarding accuracy, the most significant effects arise from interactions between greedy search and parameters such as repetition-penalty , do-sample , top-p and temperature . For example, setting repetition-penalty to 0.6 decline accuracy by 0.65 , and fixing top-p to 0.8 improves Pass@1 by 0.23 . Notably, some parameter values—such as top-p set to 0.8 —appear among the most influential combinations for latency, and accuracy, suggesting configurations that offer favorable trade-offs across all metrics. RQ1: By leveraging variability modeling, we systematically identified how inference hyperparameters influence energy consumption, latency, and accuracy, both individually and through interactions. In our case-study, energy consumption and latency are strongly correlated, and are primarily driven by features such as offloaded cache and hyperparameters that increase the number of forward passes and the diversity of hypotheses considered during generation. Accuracy, in contrast, is mainly affected by features related to decoding strategy, repetition control, and memory optimization. While several efficient features correspond to the default settings of Hugging Face Transformers—such as dynamic caching and greedy decoding—our results show that these defaults can be further improved when combined with carefully chosen complementary parameters. (a) Feature-wise analysis of energy consumption per decoding implementation. (b) Feature-wise analysis of pass@1 per decoding implementation. Figure 5 . Feature-wise analysis of performance and energy consumption across decoding implementations. D1 , D2 , D3 , D4 and D5 correspond to the beam search multinomial sampling , contrastive search , diverse beam search , greedy search and multinomial sampling configurations, respectively. RQ2: Which Pareto-optimal trade-offs between energy consumption, performance, and accuracy can be identified? To analyze trade-offs between these measurements, we computed the Pareto front over the empirically measured configurations for all the selected LLMs , as shown in Figure 6 . It represents configurations that cannot be improved on one metric without degrading another, thereby identifying the most efficient trade-offs in the configuration space. We focused on energy consumption and accuracy, since latency was shown in RQ1 to be strongly correlated with energy. Two configurations with a Pass@1 score of zero were excluded, as well as configurations exceeding 70 kJ, since they do not correspond to practically usable inference settings and their removal improves the clarity of the figure. The results show that accuracy improvements exhibit diminishing returns as energy consumption increases. In the initial low-energy phase (approximately 20 - 25 kJ), small increases in energy lead to large gains in accuracy, with Pass@1 improving from 0.66 (with Qwen-3B ) to 0.75 (with Qwen-7B ). For Qwen-3B , sampling is not always activated, dynamic caching is used, along with a single beam and beam group, a low temperature of 0.3 , and top-p set to 0.8 when sampling is enabled. For Qwen-7B , dynamic caching is employed with either greedy or contrastive decoding. When sampling is disabled, default sampler parameters are used, and when it’s enabled, temperature is set to 0.1 and top-p to 0.95 . Configurations using Qwen-7B in this phase achieve an increase of 0.09 in accuracy compared to Qwen-3B , while consuming 7 - 10\% more energy. In the balanced phase (around 35 - 40 kJ), accuracy gains become more moderate, increasing from 0.75 to 0.77 . The corresponding configurations consistently use Qwen-7B with dynamic caching, beam search multinomial with two beams, sampling enabled, low temperatures ( 0.1 – 0.3 ), low top-k values ( 5 – 25 ), and top-p values of 0.8 – 0.85 . Finally, in the high-accuracy phase ( 49 - 64 kJ), Pass@1 reaches a maximum of 0.80 , with energy consumption increasing by up to 66\% compared to the balanced phase. These configurations employ Qwen-7B with dynamic, static, or hybrid caching, more aggressive decoding strategies such as beam search with three to four beams, temperatures ranging from 0.1 to 0.7 , and top-p values from 0.8 to 1.0 . Figure 6 . Pareto front illustrating the trade-offs between energy consumption and accuracy across the different configurations and selected LLMs . RQ2: By combining feature modeling, systematic exploration, and Pareto analysis, we identify distinct classes of inference configurations that balance trade-offs between energy, latency, and accuracy. Most accuracy gains can be achieved in a low-energy regime using dynamic caching, greedy or contrastive decoding, a single beam and default sampling parameters or a combination of low temperature and high top-p. Balanced configurations increase energy consumption by introducing two-beam search, sampling with low temperature, smaller top-k, and high top-p values. Achieving the highest accuracy requires much more energy and more complex configurations, with dynamic, hybrid or static cache, 3 – 4 beams, low temperature and high top-p. Table 4 . Optimal configurations for each objective and their impact on energy and accuracy. Objective Energy-efficient Balanced High accuracy Model Qwen-3B Qwen-7B Qwen-7B Qwen-7B Qwen-7B Qwen-7B Qwen-7B Cache Dynamic Dynamic Dynamic Dynamic Dynamic Static Hybrid Decoding Greedy Greedy Contrastive Beam Search Multi Beam Search Multi Beam Search Multi Beam Search Multi Number of beams 1 1 1 2 3 3 4 Beam groups 1 1 1 1 1 1 1 Sampling Partial \times ✓ ✓ ✓ ✓ ✓ Temperature 0.3 / 1.0 1.0 0.1 0.1 / 0.3 0.3 0.1 0.7 Top-k 50 50 50 5 / 25 50 50 5 Top-p 0.8 / 1.0 1.0 0.95 0.8 / 0.85 0.8 0.8 1.0 Avg accuracy 0.66 0.75 (+0.09) 0.75 (+0.00) 0.77 (+0.02) 0.79 (+0.02) 0.80 (+0.01) 0.80 (+0.00) Avg energy (kJ) 21.79 23.31 (+7%) 25.59 (+10%) 38.35 (+29%) 49.33 (+28.63) 52.82 (+7%) 63.77 (+20.73%) RQ3: To what extent can machine learning models accurately predict energy consumption, performance, and accuracy for unseen LLM inference configurations? Table 5 reports the prediction performance of our models for energy consumption, latency, and accuracy (Pass@1) across different LLMs and sampling strategies. The MAPE is not reported for accuracy models due to the presence of null values, which are incompatible with MAPE . Overall, the results indicate that accurate prediction of unseen inference configurations is achievable. However, predictive performance strongly depends on both the target metric and the sampling strategy used to construct the training set. Models trained on configurations generated by all three samplers ( ALL ) consistently achieve the best results across all metrics. They achieve R^{2} values of 0.95 for energy, 0.94 for latency, and 0.99 for accuracy, along with the lowest errors: for energy, MAE 10.05 and MAPE 0.16 ; for latency, MAE 23.78 and MAPE 0.17 ; and for accuracy, MAE 0.01 . This demonstrates the benefit of combining diverse sampling strategies when constructing the training set, as it provides richer and more representative training data. Considering individual samplers, performance varies depending on the metric. The 2-wise sampler ( ICPL ) consistently underperforms, yielding the highest errors and lowest R^{2} values: for energy, MAE 19.59 and R^{2} 0.74 ; for latency, MAE 37.77 and R^{2} 0.78 . Concerning accuracy, the results are almost identical. This suggests that relying solely on ICPL-generated configurations is insufficient to capture the variability of inference behavior. In contrast, YASA achieves competitive performance across all metrics. For energy and latency, it outperforms RANDOM in terms of R^{2} , while for accuracy, it reaches the best R^{2} ( 0.01 ) and lowest MAE ( 0.99 ), tied with the ALL sampler. Interestingly, RANDOM sampling is also relatively effective compared to other samplers, indicating that even simple or uniform sampling strategies can provide informative training data. RQ3: Overall, the results show that machine learning models can accurately predict energy consumption, latency, and accuracy for unseen LLM inference configurations when trained on representative samples of the configuration space. Prediction quality, however, depends on both, the target metric and the sampling strategy. Consistent with prior work showing that a single well-chosen sample can yield sufficiently accurate models ( 39 ) , our results confirm that limited data can be effective. At the same time, the models benefit from increased diversity in the training data, making the combination of multiple sampling strategies particularly effective. 6. Discussion & Limitations In this section, we discuss some implications of our approach, and outline the limitations of our study. 6.1. Practical Usage & Implications Our results show how variability modeling, combined with empirical measurements and predictive models, can serve as a foundation for managing the complexity of LLM inference configuration. By explicitly structuring the configuration space and encoding valid options and interactions, feature models enable systematic exploration while preventing invalid or unsupported configurations. They offer a clear advantage over ad hoc or trial-and-error tuning approaches, particularly in complex inference settings with numerous interacting hyperparameters. Beyond analysis, our approach lays the foundation for increased automation in inference configuration. By combining variability modeling with empirical analysis and learned predictors, it becomes possible to automatically recommend inference configurations tailored to user-specific objectives, such as minimizing energy consumption, maximizing performance, or maintaining a target level of accuracy. In practice, this could support configuration assistants that recommend efficient inference setups, guiding users toward valid and efficient configurations while abstracting away low-level parameter interactions. Inference frameworks expose heterogeneous configuration spaces, with options, parameter names, and supported features differing across inference servers. This heterogeneity suggests using inference server–specific feature models that capture platform-dependent variability, rather than relying on a single feature model. These models could be connected through a higher-level abstraction, such as an abstract feature model supported by a domain-specific language, providing a unified interface for configuring inference across platforms. Such an abstraction would allow platform-specific configurations to be automatically generated and optimized according to user objectives. Table 5 . Overall prediction performance across energy, latency, and accuracy. Best results are highlighted in green, while the worst results are shown in red. (a) Prediction performance for energy (kJ). Sampler MAE \mathbf{R^{2}} MAPE YASA 12.23 0.94 0.25 ICPL 19.59 0.74 0.25 RANDOM 15.94 0.91 0.30 ALL 10.05 0.95 0.16 (b) Prediction performance for latency (s). Sampler MAE \mathbf{R^{2}} MAPE YASA 27.72 0.93 0.25 ICPL 37.77 0.78 0.23 RANDOM 32.99 0.91 0.32 ALL 23.78 0.94 0.17 (c) Prediction performance for pass@1. Sampler MAE \mathbf{R^{2}} YASA 0.01 0.99 ICPL 0.02 0.97 RANDOM 0.02 0.96 ALL 0.01 0.99 6.2. Limits & Threats to Validity While our study provides valuable insights into leveraging variability modeling for the efficient and sustainable configuration of LLM , several limitations and threats to validity must be considered. External validity. Our evaluation relies on a single dataset, HumanEval+ , which focuses on code generation. As a result, it does not capture the diversity of inference behaviors observed in other tasks such as summarization and translation. Consequently, the relationship between configuration parameters and metrics such as energy consumption, latency, and accuracy may differ across tasks and datasets, limiting the external validity of our findings. Similarly, all experiments were conducted using a single inference server, Hugging Face Transformers. Although this framework offers fine-grained control over generation parameters, it is not representative of all inference servers, that may expose different configuration options or implement similar parameters differently. Extending the analysis to other inference platforms could therefore reveal additional constraints and interactions that may influence energy consumption, latency, and accuracy. In addition, our study considered only three LLMs . Given the rapid evolution of LLM architectures, training techniques, and optimization methods, the observed results may not generalize to other models or future systems. Despite these limitations, the proposed approach is generic and can be applied to other datasets, inference servers, and LLMs , provided that an appropriate variability model is defined. Construct validity. The proposed feature model has inherent limitations. Due to the large number of available hyperparameters, we selected only those relevant to our use case, and continuous parameters were discretized into a limited set of representative values. While this was necessary to keep the configuration space tractable, it may hide finer-grained effects or overlook configurations that could yield different trade-offs. Moreover, some dependencies and constraints between parameters may not be fully captured by the feature model. This is reflected by the fact that approximately 3\% of the generated configurations could not be executed successfully, indicating incomplete or missing constraints. Internal validity and reproducibility. All measurements were conducted on NVIDIA A100 GPUs in a controlled environment. While this experimental setup ensures consistency and reproducibility, it does not capture the full variability of hardware configurations and deployment environments encountered in practice, which can significantly influence inference behavior. Feature modeling challenges. AI and LLM ecosystems evolve rapidly, with new architectures, quantization techniques, and serving frameworks emerging frequently. As a result, feature models require continuous maintenance to remain aligned with this evolution, which can hinder reproducibility and long-term generalization. Beyond generation hyperparameters, other factors such as hardware configuration and deployment environment also influence inference behavior. Including these additional sources of variability would increase the complexity of the variability model and complicate both its construction and maintenance. In particular, hardware-related parameters can make constraint generation more difficult, and failures—such as out-of-memory errors—are harder to interpret, as they may arise from multiple interacting factors. These challenges, however, are well-known in the variability modeling community. Prior work has explored the use of machine learning techniques for automatic constraint inference ( 59 ) , and several studies have investigated strategies for managing evolving variability models ( 46 ) . 7. Conclusion & Future Work Variability modeling techniques have long been used to manage and reason about configurable software systems. In this paper, we extend this perspective to LLMs , viewing their inference process as a highly configurable system characterized by numerous interdependent hyperparameters. By representing these configurations through feature modeling, we bridge the gap between the variability management and machine learning communities. Our results show that variability modeling provides a systematic framework for exploring the complex configuration space of LLMs . It enables structured analysis of how individual and combined parameters affect metrics such as energy consumption, performance, accuracy, and supports the construction of predictive models capable of estimating these metrics for unseen configurations. This approach directly addresses the combinatorial explosion inherent to exhaustive configuration exploration, allowing trade-offs to be evaluated more efficiently. Looking forward, we plan to extend this work by: (i) enriching the variability model to incorporate additional variability level, such as hardware configurations and deployment options; (ii) leveraging our approach for adaptive reconfiguration during inference, enabling runtime trade-off management; and (iii) extending the methodology to other inference servers, datasets, and models. Data Availability All code, notebooks, and supplementary information regarding hyperparameter choices and experimental setup are publicly available, along with the data supporting the findings of this study, at https://doi.org/10.5281/zenodo.17375044 .