Large Language Models for Mortals book released

I have published a new book, Large Language Models for Mortals: A Practical Guide for Analysts with Python. The book is available to purchase in my store, either as a paperback (for $59.99) or an epub (for $49.99).

The book is a tutorial on using python with all the major LLM foundation model providers (OpenAI, Anthropic, Google, and AWS Bedrock). The book goes through the basics of API calls, structured outputs, RAG applications, and tool-calling/MCP/agents. The book also has a chapter on LLM coding tools, with example walk throughs for GitHub Copilot, Claude Code (including how to set it up via AWS Bedrock), and Google’s Antigravity editor. (It also has a few examples of local models, which you can see Chapter 2 I discuss them before going onto the APIs in Chapter 3).

You can review the first 60 some pages (PDF link here if on Iphone).

You can see the table of contents for all of the sections, but it includes over 250 different python code snippets, and over 80 screenshots. The print book is in letter sized paper and is a total of 354 pages.

Why write this book?

I wrote the book because of the rapid pace of advancement in data science in just the past few years. I basically self-taught traditional machine learning applications during the end of my PhD and early career as a professor (so around 2015). That has been the focus of my work until the past year. The advancement of LLMs have really upended the data science industry in just the past few years, where the majority of my job flipped from traditional machine learning models to LLM applications.

The hype is real, and folks with similar background to me (advanced social science degrees) you need to learn these fundamentals to be able to get a data science job. This is my introduction to major components of foundation models. You will definitely need to know python basics before this book (in which I would recommend my book, Data Science for Crime Analysis with Python. But other than that, you should be able to review the material in this book and have a good, fundamental understanding of large language models.

The book that goes through the major components of calling APIs (temperature, structured outputs, thinking/reasoning, caching, measuring costs), and introductions to designing more complicated systems (like RAG, agents, testing, and measuring how accurate your system is). In addition to this it gets your feet wet with LLM coding tools and what they can (reasonably) accomplish.

It is the book I wish I had several years ago. While the APIs are rapidly changing, this should give you the fundamentals in understanding and building real LLM applications with foundation models. The APIs will no doubt change and add new features, this is a good base from which to build upon though.

While many of the examples in the book are criminology focused, such as extracting out crime elements from incident narratives, or summarizing time series charts, the lessons are more general and are relevant to anyone looking to learn the LLM APIs. I say “analyst” in the title, but this is really relevant to:

Basically anyone who wants to build or create LLM applications, this is the book to help you get started.

Why my book vs competitors?

Two of the potential alternatives I am familiar with, both from O’Reilly, deserve a brief mention as to how my book is different.

The first, Chip Huyen’s AI Engineering: Building Applications with Foundation Models is a high level description of foundation models. It is a good place to look if you want more mathematical details on foundation model architecture, semantic similarity, understanding temperature, how to construct evaluations, etc. (But still in a very accessible way, easier than reading a computer science journal article.) It does not have example code snippets to actually run.

Chip’s book is good, but is not intended to be a tutorial style how to code book. I would suggest it as a complement to my book if you are interested in more of the mathematical details of foundation models.

Generative AI in Action, by Amit Bahree, is closer in spirit to the same material I have written. He has actual code snippets for OpenAI models querying Azure (he is a Microsoft employee). The biggest rub with Amit’s book is it is already out of date – he uses code that is several years old openai API specs. Here is one of the first examples in his book.

# Example code snippet from Bahree
import os
import openai

openai.api_type = "azure"
openai.api_base = os.getenv("AOAI_ENDPOINT")
openai.api_version = "2022-12-01"
openai.api_key = os.getenv("AOAI_KEY")

prompt_startphrase = "Translate the following to Spanish: 
                       I have a small dog called Champ."

response = openai.Completion.create(
  engine="gpt-35-turbo",
  prompt=prompt_startphrase,
  temperature=0.8,
  max_tokens=100,
  stop=None)

responsetext = response["choices"][0]["text"]

print("Prompt:" + prompt_startphrase + "\nResponse:" + responsetext)

So my book for OpenAI has examples both for the chat completions API as well as the newer responses API. In addition to that, it has examples with Anthropic, Google Gemini, and AWS Bedrock models in each of the chapters. (E.g. in the RAG chapter I show how to use AWS S3 Vectors, OpenAI’s vector store, and Google’s BigQuery in a RAG application, in addition to in memory FAISS and ChromaDB.)

In addition to the above sample chapters, you can see additional materials for the book on GitHub at https://github.com/apwheele/LLMsForAnalysts.

Purchase the Book!

Again, the book is available in:

For purchase worldwide. Here are all the sections in the book – whether you are an AWS or Google shop, or want to learn the different database alternatives for RAG, or want more self contained examples of agents with python code examples for OpenAI, Anthropic, or Google, this should be a resource you highly consider purchasing.

Large Language Models for Mortals: A Practical Guide for Analysts with Python

TABLE OF CONTENTS

Preface
    Are LLMs worth all the hype?
    Is this book more AI Slop?
    Who this book is for
    Why write this book?
    What this book covers
    What this book is not
    My background
    Materials for the book
    Feedback on the book
    Thank you
1 Basics of Large Language Models
    1.1 What is a language model?
    1.2 A simple language model in PyTorch
    1.3 Defining the neural network
    1.4 Training the model
    1.5 Testing the model
    1.6 Recapping what we just built
2 Running Local Models from Hugging Face
    2.1 Installing required libraries
    2.2 Downloading and using Hugging Face models
    2.3 Generating embeddings with sentence transformers
    2.4 Named entity recognition with GLiNER
    2.5 Text Generation
    2.6 Practical limitations of local models
3 Calling External APIs
    3.1 GUI applications vs API access
    3.2 Major API providers
    3.3 Calling the OpenAI API
    3.4 Controlling the Output via Temperature
    3.5 Reasoning
    3.6 Multi-turn conversations
    3.7 Understanding the internals of responses
    3.8 Embeddings
    3.9 Inputting different file types
    3.10 Different providers, same API
    3.11 Calling the Anthropic API
    3.12 Using extended thinking with Claude
    3.13 Inputting Documents and Citations
    3.14 Calling the Google Gemini API
    3.15 Long Context with Gemini
    3.16 Grounding in Google Maps
    3.17 Audio Diarization
    3.18 Video Understanding
    3.19 Calling the AWS Bedrock API
    3.20 Calculating costs
4 Structured Output Generation
    4.1 Prompt Engineering
    4.2 OpenAI with JSON parsing
    4.3 Assistant Messages and Stop Sequences
    4.4 Ensuring Schema Matching Using Pydantic
    4.5 Batch Processing For Structured Data Extraction using OpenAI
    4.6 Anthropic Batch API
    4.7 Google Gemini Batch
    4.8 AWS Bedrock Batch Inference
    4.9 Testing
    4.10 Confidence in Classification using LogProbs
    4.11 Alternative inputs and outputs using XML and YAML
    4.12 Structured Workflows with Structured Outputs
5 Retrieval-Augmented Generation (RAG)
    5.1 Understanding embeddings
    5.2 Generating Embeddings using OpenAI
    5.3 Example Calculating Cosine similarity and L2 distance
    5.4 Building a simple RAG system
    5.5 Re-ranking for improved results
    5.6 Semantic vs Keyword Search
    5.7 In-memory vector stores
    5.8 Persistent vector databases
    5.9 Chunking text from PDFs
    5.10 Semantic Chunking
    5.11 OpenAI Vector Store
    5.12 AWS S3 Vectors
    5.13 Gemini and BigQuery SQL with Vectors
    5.14 Evaluating retrieval quality
    5.15 Do you need RAG at all?
6 Tool Calling, Model Context Protocol (MCP), and Agents
    6.1 Understanding tool calling
    6.2 Tool calling with OpenAI
    6.3 Multiple tools and complex workflows
    6.4 Tool calling with Gemini
    6.5 Returning images from tools
    6.6 Using the Google Maps tool
    6.7 Tool calling with Anthropic
    6.8 Error handling and model retry
    6.9 Tool Calling with AWS Bedrock
    6.10 Introduction to Model Context Protocol (MCP)
    6.11 Connecting Claude Desktop to MCP servers
    6.12 Examples of Using the Crime Analysis Server in Claude Desktop
    6.13 What are Agents anyway?
    6.14 Using Multiple Tools with the OpenAI Agents SDK
    6.15 Composing and Sequencing Agents with the Google Agents SDK
    6.16 MCP and file searching using the Claude Agents SDK
    6.17 LLM as a Judge
7 Coding Tools and AI-Assisted Development
    7.1 Keeping it real with vibe coding
    7.2 VS Code and GitHub Install
    7.3 GitHub Copilot
    7.4 Claude Code Setup
    7.5 Configuring API access
    7.6 Using Claude Code to Edit Files
    7.7 Project context with CLAUDE.md
    7.8 Using an MCP Server
    7.9 Custom Commands and Skills
    7.10 Session Management
    7.11 Hooks for Testing
    7.12 Claude Headless Mode
    7.13 Google Antigravity
    7.14 Best practices for AI-assisted coding
8 Where to next?
    8.1 Staying current
    8.2 What to learn next?
    8.3 Forecasting the near future of foundation models
    8.4 Final thoughts