Abstract: Efficiently managing compute resources for Large Language Model (LLM) inference remains challenging due to the inherently stochastic and variable lengths of autoregressive text generation. Accurately estimating response lengths in advance enables proactive resource allocation, yet existing approaches either bias text generation towards certain lengths or rely on assumptions that ignore model- and prompt-specific variability. We introduce CASTILLO, a dataset characterizing response length distributions across 13 widely-used open-source LLMs evaluated on seven distinct instruction-following corpora. For each $\langle$prompt, model$\rangle$ sample pair, we generate 10 independent completions using fixed decoding hyper-parameters, record the token length of each response, and publish summary statistics (mean, std-dev, percentiles), along with the shortest and longest completions, and the exact generation settings. Our analysis reveals significant inter- and intra-model variability in response lengths (even under identical generation settings), as well as model-specific behaviors and occurrences of partial text degeneration in only subsets of responses. CASTILLO enables the development of predictive models for proactive scheduling and provides a systematic framework for analyzing model-specific generation behaviors. We publicly release the dataset and code to foster research at the intersection of generative language modeling and systems.
Introduction
In the ecosystem of LLM serving, efficiency is paramount. Inference is typically divided into two distinct phases: the prefill phase, which processes the input prompt with high parallelism and speed, and the decode phase, which generates output tokens sequentially. The decode phase is memory-intensive, relatively slow, and its duration is inherently unpredictable.
The primary scheduling challenge arises from this unknown duration. Overestimating response length leads to wasted GPU memory, while underestimating it can cause latency spikes or out-of-memory errors. Current solutions often rely on oversimplified assumptions—like assuming all models behave similarly or that a prompt always results in a consistent length. CASTILLO addresses the lack of empirical data on how response lengths actually distribute across different models and tasks.
The CASTILLO Dataset
The authors developed CASTILLO (CharActerizing reSponse lengTh dIstributions in Large Language mOdels) using a systematic multi-sample approach. Instead of a single generation, they produced 10 independent completions for every <prompt, model> pair using fixed decoding hyperparameters (e.g., temperature and top-p). This methodology captures the stochastic nature of LLMs—the reality that the same model can produce significantly different response lengths for the same input.
The dataset covers 13 open-source LLMs from the Llama, Mistral, Qwen, Phi, and Gemma families, ranging from 1B to 70B parameters. These were evaluated against seven distinct instruction-following and code-generation corpora, including general-purpose sets (Dolly, ShareGPT, Alpaca) and code-oriented sets (Mbpp, Apps, DS-1000, BigCodeBench).
Analysis of Response Variability
Analysis of the CASTILLO data reveals three critical dimensions of variability:
- High Intra-Model Variability: Even with fixed settings, response lengths vary wildly. The Coefficient of Variation (CV) reached as high as 45% for some models, meaning the standard deviation can be nearly half the size of the average response length.
- Inter-Model Disparity: Models are not interchangeable. A model might be concise on one prompt while another is verbose, but they may swap roles on a different task. This underscores that length predictors must be model-specific.
- Task-Specific Volatility: Coding tasks generally elicit longer responses and exhibit much higher variance than general chat, making code-generation significantly harder to schedule efficiently.
Key Results and Implications
The study identified significant patterns in model behavior, particularly regarding "text degeneration" (pathological repetition or incoherence). Smaller models, specifically the Llama-1B variant, accounted for over 40% of all degeneration cases. In contrast, models like gemma-12B and minist-8B showed zero degeneration across the test sets.
As shown in the heatmaps, mean response sizes can vary by several hundred tokens across different model/dataset combinations even under identical settings. By releasing this dataset, the authors provide the community with the necessary data to build "proactive" schedulers that can accurately predict resource requirements by analyzing the prompt and model ID before generation begins.
Limitations and Future Work
CASTILLO currently focuses on Transformer architectures and default decoding settings. Future research will explore how varying hyperparameters like temperature affects length distributions and extend the analysis to newer architectures like State-Space Models (SSMs). Additionally, reasoning-heavy models using Chain-of-Thought (CoT) present a new challenge, as the distribution of reasoning tokens may differ significantly from the final answer tokens, requiring further specialized characterization.
Summary updated