Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

Local & Private AI

These books have a total suggested price of $145. Get them now for only $49.00!
About

About

About the Bundle

Books

About the Books

Local LLMs Engineering: Build, Run and Ship Private AI

Local LLMs Engineering: Build, Run and Ship Private AI

The cloud made large language models easy to prototype, but it never made them private, predictable, or cheap. Every document sent to a remote API comes with someone else’s retention policy, rate limits, surprise model changes, and a per-token bill. That may be fine for a weekend experiment. It is a weak foundation for contracts, support systems, regulated records, or a product whose margins depend on inference cost.


Local LLMs Engineering: Build, Run, and Ship Private AI on Your Own Hardware is a practical, end-to-end guide to building private language model applications on consumer and workstation hardware. Running models locally gives you control over the processor, memory, quantization, context policy, serving engine, update schedule, and data boundary. It also brings new responsibilities. A laptop that works well for one user can fall over under concurrent requests. A model advertised with a 128K context window may need more memory than your hardware has. A private endpoint can still be unsafe if retrieved documents turn into instructions and the model can call tools without limits. This book shows you how to handle all of it.


You will begin with hardware planning and capacity budgeting, then learn how to select and evaluate models with their licenses in mind. From there you will master quantization and GGUF conversion, run inference with llama.cpp and Hugging Face Transformers, and get reliable structured output with the right prompt templates. You will build private retrieval with embeddings, design tool-using agents with safe autonomy, and serve models through Ollama, vLLM, and Open WebUI.


The book then moves into production. You will benchmark performance properly, tune GPU acceleration across runtime backends, optimize memory and manage context, secure private LLM systems, and set up observability, evaluation, and operations. You will also learn to package and deploy your stack with CI/CD so every environment can be reproduced.

Real projects anchor every workflow in commands you can verify and trade-offs you can measure, including Ollama, llama.cpp, Hugging Face Transformers, vLLM, LM Studio, Open WebUI, llamafile, Podman AI Lab, Meta Llama, Microsoft Phi, IBM Granite, and NVIDIA Nemotron. Whether you run on an Apple Silicon laptop, a Linux workstation with an NVIDIA GPU, a small on-premises rack, or a multi-node cluster, the same principles apply.

It all comes together in a complete end-to-end build of a private document assistant, followed by a consolidated deployment checklist, an evaluation framework, and a reusable roadmap for moving from laptop experiments to governed production infrastructure. If you are a developer, ML engineer, or platform team that wants the power of LLMs without giving up control of your data, this is the book for you.

Run Local LLMs with Ollama, LM Studio, and vLLM

Run Local LLMs with Ollama, LM Studio, and vLLM

## About the Book

Local inference has moved from hobbyist curiosity to production infrastructure. This book is the operating manual for teams running large language models on their own hardware: choosing a runtime for a workload, sizing and buying hardware, pulling and quantizing models, and building OpenAI-compatible services that existing Python code can reach with a one-line base-URL change.

**Ollama** gets a full treatment — daemon model, Modelfile layering of system prompts and chat templates, HTTP API, Python client patterns, multi-model serving, and nginx-fronted team servers. **LM Studio** is covered on the desktop and headless via `llmster`, including the MLX advantage on Apple Silicon. **llama.cpp** is explained underneath both, from building with CUDA/Metal/Vulkan to `llama-bench` and GGUF internals. **vLLM** gets the production chapters: PagedAttention, continuous batching, parallelism strategies, and tuning parameters.

The book then layers on retrieval-augmented generation, structured outputs, tool calling, MCP, honest benchmarking (TTFT and inter-token latency, not a single tokens-per-second number), security hardening (prompt injection, model provenance, access control), Docker and Kubernetes deployment, Prometheus and Grafana observability, and advanced optimization including prefix caching, chunked prefill, FP8 KV cache, speculative decoding, and disaggregated prefill/decode.

Three closing walkthroughs are complete, copy-pasteable implementations: a private chat service, a document assistant with ingestion and retrieval evaluation, and a production OpenAI-compatible API with a gateway, quotas, circuit breaker, blue-green releases, and an operational runbook.

Every chapter ends with a recap checklist, hands-on exercises, and a pitfalls section. Written for developers, ML engineers, platform teams, and technical professionals who already know Python, APIs, the command line, and basic ML concepts.

Run Large Language Models on ROCm

Run Large Language Models on ROCm

A working engineer's guide to running large language models on AMD GPUs with ROCm, aimed at ML engineers, platform engineers, data scientists and developers who already know Python and transformers.

The book opens with the hardware and software stack you are actually choosing between — Instinct MI300X, MI325X and MI355X accelerators, RDNA4 Radeon cards, Ryzen AI APUs — and the `gfx` targets (gfx942, gfx950, gfx1201, gfx1151) that decide kernel behaviour. From there it moves through five installation paths (package manager, runfile, containers, PyTorch pip wheels), with a three-layer verification that checks the `amdgpu` module, device nodes and group membership, plus a reproducible idempotent install script.

You then get PyTorch on ROCm: the `torch.cuda` device-string illusion, dtype rules for CDNA versus RDNA, automatic mixed precision, hipBLASLt, Triton on ROCm, RCCL and hipFile, wrapped in a vendor-neutral device layer you can drop into any project. Model loading covers safetensors, sharding, attention backends, GPU ordering, GGUF via llama.cpp, and cache layout.

The porting chapter uses hipify-perl and hipify-clang with CMake `hipcc` builds and a CUDA2HIP support report, and is explicit about what does not port. Optimisation covers the seven vLLM attention backends on ROCm, AITER switches, FP8 KV cache, AWQ and GPTQ quantization, with a systematic tuning procedure. Serving compares llama.cpp, vLLM and SGLang on real numbers; profiling uses rocprofv3, rocprof-compute, AMD SMI and the roofline model, including the RDNA performance-level requirement. Distributed inference covers XGMI topology, RCCL channels, TP/PP/DP+EP placement and scaling efficiency. Security and observability cover device-node permissions, container hardening, the AMD Kubernetes device plugin, Prometheus metrics and supply-chain pinning. A symptom-indexed troubleshooting ladder and three end-to-end walkthroughs close the book.

Every chapter has version-pinned commands, runnable code, pitfalls, exercises and a recap checklist.

LiteLLM Setup Guide

LiteLLM Setup Guide

Written for engineers who know Python and REST but need a dependable control plane instead of a demo, this guide takes you from an empty directory to a hardened, multi-tenant LiteLLM gateway in front of OpenAI, Anthropic, Google Vertex AI, Azure OpenAI, AWS Bedrock, Mistral, Groq, and dozens more providers.

You'll learn how LiteLLM's model groups and deployment blocks work, then install the proxy and verify it with liveness and readiness checks, a real completion, and a model listing. From there you configure providers, wire up PostgreSQL and Redis for the admin UI, and switch from the Python SDK to the OpenAI-compatible proxy API — including streaming, non-streaming, and the Responses API bridge in both directions, plus embeddings, images, audio transcription, speech synthesis, and the batch endpoint (upload JSONL, create batch, poll, retrieve).

The operational half of the book covers what production actually demands: the master key versus scoped virtual keys, model aliases, routing strategies, retries, timeouts, cooldowns, load balancing with precedence rules, cost tracking and budgets, observability through logs, callbacks, and OpenTelemetry, evaluation and quality testing, guardrails for PII and moderation, secret management, Docker and Kubernetes deployment (tag pinning, digest pinning, non-root), CI/CD smoke tests, scaling, and a troubleshooting chapter that isolates database, Redis, and provider failures.

You'll also get prompt-cache-friendly patterns for cost optimization, customer management and end-user tracking, and a final walkthrough that builds a production-shaped gateway from scratch: config, Helm values, key provisioning, schema migration, verification, and a runbook with triage procedures for failed requests, single-provider outages, spend spikes, and leaked keys.

ComfyUI Tutorials: From First Workflow to Production-Ready AI Media

ComfyUI Tutorials: From First Workflow to Production-Ready AI Media

ComfyUI is the most capable open-source node-based interface for Stable Diffusion, FLUX, and Wan-family models, but its power only pays off if you build workflows deliberately instead of clicking node by node. This book teaches you to work in graphs.

You will install ComfyUI across NVIDIA, AMD, Intel, and Apple Silicon hardware, with VRAM tiering that decides which model you can actually run. You will learn the node-graph mental model — demand-driven execution, typed inputs and outputs, MODEL/CLIP/VAE/LATENT/IMAGE ports — so that changing one prompt re-runs only the subgraph that depends on it. You will structure reusable workflow JSON with explicit seeds and pinned model hashes, then compose conditioning, ControlNet and preprocessors, IP-Adapter, LoRA, FaceID, ReActor, Florence-2, and SAM 2 into reference-driven pipelines. You will build img2img and inpainting graphs, two-stage tiled upscaling with Impact Pack face and hand repair, and Wan2.2 video workflows with frame-count and duration planning.

Later chapters cover the HTTP and WebSocket API with a complete Python client, batch runner, headless deployment, and JavaScript/TypeScript clients; performance tuning including Sage Attention, torch.compile, and dynamic VRAM; troubleshooting and portability bundles with requirements.lock; and a licensing chapter that addresses the non-commercial terms on FLUX.1 [dev], FLUX.1 Kontext [dev], and InsightFace weights. A full studio walkthrough and a week-by-week deployment roadmap close the book.

Every chapter names real models, flags, and failure modes, and ends with an exercise and a recap checklist.

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.)

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