Kick off your book project in 3 hours! Live workshop on Zoom. You’ll leave with a real book project, progress on your first chapter, and a clear plan to keep going. Saturday, May 2, 2026. Learn more…

Leanpub Header

Skip to main content

Inside Large Language Models for absolute beginners: Volume I

Simple Arithmetic and beginning Python based approach

Most books about ChatGPT explain the magic. This one shows you the math. Inside Large Language Models, Volume I takes a curious beginner from "what is an LLM" to a complete, trained GPT, with nothing more than high-school algebra, a working laptop, and a willingness to read carefully. Every formula is walked through by hand. Every line of code comes with a plain-English explanation. By the end you will have built, trained, and run your own transformer from scratch, and you will know exactly what is happening inside.

No PhD or Data Science required. No prior machine learning needed. Just curiosity and a calculator.

Minimum price

$14.99

$19.99

You pay

$19.99

Author earns

$15.99
$
You can also buy this book with 0 book credits. Get book credits with a Reader Membership or an Organization Membership for your team.
PDF
About

About

About the Book

What if you could understand how ChatGPT actually works, with nothing more than high-school algebra and a working laptop?

Inside Large Language Models, Volume I is the book the field has been missing: a plain-English, math-light, code-first introduction to the technology behind every modern AI assistant. No prior machine learning experience is assumed. No graduate-level mathematics is required. Every concept is walked through with simple arithmetic that a motivated high-school student can follow on paper.

Volume I takes you from the very first question, "what is a large language model, really?" to building and training a complete GPT-style model from scratch in Python. Along the way you will:

  • See every step worked out by hand. When the book introduces attention, you compute attention scores between three actual tokens with three-dimensional vectors and a calculator. When it introduces softmax, you apply softmax to a tiny list of numbers and watch the probabilities come out correctly. There is no hand-waving, no "it can be shown that," no skipping the math.
  • Build the transformer block, piece by piece. Single-head attention. Multi-head attention. Residual connections. Layer normalisation. Feed-forward networks. The language modeling head. Every component gets a chapter that explains the problem it solves, the math behind it, and a working PyTorch implementation you can run on your laptop.
  • Learn the math the way it should be taught. The dot product is presented as a similarity score with a worked example. Softmax is presented as a soft winner-take-all rule with a four-row computation. Backpropagation is walked through a tiny one-weight network with arithmetic at every step before scaling to a 96-layer transformer. If you can multiply two numbers, you can follow this book.
  • Train your own GPT. The final chapter assembles everything into a complete, runnable Python implementation that trains on a small text corpus and generates new text. You will run it. You will modify it. You will understand exactly what every line does.

Who this book is for:

  • Software engineers who want to move beyond calling APIs and actually understand the systems they ship.
  • Students who are tired of textbooks that hide the math behind notation and want to see every step.
  • Curious readers with a high-school background who have heard about transformers and want a real, technical understanding without a PhD-level prerequisite.
  • Practitioners moving into AI roles who need a foundation that goes deeper than online tutorials.

What makes this book different:

Most LLM books fall into one of two camps: the popular-science books that explain the ideas without ever showing the math, and the academic textbooks that bury the ideas under a wall of notation. Inside Large Language Models takes a third path. It treats the reader as a serious adult who wants the real machinery, but it refuses to require any background the reader does not already have. Every formula is preceded by a plain-English paragraph that explains what the formula is doing. Every code listing is followed by a line-by-line table that explains what each line is doing. Every concept is paired with a concrete numerical example you can verify on paper.

Volume I is the foundation: tokenisation, embeddings, positional encoding, attention in all its forms, the complete transformer block, training, and a from-scratch GPT. Volume II takes those foundations into production: inference, alignment, fine-tuning, and four end-to-end fine-tuning projects.

By the end of Volume I, you will not just know how a transformer works. You will have built one yourself, trained it, and watched it generate text. The mystery will be gone. What is left is mastery.

Companion code: every listing in the book is available as a runnable Python file at https://github.com/ritesh-modi/inside-llm. Clone it, run it, modify it, break it, fix it.

Author

About the Author

Ritesh Modi

Ritesh Modi is Head of AI at MarketOnce and a former Forward Deployed Engineer at Microsoft. He has spent more than a decade building and shipping production systems across cloud, distributed computing, and applied machine learning, working with organizations ranging from global enterprises to fast-moving startups. His recent work focuses on applied large language models, designing systems that turn pretrained models into reliable, task-specific tools.

Ritesh has authored multiple technology books and speaks regularly at industry conferences on AI, cloud architecture, and software engineering. His writing philosophy rests on a simple belief: the best technical books are written by practitioners who still remember what it felt like to not understand something, not by experts who have forgotten. Every explanation in this book was tested against that standard, if it would not have made sense to him when he was first learning this material, it was rewritten until it did.

He writes, shares ideas, and connects with readers at www.riteshmodi.com. When he is not writing or building AI systems, he can be found mentoring engineers, exploring new architectures, or debugging a training run that should have converged three hours ago.

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

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.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

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

In fact, authors have earned over $15 million writing, publishing and selling 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