Small Language Models (SLMs) are defined by parameter counts typically under 10B, optimized for high-throughput, low-latency execution on commodity hardware or edge devices. Unlike frontier LLMs (e.g., GPT-4, Llama-3 70B+) that rely on massive scale for emergent reasoning, SLMs prioritize data quality and architectural efficiency to achieve comparable performance on specific benchmarks.
The primary trade-off in SLM design is Reasoning Density vs. Generalization Breadth.
| Metric | LLM (70B+) | SLM (<10B) |
|---|---|---|
| VRAM Requirement | >140GB (FP16) | <16GB (FP16) / <4GB (4-bit) |
| Inference Speed | 5-20 tokens/sec (H100) | 50-150+ tokens/sec (Consumer GPU/NPU) |
| Knowledge Cutoff | Broad, encyclopedic | Dense, narrow, or RAG-dependent |
| Fine-tuning | Extremely expensive (requires H100 clusters) | Accessible (can be done on a single A100 or 4090) |
Most high-performance SLMs are trained via Knowledge Distillation (KD), where a "Teacher" model (LLM) guides a "Student" model (SLM).
The goal is to minimize a loss function Lthat combines standard Cross-Entropy (CE) with Kullback-Leibler (KL) divergence between the teacher's and student's probability distributions.
Where:*z_s, z_t: Logits from the Student and Teacher models. *\sigma: Softmax function. *T: Temperature, a hyperparameter that "softens" the probability distribution to reveal more about the teacher's internal logic. *\alpha: Weighting factor between ground truth and teacher guidance.
By learning the teacher's "dark knowledge" (the relative probabilities of incorrect tokens), the student model captures subtle reasoning patterns that are absent in raw text-next-token prediction.
SLMs are rarely deployed in FP16/BF16. To fit on mobile devices or 8GB VRAM cards, they utilize aggressive quantization.
llama.cpp. Supports 4-bit (Q4_K_M) and 5-bit quantization with minimal perplexity loss.For a 3B parameter model (e.g., Phi-3 Mini):
Used in models like Llama-3 8B and Gemma, GQA reduces the memory bandwidth required for the Key-Value (KV) cache by sharing keys and values across multiple query heads. This is critical for maintaining high throughput during long-context generation on edge hardware.
Used in Mistral 7B, SWA allows each layer to attend to a limited window of previous tokens, reducing the computational complexity fromO(n^2)toO(n \times w)wherew is the window size.
To deploy an SLM effectively, the following components are required:
llama.cpp (CPU/Apple Silicon), vLLM (High-throughput GPU), or MLC LLM (Universal/NPU).Ollama for local API serving.