AI Images and the Library of Babel

In this post, I am going to talk about my summer learning Python, the Library of Babel, and how image generation via AI models are all connected. I’ll talk about each of them separately and then connect the dots.


Learning Python

Back in 2012, I was home in Port Blair for the summer holidays after my first year in college. My parents had tried their best to get me an internet connection at home, but the best we could get on the island was a 2G dongle. So before packing up from my hostel, I made sure to download a copy of O’Reilly’s Python for Dummies and set up a working installation on my laptop.

Programming in isolation, without modern-day distractions, was a rewarding experience by itself. I was already pretty good at C and C++ from school, so picking up Python wasn’t daunting. But man, was I in for a fun surprise. Python is frikkin cool. It didn’t even feel like coding. It felt like writing pseudo-code and actually getting away with it.

One of the most fascinating things I started exploring was image processing. In a Python program, an image isn’t a snapshot of reality or a creative masterpiece. It’s just a 2D matrix of pixels. Each pixel is a combo of Red, Green, and Blue values, each represented by 1 byte, which means a number between 0 and 255. With just these three primary colors—RGB—you can represent any color on screen.

As a kid, I was pretty good at watercolor art, so this all made intuitive sense to me.

Then came the epiphany: if every image is nothing but a 2D matrix of RGB values, then theoretically, if you could generate enough permutations and combinations of those values, you could generate every image. Every image that has ever existed, every image that ever will, or even ones that never will.

Every person, living or dead.
Every person not yet born.
Every object, every car, every schematic, every logo, every planet, every being in the universe.
Maybe even the answer to life.

It’s all just one random combination of pixels.


The Library of Babel

Then a couple of years later, I was watching a video by VSauce – Messages For The Future (17:07)

As with any VSauce video, it was a power pack of information from all over the place that to this day has no match. In the later half of the video, Michael talks about the Library of Babel, and to quote him:

...the Library of Babel. It’s a website built by Jonathan Basile that currently offers everything that has been or could be written… Basile has organized it all into hexagon-shaped rooms, each with four walls of books containing five shelves with 32 volumes of 410 pages each… browsing the online library feels like a treasure hunt…

Every possible combination of English letters, spaces, commas, and periods—3,200 characters long—exists somewhere in this library. You can find in this library the description of your birth, every possible description of your death, every poem, every joke, every lie, anything that could be said can be found on this site.

This thing blurs the line between invention and discovery. Did you really discover or invent that thing if its description already existed?

Here’s a link to the Library of Babel for you to play around with – https://libraryofbabel.info/

With this piece of knowledge, I’m inclined to call my idea—the Gallery of Babel.


Invention or Discovery?

I think it all boils down to this fundamental question. Are we inventing or discovering? In every sense, you could think of both invention and discovery as two sides of the same coin. If one is top down, then the other is bottom up. You need to discover to invent and you need to invent to discover. Whether the Library of Babel or my Gallery of Babel, they contain everything already. So the next time you click a photo, just remember that it was already there in my gallery.

But before you lose hope, I want to tell you that you are not random, you are special, and so is your photo. When you click the photo, it was a needle in my haystack. I could have not found the needle in millions or billions of years, but you did, so you win. But jokes aside, I believe this is a statement about the conscious experience itself.


AI Images

As I promised, it is time to tie it all together. AI-generated images work on a technology called a diffusion model. It starts with a noisy canvas and slowly imagines an image—pun not intended ;)

(Dammit, is there a relation between image and imagine? Let me come back after some googling) (Yes, they both come from the word imago—meaning image. Crazy!)

If you were expecting a deep-dive into how diffusion technology works, I’m sorry to disappoint, but I’ll leave you with some food for thought.

If conscious experience is what invents images rather than discovers them, then doesn’t the AI also exhibit some level of consciousness? And if AI is conscious, and so are you, then what’s the difference between us? What’s the common thread? Also, is AI an invention or a discovery?

That’s a thinker.

Thank you for reading.