Abstract
Large Language Model (LLM) serving faces a significant challenge in balancing response quality with operational costs and latency. While offloading to smaller models or using semantic caching are common strategies, they often compromise accuracy or fail to handle semantic variations. We present IC-Cache, a novel serving system that enhances small LLMs by prepending them with high-quality in-context examples derived from larger "teacher" models. IC-Cache utilizes a two-stage example selector and a bandit-based router to dynamically optimize the serving process. Our evaluation shows that IC-Cache achieves up to 5.9x higher throughput and 71% lower latency while maintaining quality parity with significantly larger models.
Introduction
The deployment of state-of-the-art LLMs like DeepSeek-R1 or Gemini-1.5-Pro is constrained by high computational costs and inference latency. Current mitigation strategies, such as offloading to smaller models, often result in degraded response quality. Semantic caching, while efficient, is limited by its inability to generalize across minor prompt variations. IC-Cache addresses these issues by transforming historical interactions into educational examples, allowing smaller, more efficient models to emulate the capabilities of larger models through in-context learning.
System Architecture
IC-Cache implements a "live capability augmentation" framework consisting of several key components:
- Two-Stage Example Selector: To ensure that prepended examples are truly beneficial, the system first filters for semantic relevance and then employs a lightweight proxy model (e.g., TinyBERT) to estimate the utility of an example for the specific target model.
- Bandit-Based Request Router: A contextual Multi-Armed Bandit (MAB) learns to route requests between small, augmented models and large teacher models. This router adapts to system load, prioritizing quality during low traffic and efficiency during bursts.
- Cache Management: The system uses a cost-aware cache replay mechanism to refine frequently used examples and a knapsack-based eviction strategy to maximize efficiency gain per byte of memory.
Workload Characterization
Real-world LLM workloads often exhibit significant temporal variation and semantic overlap. Analysis of millions of requests reveals that over 70% of queries have semantically similar historical counterparts, providing a rich source of potential in-context examples.
Experimental Results
We evaluated IC-Cache across diverse datasets including LMSys-Chat-1M, MS MACRO, and specialized reasoning tasks. The results demonstrate substantial improvements in serving efficiency. IC-Cache reduced Time to First Token (TTFT) and Time Between Tokens (TBT) significantly compared to baseline systems like vLLM. Notably, small models (e.g., 2B parameters) augmented with IC-Cache often outperformed much larger models (e.g., 27B parameters) in terms of user preference win rates.
Conclusion
IC-Cache provides a robust solution to the LLM serving trilemma of accuracy, cost, and latency. By effectively leveraging historical data as in-context examples, it enables high-performance serving using smaller, more economical models. Future work will focus on context window optimization and privacy-preserving synthetic cache generation.
Summary updated