Book Profile
Domain-Specific Small Language Models
Manning (MEAP) · 2025
A practical guide for engineers to build, optimize, and deploy cost-effective and secure small language models (SLMs) on commodity hardware for specialized, real-world applications.
Get the book →In an era dominated by the hype of massive, generalist language models, this book takes a refreshingly pragmatic stance, arguing that true business value often lies in smaller, specialized, and more efficient AI. "Domain-Specific Small Language Models" is a hands-on guide for ML engineers and data scientists who need to move beyond expensive, high-risk prototypes and deliver tangible results within real-world constraints. It provides a comprehensive toolkit for selecting, tuning (via fine-tuning or RAG), and rigorously optimizing SLMs using techniques like ONNX conversion and quantization. Readers will learn to deploy these powerful models on commodity hardware—from on-premise servers to laptops and edge devices—unlocking applications in regulated or data-sensitive domains like code generation and chemistry while ensuring privacy, controlling costs, and achieving superior performance on domain-specific tasks.
What it argues
This model outlines the causal relationships between technical design choices made during the development of a Small Language Model (SLM) application and the resulting system performance, cost, and quality outcomes. It shows how levers like model selection, specialization strategy, and optimization techniques influence intermediate system properties, which in turn drive final business and operational metrics.
Key ideas it contributes
- Model Size and Architecture — The initial choice of the base language model, specifically its parameter count (e.g., SLM vs. LLM) and underlying architecture (e.g., encoder-only like BERT vs. decoder-only like GPT). This is a foundational design choice.
- Domain Specialization Strategy — The technical approach chosen to adapt the base model to a specific domain or task. This includes methods like full fine-tuning, parameter-efficient fine-tuning (PEFT, e.g., LoRA), or Retrieval-Augmented Generation (RAG).
- Optimization and Quantization Techniques — The set of post-training or during-training techniques applied to the model to reduce its size and computational cost. This includes conversion to formats like ONNX and quantization to lower bit precision (e.g., 8-bit, 4-bit via GPTQ/GGUF).
- Deployment and Serving Framework — The software framework and environment chosen to host the model for inference. This includes high-throughput servers (vLLM), web frameworks (FastAPI), or local/on-device runtimes (Ollama, MLC LLM).
- Domain Data Quality — The quality, relevance, and volume of the domain-specific dataset used for fine-tuning or as the knowledge base for RAG. High-quality data is critical for effective specialization.
- Hardware Environment — The computational hardware on which the model is deployed and run for inference. This includes constraints such as CPU-only, single consumer GPU, laptop, or dedicated server infrastructure.
- Model Footprint — The amount of memory (RAM or VRAM) and disk space required to store and load the model's weights. This is a direct consequence of model size and optimization.
- Computational Requirements — The processing power (e.g., FLOPS) and memory bandwidth needed to execute an inference pass through the model. This is influenced by the model's footprint and architectural complexity.