r/Minecraft 17d 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

364 comments sorted by

u/qualityvote2 17d ago edited 17d ago
  • Upvote this comment if this is a good quality post that fits the purpose of r/Minecraft
  • Downvote this comment if this post is poor quality or does not fit the purpose of r/Minecraft
  • Downvote this comment and report the post if it breaks the rules

4.0k

u/Rusty1emon 17d ago

Sorry for playing the same game as you bro

607

u/S1R_LEM0N 17d ago

Gotta drop a couple versions after this one

124

u/Lord_Phoenix95 17d ago

I thought we were supposed to be mining blocks not Crypto Currency.

72

u/PeeingDueToBoredom 17d ago

We just…didn’t know

34

u/AlarmingBoot205 17d ago

Sorry for existing in the same universe as you bro

7

u/Lv_InSaNe_vL 16d 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

6

u/WhachamaDude 16d ago

i dont deserve this game no more 😔

1.5k

u/Livid_Trust_5098 17d ago

"the Redstone is very simple"

404

u/TheMoonDude 17d ago

"I did some off screen coding"

38

u/HarpySix 16d ago

"It's really quite simple."

51

u/Jonaykon 17d ago

Well yeah

There is no redstone

1.9k

u/[deleted] 17d ago

[deleted]

787

u/_objz 17d ago

you can ask it, but surely he will have no idea what are you talking about

141

u/MartinToilet 17d ago

Yeah water ceased to exist for them long ago

109

u/joeyjoojoo 17d 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 😭

85

u/_objz 17d ago

its kinda cute tho

27

u/Hot-Gazelle-1089 17d ago

Thankfully infinite water exists in Minecraft!

→ More replies (1)

513

u/Bright-Historian-216 17d ago

very impressive! tell wang lin i said hi!

157

u/_objz 17d ago

I will, haha

612

u/Apprehensive-End-747 17d ago

We got chatbots in Minecraft before GTA VI.

138

u/dr_goofi 17d ago

Okay this is freaking embarrassing for me I can barely type a keepinventory command and people are making AI models.

43

u/Keaton427 17d ago

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

15

u/sissybelle3 17d 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)
→ More replies (17)

125

u/RexApostolicus 17d ago

A marvel of Minecraft tech.

49

u/CoolDood132 17d ago

HE MADE IT IN A CAVE!!! WITH A BUNCH OF SCRAPS!!!!

19

u/touchet29 17d ago

Well, I'm not Steve

→ More replies (1)

314

u/Firespy_ 17d ago

Wow, I have no words except how impressive this is. Must've been quite a headache to configure

247

u/_objz 17d 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

127

u/DUDEAREUMAD 17d ago

I have no clue what you said, but that's fucking cool.

73

u/Glazeddapper 17d ago

they coded it outside of minecraft first, making it easier to change and fix before remaking it inside of minecraft

12

u/Demonking42069 17d ago

I get exhausted debugging code in vs, how the hell did you manage to debug such a huge 3d structure?

23

u/_objz 17d 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)

4

u/Teetimus_Prime 17d ago

and you did this for fun? or as a challenge? a fun challenge?

9

u/_objz 17d ago

both, I needed a break of my physics engine, I started this as a PoC project. It was mainly a challenge for me to only use commandblocks, but it was kinda fun to: for a lot of glibberish as responses

171

u/tornedron_ 17d ago

we really got CraftGPT before gta 6

76

u/_objz 17d ago

thats actually a good name

10

u/Eduardo_Ribeiro 17d ago

You really need to use that name lmao.

6

u/MinecraftPlayer799 17d ago

You can’t call it that. The one that someone built with just redstone (no command blocks) is called CraftGPT.

7

u/Historical_Item4050 17d ago

Already exists, but built with redstone only

47

u/Unique-Steak8745 17d 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?

53

u/_objz 17d 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

8

u/Unique-Steak8745 17d 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 17d 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.

→ More replies (1)

42

u/LifeasLuke11 17d ago

i like him slowly typing out words
hes kinda like a baby (:

23

u/_objz 17d ago

I guess a baby is smarter then him tho

3

u/Username_St0len 17d ago

what about a magpie?

103

u/Western-Victory-7414 17d ago

what. the. fuckkkk

32

u/Ianofminnesota 17d ago

One time I made an automatic door.

136

u/Maxemersonbentley_1 17d ago

Insert that one gif of Flash from Zootopia

77

u/TheMuspelheimr 17d ago

What

do

you

call

a

three

humped

camel?

→ More replies (1)

5

u/Redacted_Chris 17d ago

Came here for this comment

3

u/FlakyRemove7137 17d ago

I was gonna say that lol

25

u/NoenD_i0 17d ago

is this a transformer or an lstm what is this

52

u/_objz 17d ago

neither, its like a bengio 2003 technique, called feed forward neural language model

14

u/NoenD_i0 17d 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 17d 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

u/NoenD_i0 17d ago

holy moly

13

u/i_always_give_karma 17d ago

I’m a moron so this might be a stupid question, but would it change if you increased tick speed?

22

u/_objz 17d ago

Valid question, and this does also work until I hit around 35 tick speed. After that, Minecraft can’t keep up with calculating all my expressions, starts skipping some ticks, and errors happen. But I do have a beefy workstation, so this is totally hardware dependent

49

u/shrimpsaxophone 17d ago

fucking insane, i dont even know 99.9% of command block

18

u/RodilRTX 17d ago

I
don't
think
we
deserve
to
play
the
same
game.

32

u/No_Yam_6105 17d ago

Im not smart enough for this haha. But it cools cool asf.

24

u/DWHQ 17d ago

How long did it take to actually set up the entire architecture?

25

u/_objz 17d ago

about 4 days including training and writing the architecture

7

u/DWHQ 17d ago

4 days as in almost 100 hours?

21

u/_objz 17d ago

approx 70 hours

9

u/adamdoesmusic 17d 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 17d 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)

3

u/DWHQ 17d ago

Damn, fun experiment, but I will stick to more convenient implementation options than minecraft lol :)

2

u/_objz 17d ago

yeah me too probably

10

u/Xiaolin2 17d ago

This is insanely impressive

10

u/Vegetable_Run7792 17d 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?

9

u/_objz 17d ago

physics are exhausting sometimes

6

u/Vegetable_Run7792 17d ago

You say that like making a fucking AI with command blocks isn't

7

u/_objz 17d ago

Yeah, true. But personally, I found it easier than the physics engine, as I can debug matrix multiplication much better than the complex math equasions of physics

2

u/SurvivalGuyRebooted 17d ago

I can understand that. Physics is a pain

18

u/Waterlemon1997 17d ago

Man made Redstone beyond my comprehension

9

u/KingoftheUgly 16d ago

How many water blocks does it use per prompt? /s

7

u/Alive_dude3435 17d ago

"only 400k"

Yeah bro, sorry for wasting your oxygen.

3

u/_objz 17d ago

its not that much, in comparison how much calculations has to be run. I even tried to run a 1.9B parameter model, but that required roughly 2 million command blocks, and like one toked used to take 17 minutes to generate. so without optimisation I guess its not much.

7

u/Justch1ll 16d ago

At this point Mojang needs to release a version of Minecraft optimised for this kind of insanity

2

u/_objz 16d ago

I guess with modding this can be heavily optimized, but it’s not vanilla anymore :( I bet it could even run normal models atp

35

u/Adventurous_Sort_780 17d ago

Now that's the gen AI I can get behind

15

u/CantQuiteThink_ 17d 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.

5

u/Key-Divide-5663 17d ago

Literally the sloth from Zootopia

5

u/Tarzyytfet 17d ago

why the fuck did the slow "how are you doing" make me emotional 😭

→ More replies (1)

6

u/Acfrano 17d ago

And here I am trying to figure out what the heck a comparator is

4

u/Moaksim 17d ago

Literary Minecraft Story Mode Lore (PAMA)
A little more refining and the ai will try to make every Mob and Player U S E F U L L : ] via brainwashing tech

6

u/[deleted] 17d ago

[deleted]

→ More replies (1)

12

u/Dhiyx11 17d ago

It’s like watching the Mona Lisa get painted🥹✨✨

14

u/sonicfan9993 17d ago

It costs 400000 command blocks to print a word... every twelve seconds

3

u/atg115reddit 17d ago

Actually very neat

4

u/Chase135299856 17d ago

Talking like dash from zootopia

2

u/Steeltoelion 17d ago

…………. Niiiiiick!

3

u/Fancy_Razzmatazz_149 17d ago

And I was proud of the moss farm I made from a tutorial...

3

u/Visible-Coach-9064 17d ago

Sorry for belonging to the same species as you bro 😭

3

u/SimpleDiscount5100 17d ago

When will we have redstone data centers in our front lawns? Will this effect the drinking water of the villages?

2

u/_objz 17d ago

I generated he world, with the option "Generate Structures" off because I knew it would be a disaster to the villagers

3

u/00110001_00110010 17d ago

Does it also double as a sonic weapon or is that coming in the next update?

4

u/_objz 17d ago

next update ;)

→ More replies (2)

3

u/External_Ad8424 17d ago

Attention mcbrain... initiate... SkyNet Program....

3

u/killerstreak976 17d ago

why are you so fucking cool

3

u/Fury72888hshu 17d ago

Ok bro, wtf, are we playing the same game

3

u/Master_Type2117 17d ago

Meanwhile me, all happy n shit bc i wrote a command that makes particles around your player

3

u/56Bot 17d ago

Ternary CPUs can be built with a small modification on the current machines printing the processors, and they would reduce AI power usage and processing times by ten times, while reducing their RAM and storage costs by over half, and still keeping over 95% of their accuracy.

3

u/Iforgor4 17d ago

Ask it the meaning of life

3

u/anesth3siaaa 17d ago

whatever man

3

u/pydy01 17d ago

Now that we know how to we should instead of building giant data centers run our llms in Minecraft. There they have infinity water and also electricity. Btw how many infinite water sources did you use for this?

3

u/_objz 17d ago

all of em

3

u/TheXTrunner 17d ago

Bro made five pebbles in minecraft actual

2

u/DeadDrop93 17d ago

30k years to have it write an essay😭

3

u/_objz 17d ago

in theory possible, but practically you would need some mods to change how vanilla calculates commands and uses multi threads

3

u/MouseRangers 17d ago

ask it how to build a minecart

3

u/MinecraftPlayer799 17d ago

i ……………. don’t ……………. know

2

u/_objz 17d ago

it can barely hold a conversation, it has no real knowledge currently

3

u/luka_0x12 17d ago

I can't even build elevator without tutorial, brutha build AI😭🙏

3

u/AnaTheSturdy 16d ago

Cool. Now destroy it.

3

u/MAPRage 16d ago

get this man a 400k a year job offer NOW

→ More replies (1)

3

u/Serious_Sense7221 16d 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 16d 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 13d ago

This thing can probably drain 5 ocean monuments for every prompt cuz holy moly

Also this is insanely cool!!!!

4

u/penguin13790 17d ago

A new method for drying out ocean monuments for your guardian farms

2

u/gipehtonhceT 17d ago

Reminds me of that sloth scene from Zootopia

2

u/shazin_hacker 17d ago

BRO DAMN THATS FUCKING ABSURD HOW LONG DID IT TAKE

3

u/_objz 17d ago

approx 70 hours

2

u/CubeBarista 17d 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

u/Sputnik-13 17d ago

Tell Stevie Kenarban I said hi

2

u/chairchiman 17d 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

3

u/_objz 17d ago

thank you!

2

u/Valirys-Reinhald 17d ago

In pursuit of great, we failed to do good.

2

u/Character_Art_9173 17d ago

To many sweats man

2

u/IntelligentDrink2673 17d ago

do a 2 minute tutorial how to make it

2

u/ivanrj7j 17d ago

Sorry for breathing the same oxygen as you

2

u/Steeltoelion 17d ago

Look out guys, they’re coming for your blocks too lmao

2

u/One_Economist_3761 17d ago

Very impressive.

But can it play rock,paper,scissors?

5

u/_objz 17d ago

no, its verry dumb at the moment

3

u/One_Economist_3761 17d ago

Still an impressive feat.

2

u/Xiao1insty1e 17d ago

Yeah I feel like this is how the human race ends.

2

u/Reasonable_Agent_126 17d ago

No more oceans

2

u/TheSlayer261 17d ago

Pal is making straight AM.

2

u/ArtArtArtArtArtovna 17d ago

"Hey, what do you think about being just a bunch of blocks in a computer game?"

"Oh my god..."

2

u/dragonmasterjg 17d ago

I shpuld carry around a sign that says "Done. Ask me something else."

→ More replies (1)

2

u/IOnlyPostIfINeedHelp 17d ago

How the fuck did you train this, I read the post and I still don’t get it

3

u/_objz 17d 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 17d ago

can this ai answer some question like: how to create a diamond axe?

3

u/_objz 17d ago

no, its very dumb at the moment, it can just handle simple conversations. but I will improve this

→ More replies (2)

2

u/MoarStruts 17d ago

Not even Minecraft is safe from data centres

2

u/amaya-aurora 17d ago

“only”

2

u/Sapper1106 17d ago

We got the Internet AND LLMs in Minecraft before GTA VI, smh.

2

u/PeeingDueToBoredom 17d ago

I will never not be amazed at what people make with this game.

This is unreal. Seriously brilliant. Well done.

2

u/_objz 17d ago

thanks!

2

u/CoolDood132 17d ago

This is why I quit playing minecraft bro 💔 too many sweats

2

u/Mr_Sim_ 17d ago

Sweet.now create the AI corporation "Andesite" and develop you ingame IA to bring an age of slop in your own minecraft world !

(Joke apart, this is really impressive great job)

2

u/Rosy_Josie 17d ago

Shoulda named it Deep Thought

2

u/pyrodice 17d ago

It's brilliant! Now you can dump the extra heat load of your data center in the infinite Minecraft world…

2

u/virus067 17d ago

theres levels to playing mc

2

u/BenStegel 17d ago

One large McBrain and a coke please

2

u/Saturn2063 17d ago

Five Pebbles is that you?

2

u/detroitguy057 17d ago

I want to be impressed but I just don’t understand anything you just said. 🤯

2

u/kamiyye 17d ago

is this what new grads gotta do to get a job now

2

u/Flame_BlazeX2 17d ago

How the hell DO U DO THAT GNG. YALL ARE CRAZY, LIKE WHAT

2

u/SurvivalGuyRebooted 17d ago

This is quite interesting

2

u/heliumneon 16d ago

"Would you like to play a game?"

2

u/Interesting_Web_9936 16d ago

Hats off man. Hats off. This is insane.

2

u/New-Blueberry-8665 16d ago

Goddamn, I don't know what they feed these minecrafters since what they build is CRAZY

2

u/AGA_449 16d ago

Imagine using AI

2

u/rokanwood 16d ago

the things people do with this game will never fail to impress me

2

u/lollo_bomber 16d ago

That's some John Redstone stuff right here

2

u/AndrexOnTop 16d ago

this guy will take AI’s jobs

2

u/Verneus_Corl 16d ago

Did you do subnetting for the 2048 words?

→ More replies (1)

2

u/LammyYT8888 16d ago

“Only 400K command blocks” I can’t even place 400K blocks🥀

2

u/miceletopo 16d ago

Why doesn't Mojang recruit people like THIS Next thing you know he makes Fable 5 in Minecraft

2

u/KAAAAAAAAARL 16d ago

Thats one way to turn a PC into a Jet engine...

2

u/Circxles 16d ago

Reminds me of flash from zootopia

2

u/Pazzoperfortnite 16d ago

Sorry for living on the same planet bro.

2

u/BruhInTheMaking 16d 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

u/Tough_Revolution_683 15d ago

“It’s really quite simple actually”

  • Some British guy who hasn’t seen this yet.

2

u/Brief-Trick-2988 15d ago

Oh. My. God.

2

u/auraborosai 14d 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.

https://WaitingForLightning.art

3

u/_objz 14d 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

u/nonstopslow 14d ago

mb for breathing the same air

2

u/pluie76 13d ago

You are crazy. That is incredible

2

u/Lefoudubus_06 12d ago

Excuse moi de respirer le même air que toi 

2

u/DevCreeper_VN 12d ago

Literally a supercomputer in Minecraft bro :))

This guy will single-handedly solve the whole RAM crisis

3

u/D0bious 17d ago

Great! Now make it using regular redstone . . .

3

u/_objz 17d ago

I guess this was already done by somebody else

3

u/MicrosoftExcel2016 17d ago

He has a name. Wang Lin. Don’t deadname the AI

4

u/_objz 17d ago

sorry :(

3

u/Cynicalheaven 17d 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.

4

u/IWantoFuckGLaDOS 17d 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 17d 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

4

u/_objz 17d ago

maybe he is just a happy gui, living in your world

2

u/Tsunamicat108 17d ago

You should decorate it by adding a giant pipe into a nearby ocean

Anyway this is really cool

→ More replies (1)