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 L that combines standard Cross-Entropy (CE) with Kullback-Leibler (KL) divergence between the teacher's and student's probability distributions.
Where:
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 from O(n^2) to O(n \times w) where w 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.Cluster Hub: Generative AI Hub: Foundation Models, RAG Architecture, and Agent Workflows (generative-ai)