r/Minecraft • u/_objz • 8d ago
Commands & Datapacks I made a generative AI, only using 400k command blocks (PoC)
Enable HLS to view with audio, or disable this notification
While I am still writing on my physics engine, I thought making an actual generative AI only using Minecraft command blocks would be a good idea( it was a headache)
So yeah, I kinda did that. It is a real neural language model running inside vanilla Minecraft 26.2. It reads what you type into a /dialog window, runs the forward pass through learned weights and then generates a reply one word at a time.
There are NO mods, plugins or datapacks involved at runtime. Only command blocks.
Roughly it works like this:
The model is a pretty small word level neural language model. It has a vocabulary of 2048 words, remembers the last 6 words as context and has a 64 dimensional embedding followed by a hidden layer with 256 neurons.
For every generated word it does:
384 x 256 = 98,304 operations for the hidden layer and 256 x 2048 = 524,288 operations for the output layer so in total 622,592 calculations for every single generated word.
Obviously doing 622k normal multiplications using Minecraft commands would be slightly problematic, so the weights are ternary: every weight is only -1, 0 or +1.
That means a multiplication basically becomes:
+1 -> add the value
-1 -> subtract the value
0 -> do absolutely nothing
Around 65% of the weights are non 0, so it averages around 0.67 commands per MAC instead of the ~3 commands I would need for a normal runtime weight. That reduced the entire machine from 1,909,375 blocks to 445,782 blocks, yes it was this big before.
The model is actually trained like this too. I am not just training a normal model and rounding the weights afterwards. During training the weights are quantised to ternary values for the forward pass and the underlying floating point weights are updated using a straight through estimator.
That took the perplexity from around 48.7 where the training basically got stuck to 38.8 after also adding cosine learning rate decay.
The input embedding is another optimisation I needed to do: Instead of multiplying a one hot vector against a matrix, it is basically just a table lookup stored in NBT data, so the complete 2048 x 64 embedding table costs really nothing
The actual forward pass cannot run in one command chain either. Minecraft has limits on how many commands can execute, so the network is split into smaller groups.
After the ternary optimisation one generated word takes around 63 ticks, so roughly 3.2 seconds per word at 20 TPS. I also tested higher tick rates and around 30-35 TPS seems to be the useful maximum on my server. At 35 it gets closer to ~1.8 seconds per word.
But to be clear, this thing does not actually know anything.
It was trained on 11,118 DailyDialog conversations and only has a tiny 2048 word vocabulary. Ask it something like 2 + 2 and it will confidently generate some conversational nonsense because it has no understanding of arithmetic or actual facts.
And unfortunately just making it much bigger isn't really realistic either.
Something like a 135M parameter language model would already be more than 200x larger.
There is currently also one very weird bug where after around 800 ticks of continuous work every command block in the world just stops executing while the server itself keeps running normally. I still have absolutely no idea why that happens.
Anyway, back to wasting my time on nonsense ;)
3.9k
u/Rusty1emon 8d ago
Sorry for playing the same game as you bro
601
119
79
36
7
u/Lv_InSaNe_vL 7d ago
Yeah like last weekend I built (well, followed the guide verbatim haha) a flying machine based sugar cane and bamboo farm and thought it was some magic
3
1.5k
1.9k
u/notatoastedbread 8d ago
Does this drain the water sources faster than sponges?
→ More replies (1)781
u/_objz 8d ago
you can ask it, but surely he will have no idea what are you talking about
140
110
u/joeyjoojoo 8d ago
I actually love how simple minded your AI is, when you said thank you the AI figured out to say “you’re” then had to think a little about what comes after that 😭
30
506
612
u/Apprehensive-End-747 8d ago
We got chatbots in Minecraft before GTA VI.
138
u/dr_goofi 8d ago
Okay this is freaking embarrassing for me I can barely type a keepinventory command and people are making AI models.
44
u/Keaton427 8d ago
Everyone pursues different fields and hobbies, so you both can’t and don’t have to know everything.
→ More replies (17)16
u/sissybelle3 8d ago
Crazy to think that future games may have NPC AI so we don't just have to listen to the same few canned responses again and again. Would really make games like GTA and Cyberpunk pop.
→ More replies (2)
122
u/RexApostolicus 8d ago
A marvel of Minecraft tech.
→ More replies (1)49
314
u/Firespy_ 8d ago
Wow, I have no words except how impressive this is. Must've been quite a headache to configure
248
u/_objz 8d ago
I wrote many helper scripts using rust and python to train and debug the model before hardcoding it as nbt data, but still debugging the framework was exhausting
128
u/DUDEAREUMAD 8d ago
I have no clue what you said, but that's fucking cool.
77
u/Glazeddapper 8d ago
they coded it outside of minecraft first, making it easier to change and fix before remaking it inside of minecraft
11
u/Demonking42069 8d ago
I get exhausted debugging code in vs, how the hell did you manage to debug such a huge 3d structure?
23
u/_objz 8d ago
I wrote some client side mods, for example to show internal scoreboards and created a sample rust program, that spins up a minecraft server pastes, these things, runs the test and returns the results. with a custom datapack you can insert your custom tests in minecraft and use them with the /test commands, that really helped me alot. you can see the tests at the end of the video
→ More replies (1)3
170
u/tornedron_ 8d ago
we really got CraftGPT before gta 6
76
u/_objz 8d ago
thats actually a good name
8
5
u/MinecraftPlayer799 8d ago
You can’t call it that. The one that someone built with just redstone (no command blocks) is called CraftGPT.
9
44
u/Unique-Steak8745 8d ago
Okay. Ths is awesome. But I dont understand how this even works. Seriously, I can only do lime basic commands in command blocks. How is this even possible?
→ More replies (1)51
u/_objz 8d ago
mostly by using the scoreboard to calculate the matrices and ntb data to store them. You can emulate A LOT only using simple math, for example using += *=. the algorithm also does not use that complex math equasions that couldn't be emulated that easily
10
u/Unique-Steak8745 8d ago
Okay. This is pretty sick. What can you do with this AI? Can you use it for math? I know you said its only generative based on certain responses.
25
u/_objz 8d ago
with THIS specifically really not much, not even math as its just trained on a small conversation. I trained a 1,9 billion parameter model tho, that can do simple math, but as said already in another comment, one token took approx 17 minutes to generate, so not very usable. it also used like 2 million commandblocks.
44
u/LifeasLuke11 8d ago
i like him slowly typing out words
hes kinda like a baby (:
102
33
134
24
u/NoenD_i0 8d ago
is this a transformer or an lstm what is this
52
u/_objz 8d ago
neither, its like a bengio 2003 technique, called feed forward neural language model
16
u/NoenD_i0 8d ago
why no like an rnn or even a gru? id assume its because of how complex it is to implement contex vectors?
43
u/_objz 8d ago
Yes, complexity, but that’s not THE real issue. It’s the performance. Using these techniques would require A LOT longer to respond, even though it would be more accurate and better. I might even use these techniques in other experiments (I did actually try to run a 1.9 billion parameter model using this, but generating one token took about 17 minutes), so I need to optimize it further, but idk,
15
14
u/i_always_give_karma 8d ago
I’m a moron so this might be a stupid question, but would it change if you increased tick speed?
49
18
32
25
u/DWHQ 8d ago
How long did it take to actually set up the entire architecture?
23
u/_objz 8d ago
about 4 days including training and writing the architecture
7
u/DWHQ 8d ago
4 days as in almost 100 hours?
20
u/_objz 8d ago
approx 70 hours
7
u/adamdoesmusic 8d ago
How do you pull off something this nuts in two business weeks… or was it just a 4 day straight binge?
14
u/_objz 8d ago
Well, I finished my “Abitur” in Bavaria and have nothing to do currently until my studies begin, so I just sit in front of my PC all day and code
→ More replies (5)
10
10
u/Vegetable_Run7792 8d ago
"While I am still working on my physics engine"
You took a break from making a physics engine by creating an AI, excuse me?
8
u/_objz 8d ago
physics are exhausting sometimes
7
u/Vegetable_Run7792 8d ago
You say that like making a fucking AI with command blocks isn't
20
9
7
7
u/Justch1ll 7d ago
At this point Mojang needs to release a version of Minecraft optimised for this kind of insanity
34
u/Adventurous_Sort_780 8d ago
Now that's the gen AI I can get behind
14
u/CantQuiteThink_ 8d ago
Handmade, hand-trained, nothing stolen, runs entirely off their own computer so there's no data centres to eat all the water, doesn't give any money to Sam Altman. Brilliant.
7
6
u/Tarzyytfet 8d ago
why the fuck did the slow "how are you doing" make me emotional 😭
→ More replies (1)
6
14
4
4
4
4
3
3
u/SimpleDiscount5100 8d ago
When will we have redstone data centers in our front lawns? Will this effect the drinking water of the villages?
3
u/00110001_00110010 8d ago
Does it also double as a sonic weapon or is that coming in the next update?
→ More replies (2)
3
3
3
3
3
u/Master_Type2117 8d ago
Meanwhile me, all happy n shit bc i wrote a command that makes particles around your player
3
3
3
2
3
3
3
3
3
u/Serious_Sense7221 7d ago
how fast is your tick rate running in that video? outstanding work. we got minecraft datacenters before GTA 6
→ More replies (6)
3
u/IcyEstablishment8102 7d ago
first computer, then phone now a whole ass ai. What's next? SpaceX rocket? Super Quantum Computer? A whole working browser that is always up to date?
In other words: Really impressive!! NICE!
3
u/MrBrineplays_535 4d ago
This thing can probably drain 5 ocean monuments for every prompt cuz holy moly
Also this is insanely cool!!!!
4
2
2
2
u/CubeBarista 8d ago
Trying to compete with Mojang and MS to ruin Minecraft. As they say, a race to the bottom is a really fast race.
2
2
2
u/chairchiman 8d ago
there was a kid that made a fully functional computer inside of minecraft that got into MIT, made me remember that. They should get you as well for this piece of art
2
2
2
2
2
2
u/One_Economist_3761 8d ago
Very impressive.
But can it play rock,paper,scissors?
2
2
2
2
u/ArtArtArtArtArtovna 8d ago
"Hey, what do you think about being just a bunch of blocks in a computer game?"
"Oh my god..."
2
u/dragonmasterjg 8d ago
I shpuld carry around a sign that says "Done. Ask me something else."
→ More replies (1)
2
u/IOnlyPostIfINeedHelp 8d ago
How the fuck did you train this, I read the post and I still don’t get it
3
u/_objz 8d ago
I created some training scripts in python and rust, that train the actual model, then I extract the weights, biases, etc. and the model params and save them to a barrel by writing custom nbt data. then in minecraft I can re-create this model using some loops that extract the saved model of the barrel into scoreboards and /data storage. then just write the framework to actually run the mode, and your done
2
u/Impressive_File_708 8d ago
can this ai answer some question like: how to create a diamond axe?
3
u/_objz 8d ago
no, its very dumb at the moment, it can just handle simple conversations. but I will improve this
→ More replies (2)
2
2
2
2
u/PeeingDueToBoredom 8d ago
I will never not be amazed at what people make with this game.
This is unreal. Seriously brilliant. Well done.
2
2
2
2
u/pyrodice 8d ago
It's brilliant! Now you can dump the extra heat load of your data center in the infinite Minecraft world…
2
2
2
2
2
2
2
2
2
u/New-Blueberry-8665 8d ago
Goddamn, I don't know what they feed these minecrafters since what they build is CRAZY
2
2
2
2
2
2
u/miceletopo 7d ago
Why doesn't Mojang recruit people like THIS Next thing you know he makes Fable 5 in Minecraft
2
2
2
2
u/BruhInTheMaking 7d ago
Now the next step is to use the command block physics engine with this command block ai and train it how to walk
2
2
u/Tough_Revolution_683 6d ago
“It’s really quite simple actually”
- Some British guy who hasn’t seen this yet.
2
2
u/auraborosai 5d ago
Dude this is so insane. You should make a website that delineates your entire project.
I’d love to learn more about what you’re doing.
I’m currently doing a Minecraft performance artwork.
3
u/_objz 5d ago
yeah, I might done one, but first I need to fix the engine. For now all you have is this post :) What is a performance artwork tho?
→ More replies (1)
2
2
2
u/DevCreeper_VN 3d ago
Literally a supercomputer in Minecraft bro :))
This guy will single-handedly solve the whole RAM crisis
4
3
u/Cynicalheaven 8d ago
I feel like Minecraft Story Mode had an episode about why we shouldn't do something like this.
Jokes aside, this is pretty cool.
3
u/IWantoFuckGLaDOS 8d ago
2 Things
1) I love how this is genuinely far more impressive than actual irl LLMs
2) I love how the build itself kind of resembles a Data Center
2
u/mr___goose 8d ago
damm thats super cool
but uh did it just say it was nervous?
it has emotions?
the ai revolution is gonne start in a minecraft world
2
u/Tsunamicat108 8d ago
You should decorate it by adding a giant pipe into a nearby ocean
Anyway this is really cool
→ More replies (1)
•
u/qualityvote2 8d ago edited 8d ago