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...
The Python AI ecosystem has hundreds of excellent libraries that nobody writes about because LangChain dominates the conversation. This book covers 38 of them.
Each chapter is a practical guide: what the library does, why it exists, how to install it, and working Python code you can run today. No fluff, no theory — just tools and code.
Minimum price
$19.00
$29.00
About the Book
Every week, a new Python AI tutorial lands on Hacker News or Medium. Nearly every one of them uses the same five libraries. The ecosystem is vast, the tutorials are narrow, and developers building real products keep reinventing the same wheels.
This book is different. It deliberately avoids the most-hyped frameworks and instead digs into the libraries that working engineers reach for when they need something that actually works in production — tools that are focused, composable, Pythonic, and battle-tested.
What you will learnThe book covers 38 Python AI libraries organised into 12 thematic parts:
Part 1 — Structured Outputs and LLM Control Stop wrestling with LLM responses that are almost JSON but not quite. Instructor adds a Pydantic validation + retry loop to any LLM API call. Outlines constrains token sampling at the model level so invalid output is mathematically impossible. Guidance lets you interleave Python logic with generation mid-prompt.
Part 2 — LLM API Abstraction LiteLLM gives you one OpenAI-compatible interface for 100+ providers — GPT-4o, Claude 3.5, Gemini 1.5, local Ollama, all with one line change. Mirascope and Magentic make prompts first-class Python functions with proper type signatures.
Part 3 — Prompt Engineering as Code DSPy from Stanford NLP lets you program LLM pipelines instead of writing prompts — its optimiser finds the best prompts automatically against your data. Ell version-controls every prompt you write and gives you a full history browser.
Part 4 — Agent Frameworks Smolagents from HuggingFace takes the surprising approach of having agents write Python code to combine tools, rather than JSON tool calls. Burr models agents as explicit state machines that are resumable, debuggable, and testable. Mem0 gives any agent persistent long-term memory without bloating the context window.
Part 5 — Vector Search and Embeddings Sentence-Transformers for computing semantic embeddings. Qdrant for production vector search with hybrid dense+sparse retrieval. ChromaDB for zero-config local vector storage. FastEmbed for CPU-only embedding without a GPU. Rerankers for two-stage retrieval that dramatically improves RAG precision.
Part 6 — RAG and Document Processing Haystack for modular, component-based NLP pipelines. Docling from IBM Research for PDF parsing that preserves table and heading structure. Unstructured for ingesting 25+ file formats with typed element classification. Ragas for evaluating RAG quality without any human annotation.
Part 7 — LLM Evaluation and Observability DeepEval for pytest-style LLM unit testing. Langfuse for production tracing, cost tracking, and prompt management. TruLens for comparing pipeline configurations on a leaderboard. MLflow for experiment tracking with automatic LLM call logging.
Part 8 — Fine-Tuning and Model Serving Unsloth for LoRA/QLoRA fine-tuning that is 2–5× faster with 70% less GPU memory. vLLM for high-throughput model serving with PagedAttention. PEFT for understanding the fine-tuning primitives that power everything else. Axolotl for fine-tuning any model with just a YAML config file.
Part 9 — Specialised Tools Pydantic AI for type-safe agents with dependency injection. Marvin for one-line classification, extraction, and data generation. Browser-use for giving AI agents control of a real web browser.
Part 11 — More Essential Tools Crawl4AI for web crawling that returns clean Markdown instead of raw HTML. Semantic Router for routing queries to different handlers based on meaning, not keywords. Guardrails AI for content policy enforcement and PII redaction. Weave from W&B for LLM experiment tracking. Ollama Python for running local models with zero API cost.
Part 12 — Advanced Patterns Beyond individual tools: production RAG architecture (query decomposition, hybrid search, self-RAG), async patterns for high-throughput processing, semantic caching to cut costs by 30–80%, and a complete guide to testing LLM applications with mocking and property-based assertions.
Capstone Project The book closes with a complete end-to-end research assistant that combines six tools: Browser-use discovers relevant URLs, Docling parses the documents, Qdrant + Sentence-Transformers index and retrieve passages, Instructor extracts a structured summary, and Langfuse traces the whole pipeline. Full, runnable source code included.
Who this book is forMost AI books teach you what LLMs are. This book teaches you the surrounding infrastructure — the tools that make LLMs production-ready. Every chapter is practical, every example runs, and every tool was chosen because it solves a specific real problem better than the alternatives.
About the Author
I'm a Full-stack .Net developer with over five years of commercial experience as a .Net developer. I'm happy to help with every problem that you are facing :)
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
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
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
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.