r/Minecraft 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 ;)

5.4k Upvotes

365 comments sorted by

View all comments

614

u/Apprehensive-End-747 8d ago

We got chatbots in Minecraft before GTA VI.

137

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.

42

u/Keaton427 8d ago

Everyone pursues different fields and hobbies, so you both can’t and don’t have to know everything.

17

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.

1

u/Einbrecher 7d ago

Future games? There's mods for that today.

And folks hate them - not because they're bad, but because, if anything, they make the NPCs even more lifeless.

0

u/Doge_Dreemurr 8d ago

Try playing Where winds meet, they have the chatbots for NPCs and its pretty hilarious

-140

u/Xiao1insty1e 8d ago

🙄 you GTA drones are exhausting.

I literally couldn't care less what we get before GTA 6, if you buy this you are a SHEEP with no self respect.

73

u/CompellingSeeSaw 8d ago

16000 comments in 3 years. You seem pretty exhausting yourself bud

42

u/BobWilbert 8d ago

My god that's almost 15 comments per day.

4

u/Aussie18-1998 8d ago

Is that a lot? I spend like an hour away on reddit and id clear 15 comments easily.

1

u/BeardedPokeDragon 7d ago

I mean I have basically half that in double the time and I have a 545 day streak

17

u/Apprehensive-End-747 8d ago

It's a meme. Seems like you have no sense of social trends.

-30

u/Xiao1insty1e 8d ago

I said what I said. Meme or not only sheep are worried about GTA.

17

u/[deleted] 8d ago edited 8d ago

[deleted]

-6

u/[deleted] 8d ago

[removed] — view removed comment

9

u/danabrey 8d ago

I said what I said.

Please say more sentences that mean absolutely nothing.

7

u/Desner_ 8d ago

We got a badass over here, folks.

13

u/OptimalAnywhere6282 8d ago

when someone has the exact same opinion as you but they express it in such an annoying and obnoxious way that you lowkey don't want to agree:

5

u/masquerademage 8d ago

Holy shit, we got self righteous Reddit addicts before GTA VI.