Abstract
Large language models (LLMs) have demonstrated remarkable performance across a wide range of industrial applications, from search and recommendations to generative tasks. Although scaling laws indicate that larger models generally yield better generalization and performance, their substantial computational requirements often render them impractical for many real-world scenarios at scale. In this paper, we present methods and insights for training small language models (SLMs) that deliver high performance and efficiency in deployment. We focus on two key techniques: (1) knowledge distillation and (2) model compression via quantization and pruning. These approaches enable SLMs to retain much of the quality of their larger counterparts while significantly reducing training, serving costs, and latency. We detail the impact of these techniques on a variety of use cases at a large professional social network platform and share deployment lessons - including hardware optimization strategies that enhance speed and throughput for both predictive and reasoning-based applications.
Introduction: The Latency-Throughput-Quality Trilemma
In the context of industrial recommendation systems (RecSys), model accuracy is often correlated with parameter count. However, deploying massive LLMs with hundreds of billions of parameters introduces a "latency-throughput-quality" trilemma. Real-time platforms like LinkedIn require models that can process complex user-item interactions within milliseconds while maintaining high throughput across millions of users. To address this, we propose a pipeline to "scale down" foundation models into efficient Small Language Models (SLMs) that retain the intelligence of their larger counterparts.
Methodology: A Multi-Stage Compression Pipeline
Our approach utilizes a sophisticated three-stage pipeline to achieve significant model size reduction while preserving performance.
- Knowledge Distillation (KD): We employ a large "teacher" model to guide a smaller "student" model. Our experiments indicate that Forward KL (FKL) divergence is the most effective loss function for this transfer of knowledge.
- One-Shot Structured Pruning: Using the OSSCAR algorithm, we target and remove redundant MLP neurons and attention heads. Unlike unstructured pruning, structured pruning removes entire blocks, which aligns with modern hardware architectures to provide immediate speedups.
- Re-Distillation: Following pruning, models often experience a dip in quality. A second round of distillation helps the pruned model recover its generalization capabilities and fine-tune its remaining parameters.
Experimental Setup and Datasets
The effectiveness of these methods was validated using a combination of internal and public datasets. Internal LinkedIn data consisting of text-based user-item interactions was used for ranking tasks. We also applied our recipes to the Qwen-2.5 and Llama-3.1/3.2 model families. For reasoning benchmarks, we utilized the OpenThoughts dataset and evaluated performance on AIME 2024/2025. Calibration for the pruning process was conducted using the C4 (Colossal Clean Crawled Corpus) dataset.
Key Insights: KD vs. Supervised Fine-Tuning
A primary insight from our research is that Knowledge Distillation consistently outperforms standard Supervised Fine-Tuning (SFT). The "soft" labels provided by a teacher model offer a richer signal than binary "hard" labels, enabling small models to "punch above their weight class."
For reasoning tasks, we found that a two-stage approach—initial word-level distillation followed by on-policy distillation—yields the best results, with the 1.5B student model occasionally approaching the performance of much larger teachers.
Deployment and Hardware Optimization
To ensure real-time viability, we utilize FP8 quantization on NVIDIA H100 GPUs. Analysis of inference latency identified the attention mechanism as the primary bottleneck in long-context recommendation tasks. By pruning attention heads, we achieved a 40% improvement in latency and a 28% speedup in the "prefill" phase. These optimizations allowed for a total model size reduction of over 20x while maintaining competitive AUC scores.
Conclusion and Future Work
This work demonstrates that through a combination of multi-stage distillation, structured pruning, and quantization, LLMs can be effectively compressed for high-traffic industrial applications. Future research will focus on integrating sparse attention techniques (such as Star Attention) and exploring the synergy between structured and unstructured sparsity to further enhance inference efficiency.
Summary updated