PyTorch Without the Calculus: What It Is and What You Can Ignore
A gentle, math-free introduction to PyTorch for engineers and technical PMs — what it actually is, what you can safely skip, and how to set up Google Colab to run real AI models.
Run pretrained models from a model hub with PyTorch and Hugging Face — your first model run by chapter 4, what is inside a model, text and embeddings, then generation — with five capstone apps and no calculus.
A gentle, math-free introduction to PyTorch for engineers and technical PMs — what it actually is, what you can safely skip, and how to set up Google Colab to run real AI models.
A beginner-friendly tour of pytorch tensors — creating them, indexing and reshaping them, and doing arithmetic on them — with no linear-algebra homework attached.
A beginner-friendly guide to moving PyTorch tensors between the CPU and GPU with .to(device), trading data with NumPy, and pulling a single value out with .item() — no math required.
A beginner-friendly walkthrough to run a pretrained model in PyTorch end to end — download an image and do image classification with torchvision, no deep-learning math required.
A practical PyTorch shape-reading guide for beginners: batches, image tensors, classifier outputs, token IDs, hidden states, and the print-shape habit that makes model code debuggable.
A beginner-friendly guide to PyTorch model inputs and outputs — preprocessing and batch dimensions on one end, logits vs probabilities on the other — so you can run any pretrained model with confidence.
A beginner-friendly tour of the Hugging Face transformers pipeline — the fastest way to run a pretrained model in three lines, across text, images, and audio.
Where the model names come from: how to browse the Hugging Face Hub by task and trust, read a model card like an adult, check the licence before anything ships, get through a gated model's form, and know where the weights land on disk.
A practical debugging playbook for beginner PyTorch and Hugging Face inference: missing packages, CUDA availability, device mismatch, shape errors, OOM, gated models, preprocessing mistakes, and slow first runs.
Build an AI app in PyTorch by wrapping a pretrained model in a Gradio app — a beginner-friendly capstone that turns a model into a real, shareable little tool.
A gentle, math-free look at what a neural network is actually made of — layers and parameters — by building one yourself in PyTorch, from a single nn.Linear up to a small stack, and reading its insides. Beginner-friendly.
Open a real pretrained image classifier — ResNet-18 — and read it like a spec sheet: the one new layer vision models add (convolution), the layer tree, the eleven million parameters, and the named weights, all with the nn.Module skills from the last chapter. Math-free.
Before a model can read, each word has to become numbers: vocabularies, token IDs, and the embedding lookup, on a 12-word toy you can run. Then the one idea behind every transformer — attention — and the encoder-versus-decoder split that decides which models classify and which ones write. Math-free.
Open a famous language model — DistilBERT — and read it like a spec sheet: the embeddings table, six stacked attention blocks, sixty-six million parameters, and named weights, all with the same nn.Module skills you used on ResNet. Math-free and beginner-friendly.
Part II's capstone: build a small MLP, load a trained state dict into it from a plain URL — the move for every model that isn't on a model hub — and wrap it in a Gradio app that reads handwritten digits you draw.
A beginner-friendly bridge from image preprocessing to text tokenization: token IDs, attention masks, padding, truncation, batching, and how to choose the right model input abstraction.
A beginner-friendly guide to dropping below pipeline() for control — using AutoTokenizer and AutoModel from_pretrained, a huggingface tokenizer, and reading raw logits by hand.
The text-classification capstone: turn pipeline('sentiment-analysis') into a real tool. Batch a pile of feedback through DistilBERT, route low-confidence cases to a human, and wrap it in a Gradio app with a sortable table and a live distribution.
A practical introduction to embeddings for PyTorch and Hugging Face users: turning text into vectors, comparing meaning with cosine similarity, batching inputs, and knowing when embeddings beat generation.
Part III's second capstone: turn the embeddings from the last chapter into a tiny search engine that finds results by meaning, not keywords — embed a corpus, rank by cosine similarity, and wrap it in a Gradio app.
Why a model that 'should not fit' on a free GPU often does: the arithmetic from stored dtype to gigabytes, and the four levers — the GPU you pick, the dtype you load in, device_map='auto', and 4-bit quantization — that make a 7B chat model run on a Colab T4.
The other half of the transformer family: the decoder. How GPT-2 generates text — next-token prediction, the autoregressive loop run by hand so you can see the probabilities of one step, then generate() doing the same thing — and why a model that continues text cannot answer a question.
Decoding is the step the model leaves to you: greedy versus sampling, temperature, top-k, top-p, repetition penalty, beam search, stopping, seeds, and the one batching rule decoders care about — with the same prompt run through every knob so you can see what each one does.
Why GPT-2 rambles and a chat model answers: base versus instruct, the same question put to both, the chat template that turns roles into tokens, multi-turn memory written as code, and streaming replies — running Qwen2.5-0.5B-Instruct on a free GPU or a plain CPU.
The grand finale: wrap a small instruction-tuned model in a real chat interface with Gradio — system prompt, conversation memory, and a public link — then look back at everything the book taught you.
A beginner-friendly intro to audio in PyTorch — load a waveform with torchaudio, read its shape and sample rate, and turn it into a mel spectrogram, the image a model actually sees.
Run your first text-to-speech model in Colab with SpeechT5 — text in, speech out, on CPU — and learn the encoder, mel spectrogram, and vocoder pieces behind it.
Run two more open text-to-speech models in Colab — Bark for expressive, human-sounding voices and Meta's MMS-TTS/VITS for 1000+ languages — and learn to pick a TTS model by its trade-offs.
Build a text-to-speech app that narrates a whole article — split sentences, synthesize each with SpeechT5, stitch the clips, and wrap it in a Gradio UI.
A beginner-friendly look at neural audio codecs in PyTorch — use Encodec to turn a waveform into discrete tokens and back, the trick that lets a transformer generate sound.
Generate music from a text prompt in Colab with MusicGen — the easy pipeline way and the honest processor-plus-generate way — and see how max_new_tokens sets the clip length.
Take control of MusicGen in PyTorch — set clip length with max_new_tokens, tune do_sample, temperature, and guidance_scale, batch multiple prompts, and condition on a melody with musicgen-melody.
The book's finale — generate a music bed with MusicGen and a narration line with SpeechT5, resample to a common rate, mix and normalize them into one clip, and wrap it in a Gradio app.
For the curious: the lineage behind the shapes in Part II — the 1958 perceptron, linear and logistic regression, the hidden layer that cracked XOR, LeNet built in twelve lines, and a transformer block built and counted — none of it needed to run a model, all of it a good story.