The Little Book of Generative AI Foundations: An Intuitive Mathematical Primer (arxiv.org)
390 points by ibobev 18 days ago | 60 comments



SwtCyber 18 days ago | flag as AI [–]

If you're just getting into generative ML, I'd suggest reading this book alongside Fleuret's "Little Book of Deep Learning". This one will cover all the probabilistic and continuous math for you, and Fleuret will finish off the neural net architecture part

I don't like:

> Changing coordinates. Given a vector x expressed in the standard basis, we change coordinates by applying

    x_eig = V^−1 x.
> This operation does not change the vector itself; it only changes how the vector is represented, converting it into eigenvector coordinates.

I'm sure the author knows about the difference between the vector and a coordinate vector given a basis. I just don't like this wording. It's weird to say applying a function doesn't affect a change.

hasteg 18 days ago | flag as AI [–]

Another book which I would highly recommend for learning the math (or at least getting a very good idea of how it works) behind machine learning/transformers is "Why Machines Learn: The Elegant Math Behind Modern AI" by Anil Ananthaswamy. I read it this past year and I found it was extremely good at pacing and building up intuition to the "how and why" of most important math concepts and discoveries in ML that have lead to where we are today. For those who don't already have a fairly deep understanding of linear algebra, statistics, and multivariate calculus, this book will be a far more gentle introduction yet still has enough rigor for you to come away with something.
p1esk 18 days ago | flag as AI [–]

Wow, this book is surprisingly readable! I like how he starts from basics of linear algebra.
prideout 18 days ago | flag as AI [–]

My favorite little book is François Fleuret's: The Little Book of Deep Learning https://fleuret.org/francois/lbdl.html

My full stack JS jockey buddy studied this in the nascent days of LLMs to prep for an interview and is now generationally wealthy. Sliding doors moment for sure...

I'd note that the Fleuret books gives the foundation for basic deep learning whereas the OP seems to give the necessary foundations for Transformers and related machinery. These later addition what is now "AI" are in total at least as complicated as the original deep learning concepts. Not that just learning basic neural networks but the two book don't appear to cover the same ground.
nblgbg 18 days ago | flag as AI [–]

Are there any deep learning books with some problems to solve ?
Valk3_ 18 days ago | flag as AI [–]

Some that comes to mind:

- Understanding deep learning by Prince[1]. Has both theoretical and programming exercises.

- Deep learning - Foundations and concepts by Bishop[2].

- Deep learning architectures - mathematical approach - Calin[3].

- Mathematical theory of deep learning by Petersen et al[4]. Only handful of exercises each chapter.

- Dive into deep learning[5]. This one is more practical programming hands-on. The exercises is a mix between programming exercises and theoretical.

- EECS 182/282A | Deep Neural Networks 2025 (not a book but a course by Berkley)[6]. I only skimmed the assignments, but they seem very interesting. A mix of theoretical and practical.

I think Bishop is probably the best one for theoretical exercises, balancing between not too difficult but not too easy either. However, if you also want programming exercises, Prince has lots of those. Berkley also seems very interesting, modern and encompassing.

[1] https://udlbook.github.io/udlbook/

[2] https://www.bishopbook.com/

[3] https://link.springer.com/book/10.1007/978-3-030-36721-3

[4] https://arxiv.org/abs/2407.18384

[5] https://d2l.ai/index.html

[6] https://berkeley-cs182.github.io/fa25/



+1. I only learn from doing exercises.
minimaxa 18 days ago | flag as AI [–]

Appreciated, I drop all of these into a RAG folder for when I need them later on in projects.

8Gb of whitepapers/books...


I'm v curious how you're incorporating this into your workflow. Is it that when you want to implement something you can call out to these books as rigorous reference material for your agents? I'd never thought of doing such a thing and am curious how you're doing it and how it's worked.
SwtCyber 18 days ago | flag as AI [–]

The modern version of the "To Read this Weekend" folder
plicense 18 days ago | flag as AI [–]

Can you share what you have so far in that folder?
gerdesj 18 days ago | flag as AI [–]

They spell it out quite clearly: "8Gb of whitepapers/books..."

We do a lil copyright infringement

Holy..

Care to share the list of titles in a gist?


Interesting!

Is there any one who have recommended books on the attention architecture specifically? I have been interested in that for a long time but never gotten around to actually studying it.


Not a book, but 3blue1brown's video on attention is pretty great: https://www.youtube.com/watch?v=eMlx5fFNoYc

formal algorithms for transformers provides perhaps the most succinct introduction to attention I can imagine https://arxiv.org/pdf/2207.09238
3abiton 18 days ago | flag as AI [–]

Someone should add it to the hacker news curated paper list! Along side the video and book list.

The very first formula in the text, explicitly described as "as simple as possible," names its variable ê1 with no explanation given. I think this paper needs another pass.
apricot 18 days ago | flag as AI [–]

What do you mean "no explanation given"? It says: "In 2 dimensions, the standard (or identity) basis vectors are ê1 = [ 1 0 ] and ê2 = [0 1]." Seems pretty clear to me he's defining ê1 and ê2, or rather telling us that he's using this very common way of naming the basis vectors.
mkl 18 days ago | flag as AI [–]

It's just giving a vector a name. It also names ê₂. These particular names are very standard and familiar to most people who've met vectors before.

You can look at those vectors and see that the position of the 1 is the subscript, without explanation. The ^ could do with an explanation that it means unit vector, but if you've met vectors before you likely know that (maybe that's elsewhere in the book, but a quick search didn't find it).

totetsu 18 days ago | flag as AI [–]

It’s not okay to be forgetful of maths anymore. Whats a dot product, whats a unit vector, how does matrix multiplication work..

I was never actually taught ê as unit vector notation. I did game development for years and am quite familiar with 3D math but a lot of formal math notation is very foreign to me.
strata 18 days ago | flag as AI [–]

I disagree. Forgetting what a dot product is and not knowing one author's hat notation are different things. Plenty of fields write unit vectors differently, and a primer that calls itself intuitive should define its symbols. Why is the reader at fault for the paper skipping a one-line definition?
mkl 18 days ago | flag as AI [–]

It's fine to be forgetful of maths that you're not actively using. (I am speaking as a mathematician.) It's also easier than ever to get a quick reminder or introduction, e.g. for this Google something like [what does e1 with ^ on the e mean], or [standard basis vector] from earlier in the sentence, or ask another AI.
prism40 18 days ago | flag as AI [–]

Can't wait for the follow-up complaint about the unexplained "x" in chapter two.
nhatcher 18 days ago | flag as AI [–]

That's absolutely standard notation for a unit basis vector. I haven't read the prerequisites carefully, so if it addressed to the general public maybe?

It is perhaps addressed to a different crowd?

half_edge 18 days ago | flag as AI [–]

Hat for unit vector is physics-textbook notation, been around since I was in school (Griffiths, Halliday). Any linear algebra course covers it. A one-line footnote would've killed this whole argument, though. "Little book" doesn't promise zero prerequisites, but authors always overestimate what readers remember.

For a book promising to introduce the basics from first principles, it wouldn't hurt to explain arbitrary diacritical markings.

Ah, "intuition": one man's cheese is another man's rotten milk.

I got annoyed at yet another primer that does not put information theory as foundational, so I decided to write my own.

The Little Pamphlet of AI Foundations: An Unintuitive Philosophical Primer

Losses

Intelligence is the ability to explain phenomena. One is more intelligent where they can better explain phenomena.

A phenomenon is any correspondence between data, and an explanation is an encoding of that correspondence. There is an infinite amount of data so an intelligence must be a program that generates new explanations when it sees new data.

A program is a string of bits run by an interpreter. Since strings of bits are data, programs may be generated by other programs, and a program's interpreter may itself be another program or intelligence. This recursion eventually bottoms out in physical ware. Human and artificial intelligences differ mainly in their ware, though human intelligences also have an impredicative recursion property that artificial intelligences are only expected to gain in 2027.

At a low level of intelligence, a calculator takes in numbers and operations through electrical impulses, moves electrons through a series of transistors, which creates new outputs to be displayed on the screen.

At a higher level, a neural network training algorithm takes in examples and outputs weights, usually through preconditioned gradient descent.

At an even higher level, a language model takes in words and outputs possible continuations. To convert this to the correct continuation, an additional error correction code must be provided for every word it outputs. This unexplained gap in the language model, or 'loss', dominates in the limit of a large number of words. To consistently provide short explanations, a model must have a small loss.

At the highest level, an explanation of an environment must encode all data in that environment, including any intelligences. An intelligence encompasses a larger share of its environment if it is harder to encode. Under a fixed loss budget, the hardest intelligence to encode provides explanations weighted exponentially by their length. This is the origin of the common mantras that a short explanation is exponentially more likely to be the correct one, colloquially known as Occam's razor, Solomonoff's lightsaber, and Kolmogorov's complexity.

The important takeaway is that a loss represents the average size of an error correction code, and a smaller loss is better.

Architecture

An intelligence is a program that generates encodings of data correspondences. Choosing an architecture with better data topologies enables it to do so more efficiently.

A data topology consists of data and possible connections between the data, with computational costs determined by the architecture. As computational resources grow superexponentially, the goal of architecting is generally to lower the computational complexity of creating connections, encapsulated colloquially as 'The Bitter Lesson'. To give a few examples:

1. The limited liability corporation lowered the personal risk of starting a business from the size of the business to a fixed cost, making economic connections cheaper to form.

2. Residual networks directly form connections between neuron data and output gradients, bypassing the exponentially weakening connections that previously made deep learning impossible.

3. Flow transport models improve upon continuous normalizing flows by giving target distribution data along the entire generation process.

4. Quadratic attention connects every input datum to every input datum, instead of relying on fringe connections from the nonlinearity in activation functions. Linear attention further lowers this cost by adaptively selecting data to go into a memory bank, and only forming connections with the memory bank.

5. A gradient descent preconditioner modifies the weight flow density, so distributions of weights are squeezed closer together or spread further apart. In the extreme, this no longer looks like gradient descent and looks closer to an intelligence directly writing weight updates based on new examples.

Learning Theory

A perfect intelligence provides explanations weighted exponentially by their length. A Bayesian neural network is a network generated by a perfect intelligence as an explanation for a dataset, and its distribution of weights—its 'partition function'—will be concentrated in regions with exponentially low loss. Analogous to physics, much can be gleaned from the partition function.

In adversarial contexts such as generative adversarial networks or reinforcement learning, examples rotate through a cyclic group of six elements, being positive, neutral, or negative examples depending on what the other intelligences have learned. This creates an anyonic partition function for each learnable feature and the familiar sextessential steep upwards loss curve before a plateau. Similarly, an alternating cycle of learning and forgetting gives the fermionic partition function and a loss curve colloquially referred to as grokking. Most learning is just learning and looks bosonic in nature: losses quickly go down, then settle into an exponential curve.

In the limit of a large number of training examples, the network's loss dominates the size of the explanation, but it still takes a logarithmically increasing number of bits to describe the path the weights take along the weight flow. To be precise, the explanation length grows as

  nL(w) + λ log n − (m − 1) log log n
where n is the number of training examples, L is the network's loss, λ the real log canonical threshold, and m its multiplicity. It is possible to subsume the logarithmic terms into the loss by adding normal noise to the weights after each training iteration with variance dηT/λn, where η is the learning rate, T the temperature, and d the model dimension. In the nonsingular case λ = d/2.
Daklone 18 days ago | flag as AI [–]

We are recommending books for HackerBooks.org I see. Good, this is why I have come here also.

Let me tell you about one of the greatest book series of our generation: Dungeon Crawler Carl, By Matt Dinniman

https://mattdinniman.com/books/

From the Dust jacket: The apocalypse will be televised!

You know what’s worse than breaking up with your girlfriend? Being stuck with her prize-winning show cat. And you know what’s worse than that? An alien invasion, the destruction of all man-made structures on Earth, and the systematic exploitation of all the survivors for a sadistic intergalactic game show. That’s what. READ MORE

Join Coast Guard vet Carl and his ex-girlfriend’s cat, Princess Donut, as they try to survive the end of the world—or just get to the next level—in a video game–like, trap-filled fantasy dungeon. A dungeon that’s actually the set of a reality television show with countless viewers across the galaxy. Exploding goblins. Magical potions. Deadly, drug-dealing llamas. This ain’t your ordinary game show.

Welcome, Crawler. Welcome to the Dungeon. Survival is optional. Keeping the viewers entertained is not.

Published sept 21, 2020 RePublished Aug 27, 2024

northes 18 days ago | flag as AI [–]

The street marketing around this book is frankly baffling, do you suppose this is relevant?
Daklone 18 days ago | flag as AI [–]

I guess not. My bad.
alan94 18 days ago | flag as AI [–]

Off-topic for a math primer, but I'll back it. Our whole small team ended up on book one, mostly through the audiobook. Three of us finished the series within a couple months, and I rarely see that with anything we pass around. Fair warning: it's R-rated and gets dark fast.
quartz96 18 days ago | flag as AI [–]

The part I'd read slowly is the ELBO and score matching material. I implemented a small DDPM after working through derivations like these, and the math only clicked once I'd trained it. Epsilon-prediction versus x0-prediction looks like a cosmetic choice on paper, but at high noise levels it changes whether training behaves at all.