Learn how generative AI works by building your very own models that can write coherent text, create realistic images, and even make lifelike music.
Learn Generative AI with PyTorch teaches the underlying mechanics of generative AI by building working AI models from scratch. Throughout, you’ll use the intuitive PyTorch framework that’s instantly familiar to anyone who’s worked with Python data tools. Along the way, you’ll master the fundamentals of General Adversarial Networks (GANs), Transformers, Large Language Models (LLMs), variational autoencoders, diffusion models, LangChain, and more!
In Learn Generative AI with PyTorch you’ll build these amazing models:
A simple English-to-French translator
A text-generating model as powerful as GPT-2
A diffusion model that produces realistic flower images
Music generators using GANs and Transformers
An image style transfer model
A zero-shot know-it-all agent
The generative AI projects you create use the same underlying techniques and technologies as full-scale models like GPT-4 and Stable Diffusion. You don’t need to be a machine learning expert—you can get started with just some basic Python programming skills.
About the Technology Transformers, Generative Adversarial Networks (GANs), diffusion models, LLMs, and other powerful deep learning patterns have radically changed the way we manipulate text, images, and sound. Generative AI may seem like magic at first, but with a little Python, the PyTorch framework, and some practice, you can build interesting and useful models that will train and run on your laptop. This book shows you how.
About the Book Learn Generative AI with PyTorch introduces the underlying mechanics of generative AI by helping you build your own working AI models. You’ll begin by creating simple images using a GAN, and then progress to writing a language translation transformer line-by-line. As you work through the fun and fascinating projects, you’ll train models to create anime images, write like Hemingway, make music like Mozart, and more. You just need Python and a few machine learning basics to get started. You’ll learn the rest as you go!
What's Inside
Build an English-to-French translator
Create a text-generation LLM
Train a diffusion model to produce high-resolution images
Music generators using GANs and Transformers
About the Reader Examples use simple Python. No deep learning experience required.
About the Author Mark Liu is the founding director of the Master of Science in Finance program at the University of Kentucky.
The technical editor on this book was Emmanuel Maggiori.
Quotes Mark has an engaging writing style and makes complex concepts accessible, and enjoyable. I highly recommend this book. - Simon Sheather, Dean of the Gatton College of Business & Economics, University of Kentucky
An exceptional guide with real-world examples. Interactive, approachable, and highly practical! - Noah Flynn, Research Scientist, Amazon
Comprehensive, hands-on, and state-of-the-art. After reading it, you’ll understand generative AI models and be equipped with the tools to build your own. - Arpit Singh, Senior Software, Engineer, Nvidia
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.