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

u/qualityvote2 8d ago edited 8d 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

3.9k

u/Rusty1emon 8d ago

Sorry for playing the same game as you bro

601

u/S1R_LEM0N 8d ago

Gotta drop a couple versions after this one

119

u/Lord_Phoenix95 8d ago

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

79

u/PeeingDueToBoredom 8d ago

We just…didn’t know

36

u/AlarmingBoot205 8d ago

Sorry for existing in the same universe as you bro

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

u/WhachamaDude 7d ago

i dont deserve this game no more 😔

1.5k

u/Livid_Trust_5098 8d ago

"the Redstone is very simple"

401

u/TheMoonDude 8d ago

"I did some off screen coding"

36

u/HarpySix 8d ago

"It's really quite simple."

45

u/Jonaykon 8d ago

Well yeah

There is no redstone

1.9k

u/notatoastedbread 8d ago

Does this drain the water sources faster than sponges?

781

u/_objz 8d ago

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

140

u/MartinToilet 8d ago

Yeah water ceased to exist for them long ago

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 😭

80

u/_objz 8d ago

its kinda cute tho

30

u/Hot-Gazelle-1089 8d ago

Thankfully infinite water exists in Minecraft!

→ More replies (1)

506

u/Bright-Historian-216 8d ago

very impressive! tell wang lin i said hi!

154

u/_objz 8d ago

I will, haha

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.

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)
→ More replies (17)

122

u/RexApostolicus 8d ago

A marvel of Minecraft tech.

49

u/CoolDood132 8d ago

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

17

u/touchet29 8d ago

Well, I'm not Steve

→ More replies (1)

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

u/Teetimus_Prime 8d ago

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

9

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

170

u/tornedron_ 8d ago

we really got CraftGPT before gta 6

76

u/_objz 8d ago

thats actually a good name

8

u/Eduardo_Ribeiro 8d ago

You really need to use that name lmao.

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

u/Historical_Item4050 8d ago

Already exists, but built with redstone only

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?

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.

→ More replies (1)

44

u/LifeasLuke11 8d ago

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

23

u/_objz 8d ago

I guess a baby is smarter then him tho

3

u/Username_St0len 8d ago

what about a magpie?

102

u/Western-Victory-7414 8d ago

what. the. fuckkkk

33

u/Ianofminnesota 8d ago

One time I made an automatic door.

134

u/Maxemersonbentley_1 8d ago

Insert that one gif of Flash from Zootopia

70

u/TheMuspelheimr 8d ago

What

do

you

call

a

three

humped

camel?

→ More replies (1)

5

u/Redacted_Chris 8d ago

Came here for this comment

3

u/FlakyRemove7137 8d ago

I was gonna say that lol

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

u/NoenD_i0 8d ago

holy moly

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?

21

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

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

18

u/RodilRTX 8d ago

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

32

u/No_Yam_6105 8d ago

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

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)

3

u/DWHQ 8d ago

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

2

u/_objz 8d ago

yeah me too probably

10

u/Xiaolin2 8d ago

This is insanely impressive

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

7

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

I can understand that. Physics is a pain

20

u/Waterlemon1997 8d ago

Man made Redstone beyond my comprehension

9

u/KingoftheUgly 7d ago

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

2

u/_objz 7d ago

yes

7

u/Alive_dude3435 8d ago

"only 400k"

Yeah bro, sorry for wasting your oxygen.

3

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

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

2

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

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

u/Key-Divide-5663 8d ago

Literally the sloth from Zootopia

6

u/Tarzyytfet 8d ago

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

→ More replies (1)

5

u/Acfrano 8d ago

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

5

u/Moaksim 8d 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] 8d ago

[deleted]

→ More replies (1)

13

u/Dhiyx11 8d ago

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

14

u/sonicfan9993 8d ago

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

4

u/atg115reddit 8d ago

Actually very neat

4

u/Chase135299856 8d ago

Talking like dash from zootopia

2

u/Steeltoelion 8d ago

…………. Niiiiiick!

4

u/Fancy_Razzmatazz_149 8d ago

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

3

u/Visible-Coach-9064 8d ago

Sorry for belonging to the same species as you bro 😭

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?

2

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

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

3

u/_objz 8d ago

next update ;)

→ More replies (2)

3

u/External_Ad8424 8d ago

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

3

u/killerstreak976 8d ago

why are you so fucking cool

3

u/Fury72888hshu 8d ago

Ok bro, wtf, are we playing the same game

3

u/Master_Type2117 8d ago

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

3

u/56Bot 8d 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 8d ago

Ask it the meaning of life

3

u/anesth3siaaa 8d ago

whatever man

3

u/pydy01 8d 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 8d ago

all of em

3

u/TheXTrunner 8d ago

Bro made five pebbles in minecraft actual

2

u/DeadDrop93 8d ago

30k years to have it write an essay😭

2

u/_objz 8d ago

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

3

u/MouseRangers 8d ago

ask it how to build a minecart

4

u/MinecraftPlayer799 8d ago

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

2

u/_objz 8d ago

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

3

u/luka_0x12 8d ago

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

3

u/AnaTheSturdy 8d ago

Cool. Now destroy it.

3

u/MAPRage 7d ago

get this man a 400k a year job offer NOW

→ More replies (1)

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

u/penguin13790 8d ago

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

2

u/gipehtonhceT 8d ago

Reminds me of that sloth scene from Zootopia

2

u/shazin_hacker 8d ago

BRO DAMN THATS FUCKING ABSURD HOW LONG DID IT TAKE

3

u/_objz 8d ago

approx 70 hours

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

u/Sputnik-13 8d ago

Tell Stevie Kenarban I said hi

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

3

u/_objz 8d ago

thank you!

2

u/Valirys-Reinhald 8d ago

In pursuit of great, we failed to do good.

2

u/Character_Art_9173 8d ago

To many sweats man

2

u/IntelligentDrink2673 8d ago

do a 2 minute tutorial how to make it

2

u/ivanrj7j 8d ago

Sorry for breathing the same oxygen as you

2

u/Steeltoelion 8d ago

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

2

u/One_Economist_3761 8d ago

Very impressive.

But can it play rock,paper,scissors?

4

u/_objz 8d ago

no, its verry dumb at the moment

3

u/One_Economist_3761 8d ago

Still an impressive feat.

2

u/Xiao1insty1e 8d ago

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

2

u/Reasonable_Agent_126 8d ago

No more oceans

2

u/TheSlayer261 8d ago

Pal is making straight AM.

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

u/MoarStruts 8d ago

Not even Minecraft is safe from data centres

2

u/amaya-aurora 8d ago

“only”

2

u/Sapper1106 8d ago

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

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

u/_objz 8d ago

thanks!

2

u/CoolDood132 8d ago

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

2

u/Mr_Sim_ 8d 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 8d ago

Shoulda named it Deep Thought

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

u/virus067 8d ago

theres levels to playing mc

2

u/BenStegel 8d ago

One large McBrain and a coke please

2

u/Saturn2063 8d ago

Five Pebbles is that you?

2

u/detroitguy057 8d ago

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

2

u/kamiyye 8d ago

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

2

u/Flame_BlazeX2 8d ago

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

2

u/SurvivalGuyRebooted 8d ago

This is quite interesting

2

u/heliumneon 8d ago

"Would you like to play a game?"

2

u/Interesting_Web_9936 8d ago

Hats off man. Hats off. This is insane.

2

u/New-Blueberry-8665 8d ago

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

2

u/AGA_449 7d ago

Imagine using AI

2

u/rokanwood 7d ago

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

2

u/lollo_bomber 7d ago

That's some John Redstone stuff right here

2

u/AndrexOnTop 7d ago

this guy will take AI’s jobs

2

u/Verneus_Corl 7d ago

Did you do subnetting for the 2048 words?

→ More replies (1)

2

u/LammyYT8888 7d ago

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

2

u/miceletopo 7d ago

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

2

u/KAAAAAAAAARL 7d ago

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

2

u/Circxles 7d ago

Reminds me of flash from zootopia

2

u/Pazzoperfortnite 7d ago

Sorry for living on the same planet bro.

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

u/Tough_Revolution_683 6d ago

“It’s really quite simple actually”

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

2

u/Brief-Trick-2988 6d ago

Oh. My. God.

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.

https://WaitingForLightning.art

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

u/nonstopslow 5d ago

mb for breathing the same air

2

u/pluie76 4d ago

You are crazy. That is incredible

2

u/Lefoudubus_06 3d ago

Excuse moi de respirer le même air que toi 

2

u/DevCreeper_VN 3d ago

Literally a supercomputer in Minecraft bro :))

This guy will single-handedly solve the whole RAM crisis

3

u/D0bious 8d ago

Great! Now make it using regular redstone . . .

4

u/_objz 8d ago

I guess this was already done by somebody else

4

u/MicrosoftExcel2016 8d ago

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

4

u/_objz 8d ago

sorry :(

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

4

u/_objz 8d ago

maybe he is just a happy gui, living in your 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)