Leanpub Header

Skip to main content

Evaluating Local and Small Language Models

A Practical Engineering Guide to Benchmarking, Optimization, and Production Deployment

Evaluating Local and Small Language Models
This book is 100% completeLast updated on 2026-09-07

A practical guide to evaluating small and local language models in the real world. Learn how to benchmark reliably, compare models across hardware and runtimes, optimize performance and avoid misleading results. With practical code and rigorous methods, you can build your own evaluation setup and make confident deployment decisions.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
129
Pages
About

About

About the Book

This book teaches engineers how to build reliable evaluation systems for small and locally deployed language models. You will learn to measure performance accurately, compare models across hardware and runtimes, interpret results without being misled by benchmarks, and make evidence-based deployment decisions for real-world workloads. The guide combines rigorous experimental methodology with example code so you can independently establish an evaluation laboratory and produce trustworthy, reproducible results.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

A Practical Engineering Guide to Benchmarking, Optimization, and Production Deployment

Introduction

  1. Why evaluation matters more for local models
  2. What you will be able to do after reading this book
  3. Who this book is for
  4. How this book is organized
  5. A note on pace and specificity

Chapter 1: Defining the Landscape

  1. What is a Small Language Model
  2. What is a Local Language Model
  3. Why Local Matters
  4. The Hardware Landscape
  5. Cost and Privacy Implications
  6. How This Book is Structured

Chapter 2: Model Architectures and Scaling

  1. Transformer Fundamentals
  2. Parameter Count and Scaling Laws
  3. Attention Mechanisms and Variants
  4. Grouped-Query and Multi-Query Attention
  5. Mixture of Experts Architectures
  6. Context Window Mechanics
  7. Architectural Choices that Affect Inference

Chapter 3: Model Quality and Capability Dimensions

  1. Instruction Following and Alignment
  2. Reasoning and Chain-of-Thought
  3. Coding and Technical Tasks
  4. Structured Output and Format Control
  5. Multilingual Performance
  6. Long-Context Understanding
  7. Tool Use and Function Calling
  8. Hallucination and Factuality
  9. Refusal Behavior and Safety

Chapter 4: Model Weights, Formats, and Storage

  1. Safetensors and PyTorch Weights
  2. GGUF Format and llama.cpp
  3. ONNX and Cross-Platform Export
  4. Model Card Information
  5. Quantization-Aware Format Choices
  6. Storage Requirements and Disk I/O
  7. Weight Loading Performance

Chapter 5: Quantization Fundamentals

  1. Why Quantize
  2. Full-Precision vs. Quantized Representations
  3. INT8 and INT4 Quantization
  4. Per-Tensor vs. Per-Channel vs. Per-Token
  5. Quantization-Aware Training and Post-Training
  6. GGUF Quantization Schemes
  7. Measuring Quantization Impact
  8. When Quantization Fails

Chapter 6: The Local Inference Stack

  1. Hardware Abstraction Layers
  2. GPU Runtimes and Drivers
  3. Memory Management and Allocation
  4. Context Switching and Scheduling
  5. Process Isolation and Resource Limits
  6. Container Considerations
  7. The Inference Stack Architecture

Chapter 7: llama.cpp and GGUF Ecosystem

  1. llama.cpp Architecture and Design
  2. GGUF Model Loading
  3. Quantization Selection in llama.cpp
  4. Threading and CPU Optimization
  5. Metal and GPU Offloading
  6. API and Embedding Integration
  7. Performance Tuning and Flags
  8. Limitations and Gotchas

Chapter 8: Ollama, MLX, and Alternative Runtimes

  1. Ollama Architecture and Modelfile
  2. Running and Customizing Ollama
  3. Apple MLX Framework
  4. vLLM for Local Deployment
  5. Text Generation Inference
  6. Choosing Your Runtime

Chapter 9: Tokenization and Prompt Processing

  1. How Tokenization Works
  2. Vocabulary Size and Efficiency
  3. Tokenizer Choice Matters
  4. Measuring Tokenization Performance
  5. Special Tokens and Formatting
  6. Prompt Templates and System Messages
  7. Token Counting and Estimation
  8. Multilingual Tokenization Issues

Chapter 10: Latency and Throughput Fundamentals

  1. Time-to-First-Token
  2. Inter-Token Latency
  3. Tokens Per Second
  4. Prompt Processing Speed
  5. Batch Processing and Parallelism
  6. What Drives Each Metric
  7. Hardware Bottleneck Identification
  8. Measuring Without Contamination

Chapter 11: Memory Behavior and KV Cache

  1. What is the KV Cache
  2. KV Cache Growth and Context Windows
  3. Memory Planning and Budgeting
  4. KV Cache Quantization
  5. Sliding Windows and Attention Limits
  6. Prompt Caching Strategies
  7. Eviction and Reuse
  8. Practical Memory Monitoring

Chapter 12: Designing Sound Evaluation Methodology

  1. Evaluation vs. Benchmarking
  2. Task Selection and Workload Definition
  3. Representative Test Construction
  4. Prompt Design and Variance
  5. Deterministic vs. Stochastic Evaluation
  6. Temperature and Sampling Parameters
  7. Sample Size and Saturation
  8. Evaluation Framework Design

Chapter 13: Statistical Rigor and Experimental Design

  1. Reproducibility and Seeding
  2. Confidence Intervals for Model Comparison
  3. Statistical Significance Testing
  4. Variance Sources and Control
  5. Measurement Error and Noise
  6. Warm-up Effects and Caching
  7. Normalizing Across Hardware
  8. Reporting Standards

Chapter 14: Public Benchmarks and Their Limitations

  1. Multiple-Choice Knowledge Benchmarks
  2. Math and Reasoning Benchmarks
  3. Code Generation Benchmarks
  4. Instruction and Chat Benchmarks
  5. Benchmark Contamination
  6. Overfitting to Benchmarks
  7. Aggregate Scores and Their Fallacies
  8. When to Trust Public Benchmarks

Chapter 15: Building Custom Evaluation Harnesses

  1. Evaluation Harness Architecture
  2. Implementing a Basic Harness
  3. Streaming and Telemetry Collection
  4. Automated Experiment Orchestration
  5. Result Storage and Retrieval
  6. Structured Output Validation
  7. Comparative Analysis and Reporting
  8. Visualization and Dashboards

Chapter 16: Measuring Model Quality in Depth

  1. Automated Quality Metrics
  2. Factuality Verification
  3. Hallucination Measurement
  4. Instruction Following Assessment
  5. Reasoning Quality Evaluation
  6. Code Execution Verification
  7. Long-Context Fidelity Testing
  8. Model-as-Judge Evaluation

Chapter 17: Workload-Specific Evaluation

  1. Conversational Assistants
  2. Coding and Development Tools
  3. Document Analysis and Summarization
  4. Retrieval-Augmented Generation Systems
  5. Agentic Workflows
  6. Edge and Offline Deployments
  7. Enterprise and Private Assistants
  8. Embedding and Classification Tasks

Chapter 18: Safety, Robustness, and Reliability

  1. Safety Evaluation Methodology
  2. Adversarial Prompt Testing
  3. Jailbreak Resistance
  4. Refusal Calibration
  5. Consistency and Reliability Under Load
  6. Degradation Modes
  7. Monitoring for Production Safety
  8. Compliance and Policy Checks

Chapter 19: Advanced Optimization Techniques

  1. Speculative Decoding
  2. Continuous Batching
  3. Prompt and KV Cache Compression
  4. Compiler Optimizations
  5. Distillation and Adapters
  6. Model Merging Strategies
  7. Hardware-Specific Optimizations
  8. Distributed and Multi-Node Inference
  9. Techniques for Improving Performance Without Compromising Quality

Chapter 20: Decision Frameworks and Production Deployment

  1. Multi-Criteria Decision Frameworks
  2. Model Selection by Workload
  3. Hardware Procurement Decisions
  4. Cost Modeling and TCO
  5. Operational Considerations
  6. Case Study: Local Coding Assistant
  7. Case Study: Private RAG System
  8. Case Study: Edge Deployment

Conclusion

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub