TL;DR
This paper tackles the significant resource and latency challenges of deploying large language models (LLMs) for inference. They propose a novel approach that jointly optimizes caching of previous queries and a model multiplexer that intelligently selects the best model for each query, achieving substantial cost reductions and performance improvements.
What Problem Does This Paper Address?
Large Language Models (LLMs) have revolutionized AI capabilities, but their sheer size makes them resource-intensive and slow for inference. This is a major bottleneck for real-world deployment, especially in high-throughput systems like search engines. The auto-regressive nature of LLMs further exacerbates latency issues, as they generate text token by token. The authors aim to mitigate these challenges by combining two strategies: caching frequently seen queries to avoid recomputation and using a "model multiplexer" to intelligently choose between different models (e.g., a small, fast model versus a larger, more accurate one) for processing queries.
Methods
The core of the paper lies in developing theoretical frameworks and algorithms for jointly optimizing caching and model multiplexing. They propose an optimal algorithm for both offline (learning from a fixed dataset) and online (learning from a stream of queries) settings.
- Caching: They build upon existing caching strategies like Least Expected Cost (LEC) and Greedy Dual Size with Frequency (GDSF). The key innovation is adapting these to the LLM inference context, considering factors like fuzzy matching for prompts (since exact matches are rare) and the inherent randomness in query costs.
- Model Multiplexing: They introduce a policy that learns to select the most appropriate model for a given query. This policy aims to minimize the expected cost, which is a function of the individual model costs and their estimated frequencies.
- Joint Optimization: The paper's main contribution is the theoretical framework for jointly optimizing both caching and model selection. They derive algorithms that aim to minimize the total inference cost by considering how caching decisions affect model selection and vice-versa. They also provide theoretical guarantees on the performance (regret bounds) of their proposed algorithms.
Datasets
- Synthetic Datasets: Used for algorithm analysis and simulations to evaluate performance under controlled conditions, varying parameters like cost ratios and model accuracy.
- Real Datasets:
- Lambada: Used for next-token prediction tasks, employing OPT-1.3B and OPT-13B models.
- OpenAssistant: Used for chat assistant tasks, employing FastChat-T5-3B and Vicuna-13B models.
Key Insights and Ideas
- Joint Optimization is Crucial: The paper demonstrates that simply optimizing caching or model selection in isolation is suboptimal. The true gains come from a synergistic approach where caching informs model selection and vice-versa.
- Cost Awareness is Key: Unlike traditional caching that focuses on frequency, LLM inference requires a cost-aware approach. The cost of processing a query can vary significantly based on the model used and the query itself.
- Fuzzy Matching for LLMs: The discrete and exponentially large nature of LLM prompts necessitates approximate matching in caching, moving beyond exact query storage.
- Randomness in Costs: The inherent variability in LLM inference costs (due to auto-regressive generation and response length) requires robust estimation and decision-making strategies.
Key Results
- Theoretical Guarantees: The authors provide theoretical bounds showing that their jointly optimized algorithms achieve optimal rates in both offline and online settings.
- Empirical Improvements:
- Simulations: Up to a 50x improvement over baselines when the cost ratio (max cost / min cost) is 100.
- Real Datasets (FLOPs): A 4.3x improvement on the Lambada dataset when the FLOPs ratio is 10.
- Real Datasets (Latency): A 1.8x improvement on the OpenAssistant dataset when the average latency ratio is 1.85.
- The proposed LEC caching combined with a model switcher consistently outperformed baselines like LFU and model-only approaches.
Limitations and Future Work
- Tabular Assumption: The theoretical analysis primarily relies on a tabular setting, where the set of possible queries is finite. Extending this to continuous or very large query spaces remains an open challenge.
- Model Multiplexer Accuracy: The performance of the model multiplexer is crucial. The authors acknowledge that if the multiplexer is inaccurate, simpler strategies like cascade (always trying a small model first) might perform better. Future work could focus on training more accurate and lightweight multiplexers.
- Query Queues and Batching: The current framework assumes queries arrive individually. Future work could explore handling query queues and batching strategies for more efficient inference.
- Response Quality: The current cost functions primarily focus on FLOPs or latency. Incorporating response quality (e.g., user satisfaction) as a cost factor is a promising direction.
- Variable Cache Sizes: While briefly discussed, a more in-depth analysis of variable cache sizes for different queries could be beneficial.
Summary updated