This chapter was not re-run from scratch on a blank PC: it is written from what I installed, ran and measured on mine, and only the steps that showed real output are here.
The robot's own computer is good at driving, mapping and quick vision, but it is too small to think with a language model. I tried running a 4-billion-parameter model on the robot once. It used so much memory that the kernel started killing the robot's own programs. So the PC does the thinking. A short "thought" from a 12-billion-parameter model on the PC took 1.37 seconds; the same kind of request on the robot took 5 to 6 seconds. The robot never needs the PC to drive or to stop safely. It needs the PC to think.
The first half of this chapter sets up the PC so that any program on your network, including the robot, can send a question to a model and get an answer. The second half is about training your own models on that PC, what worked, and what didn't.
You need a recent NVIDIA graphics card with 16 GB of video memory. Mine is an RTX 5070 Ti with 32 GB of ordinary memory beside it, running Fedora 44 with the KDE desktop.
The video memory is what matters. A language model is a long list of numbers, its weights, and producing one word means multiplying your text through billions of them. A graphics card does thousands of those multiplications at once and reads its own memory far faster than the processor reads ordinary memory. The rule of thumb: the model has to fit in video memory to be fast. With the model from this chapter loaded, nvidia-smi showed it using 9,456 MiB of my 16,303 MiB. One 7B model fitted beside it on my card; two did not.
Fedora ships only free software, so the NVIDIA driver comes from RPM Fusion, a separate package repository. These sudo lines ask for your password; type them yourself. I have only done this on Fedora.
sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-44.noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-44.noarch.rpm
Check it with rpm -q rpmfusion-free-release rpmfusion-nonfree-release. It should print:
rpmfusion-free-release-44-3.noarch
rpmfusion-nonfree-release-44-3.noarch
Then install the driver:
sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda
akmod-nvidia doesn't contain a ready driver. It contains the driver's source and a service that builds the driver for whatever kernel you run, and it repeats that build after every kernel update. The build has to finish before the reboot that loads it; rpm -qa 'kmod-nvidia*' lists a package for your kernel once it has. xorg-x11-drv-nvidia-cuda adds nvidia-smi and the CUDA library that LM Studio and the training scripts use.
My PC has Secure Boot off (mokutil --sb-state prints SecureBoot disabled). With Secure Boot on, the kernel won't trust a driver you built yourself. I never tried that path.
Reboot, then ask the card who it is:
nvidia-smi --query-gpu=name,driver_version,memory.used,memory.total --format=csv,noheader
On my PC, with the model and a speech-recognition program on the card, it printed:
NVIDIA GeForce RTX 5070 Ti, 615.71.09, 12279 MiB, 16303 MiB
On a fresh install the memory used is a few hundred MiB. If nvidia-smi fails after a reboot, use that rpm -qa 'kmod-nvidia*' line to see whether the build for your running kernel happened.
LM Studio's server will run as a user service, under your own user rather than as root. Normally systemd starts your user services when you log in and stops them when you log out. "Linger" tells it to start them at boot and keep them running with nobody logged in, which is what you want on a PC that serves the robot.
sudo loginctl enable-linger burgerbarn
On my PC linger is on: the file /var/lib/systemd/linger/burgerbarn exists. I have no record of turning it on, so the line above is the standard one rather than one I watched work.
A PC that has gone to sleep can't answer the robot. Mine suspended in the middle of a training job, because the desktop doesn't count an SSH session or pings as activity. Turn off automatic suspend on AC power. On KDE I did it by changing AutoSuspendAction=1 to AutoSuspendAction=0 in ~/.config/powerdevilrc. The power settings window should do the same, but I didn't use it. After a change, restart the power manager and check the value:
systemctl --user restart plasma-powerdevil.service
kreadconfig6 --file powerdevilrc --group AC --group SuspendAndShutdown --key AutoSuspendAction
It should print 0. The restart matters. I once asked the power manager to reread the file instead, it reported success, and the PC suspended anyway.
LM Studio is the program that loads a model onto the graphics card and answers questions over a small web API on port 1234. That API copies OpenAI's (POST /v1/chat/completions), so any program that can send JSON over HTTP can use it, and nothing leaves your network. I use its headless version: a background program called llmster and a command-line tool called lms, with no window.
The installer needs libatomic. The first line asks for your password:
sudo dnf install -y libatomic
curl -fsSL https://lmstudio.ai/install.sh | bash
Check that it landed:
ls -l ~/.lmstudio/bin/lms
ls ~/.lmstudio/llmster/
The second line shows one version folder. A fresh install I tested got 0.0.25-1; my own PC has 0.0.20-1, and the output in the rest of this chapter comes from that one. The installer also adds ~/.lmstudio/bin to your PATH for new shells, but this chapter uses the full path so it works either way.
Two things went wrong in that test install. On a minimal Fedora it stopped with ERROR: Missing required dependency: "libatomic" is not installed, which is why the first line is there. It also stopped with ERROR: Bootstrap binary not found at /tmp/tmp.XXXX/llmster on a machine whose /tmp doesn't allow running programs, which is the likely cause. Pointing the installer at a folder in your home got past that. Here it is as one line, a form I haven't run: mkdir -p ~/tmp && curl -fsSL https://lmstudio.ai/install.sh | TMPDIR=~/tmp bash.
The model I use for everyday thinking is google/gemma-4-12b, about 12 billion weights. Stored as ordinary 16-bit numbers that would be about 24 GB, too big for a 16 GB card. So you download a quantized file instead, which stores most weights in 4 bits with a shared scale for each small block. The file is called gemma-4-12B-it-Q4_K_M.gguf. Q4 means mostly 4-bit, and K_M is the medium mix that keeps some layers at higher precision. It works out at about 4.9 bits per weight. The answers are slightly less precise than the full model's, and it fits with room to spare. The second file, the vision projector, turns a camera picture into something the model can read. The robot needs it to talk about what it sees.
~/.lmstudio/bin/lms get google/gemma-4-12b -y
ls -l ~/.lmstudio/models/lmstudio-community/gemma-4-12B-it-GGUF/
It's about 7.6 GB. The -y accepts the download that LM Studio picks for your hardware. The sizes prove you got the right files:
gemma-4-12B-it-Q4_K_M.gguf 7381382944 bytes
mmproj-gemma-4-12B-it-BF16.gguf 175115296 bytes
My test install got exactly these. If yours differ, LM Studio picked another quantization. ~/.lmstudio/bin/lms ls should list the model:
google/gemma-4-12b (1 variant) 12B gemma4 7.56 GB Local
The context length is how much text the model can hold at once: your question, any instructions, and its answer. A fresh install defaults to 8192 tokens. I use 12192. Stop the background program first, then edit the setting:
~/.lmstudio/bin/lms daemon down
python3 - <<'EOF'
import json, pathlib
p = pathlib.Path.home() / ".lmstudio/settings.json"
s = json.loads(p.read_text())
s["defaultContextLength"] = {"type": "custom", "value": 12192}
p.write_text(json.dumps(s, indent=2) + "\n")
print(s["defaultContextLength"])
EOF
It prints {'type': 'custom', 'value': 12192}. The service in the next section starts the background program again. The same file already unloads a model after it has sat idle for an hour, and unloads the previous model when another one is asked for. Leave those as they are.
The server should come up on its own after every reboot, so make it a user service. Create the folder with mkdir -p ~/.config/systemd/user, then write ~/.config/systemd/user/lmstudio-server.service:
[Unit]
Description=LM Studio headless API server
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/burgerbarn/.lmstudio/bin/lms server start --port 1234 --bind 0.0.0.0 --cors
ExecStop=/home/burgerbarn/.lmstudio/bin/lms server stop
[Install]
WantedBy=default.target
lms server start tells the background program to open the API and returns at once. That's why the unit is a oneshot that systemd keeps marked active after the command has finished. --bind 0.0.0.0 makes it answer on your network and not only on the PC itself. No model is loaded here. The first request that names a model loads it.
Turn it on:
systemctl --user daemon-reload
systemctl --user enable --now lmstudio-server.service
systemctl --user is-active lmstudio-server.service
~/.lmstudio/bin/lms ps
On my PC it printed:
Created symlink '/home/burgerbarn/.config/systemd/user/default.target.wants/lmstudio-server.service' → '/home/burgerbarn/.config/systemd/user/lmstudio-server.service'.
active
No models are currently loaded.
~/.lmstudio/bin/lms server status should say The server is running on port 1234.
This model thinks before it answers unless you tell it not to, and the thinking counts against the answer's length limit. Try it both ways. The test prompt calls the robot Buddy. That is only a name; type the block as it is. The first request also loads the model, so if it's slow, run the block again.
q(){ curl -s localhost:1234/v1/chat/completions -H "Content-Type: application/json" -d "$1" | python3 -c "import json,sys; r=json.load(sys.stdin); m=r['choices'][0]['message']; print(repr(m.get('content'))[:200]); print('reasoning chars:',len(m.get('reasoning_content') or m.get('reasoning') or ''), r.get('usage',{}).get('completion_tokens_details'))"; }
B='"model":"google/gemma-4-12b","messages":[{"role":"system","content":"You are Buddy, a small home robot. Reply in one short sentence."},{"role":"user","content":"yo buddy, what can you do?"}]'
echo "== max_tokens 600"; time q "{$B,\"max_tokens\":600}"
echo "== reasoning_effort none"; time q "{$B,\"max_tokens\":200,\"reasoning_effort\":\"none\"}"
With the model already loaded, I got:
== max_tokens 600
'I can answer your questions and help make your day a little easier!'
reasoning chars: 1350 {'reasoning_tokens': 346}
real 0m4.513s
== reasoning_effort none
'I can help you with tasks, answer questions, and keep your home running smoothly!'
reasoning chars: 0 {'reasoning_tokens': 0}
real 0m0.313s
That's 0.3 seconds instead of 4.5. Everything the robot sends to this model uses "reasoning_effort": "none". My very first test sent a limit of 60 tokens without it, and the answer came back empty: all 60 tokens had gone on thinking.
Now lms ps shows the loaded model and its unload timer. The context reads 12288, not 12192. LM Studio appears to round it up.
IDENTIFIER MODEL STATUS SIZE CONTEXT PARALLEL DEVICE TTL
google/gemma-4-12b google/gemma-4-12b IDLE 7.56 GB 12288 4 Local 60m / 1h
Three other things went wrong. Connection refused on port 1234 meant the service wasn't enabled. A reply of No models loaded. Please load a model in the developer page or use the 'lms load' command. came when I sent a request within a second of starting the service; a few seconds later the same request loaded the model. And when several requests overlap, LM Studio sometimes answers with an HTTP 400 that says terminated. Any program you write against it has to treat that as "no answer this time", which is one more reason the robot's driving never waits for the PC.
Fedora's default firewall zone on a desktop install already lets your network reach ports 1025 to 65535. Check it, and check that the server listens on every interface:
firewall-cmd --get-default-zone
firewall-cmd --zone=FedoraWorkstation --list-ports
ss -ltn | grep :1234
You should see FedoraWorkstation, then 22/tcp 1025-65535/tcp 1025-65535/udp, then LISTEN 0 511 0.0.0.0:1234 0.0.0.0:*. If ss shows 127.0.0.1:1234 instead, the server was started without --bind 0.0.0.0. The PC can then talk to itself and the robot gets nothing.
Now ask from the robot. My PC is at PC_IP on my network; put your PC's address in its place. From your laptop:
ssh -o ConnectTimeout=8 rosorin 'curl -s -m 6 http://PC_IP:1234/v1/models | python3 -c "import json,sys; print([m[\"id\"] for m in json.load(sys.stdin).get(\"data\",[])])"'
It prints a list of the models you've downloaded. Mine had seven in it because I had tried several. Yours must include google/gemma-4-12b.
A model you download knows nothing about your robot. There are two ways to give it that knowledge, and on this project they did very different things.
The first is retrieval. Before the model answers, a search finds the pieces of your own notes and code that match the question and puts them in front of the model, and it answers from them. The second is fine-tuning: a short extra training run on your own examples, which changes the model's habits. In my tests, a general model reading excerpts from this guide answered about 9 questions in 10 correctly. A coding model fine-tuned on the project's code, with no excerpts, still invented file paths and partition names. Retrieval carried the facts. Fine-tuning only ever taught style and narrow decisions, and the coding results further down show it can do worse than that.
The other lesson is to decide on the score before you train. Keep part of your data out of training, the held-out set, and choose it so it really is new to the model, not random lines from the same files it trained on. Then score the untrained model, train, and score again on the held-out part. Twice a result looked good to me until I scored it properly.
Everything trains on the PC's graphics card with QLoRA. QLoRA loads the model in 4 bits and trains a set of small add-on matrices, an adapter, instead of the whole model. That's what lets a 7B or 8B model train on a 16 GB card.
All of it runs from one Python environment in ~/llm-train. I didn't keep the exact commands I first ran to build it, so the lines below haven't been run as written. They install the versions that are on my PC now, and I haven't checked that PyTorch's index still offers 2.11.0. The RTX 5070 Ti is a Blackwell card (CUDA compute capability 12.0), and PyTorch builds older than CUDA 12.8 don't run on it, which is why PyTorch comes from its cu128 index:
sudo dnf install -y python3.11 git cmake gcc-c++
python3.11 -m venv ~/llm-train
~/llm-train/bin/pip install torch==2.11.0 --index-url https://download.pytorch.org/whl/cu128
~/llm-train/bin/pip install transformers==5.19.0 peft==0.21.2 bitsandbytes==0.50.2 datasets==5.1.0 accelerate==1.15.0 trl==1.15.0 sentencepiece
git clone https://github.com/ggml-org/llama.cpp ~/llm-train/llama.cpp
cmake -S ~/llm-train/llama.cpp -B ~/llm-train/llama.cpp/build -DCMAKE_BUILD_TYPE=Release
cmake --build ~/llm-train/llama.cpp/build -j --target llama-quantize
~/llm-train/bin/pip install -e ~/llm-train/llama.cpp/gguf-py
The llama.cpp build is for the processor only. That is enough to convert and shrink a trained model; LM Studio does the serving. The training scripts are in the repository under brain/train/. Copy them to the PC from your laptop:
cd ~/CCode/rosorin-pro && ssh yourpc 'mkdir -p ~/llm-train/work' && scp brain/train/*.py yourpc:llm-train/work/ && scp brain/train/*.sh yourpc:llm-train/
Check that PyTorch can see the card:
~/llm-train/bin/python -c "import torch; print('cuda', torch.cuda.is_available(), torch.version.cuda, torch.cuda.get_device_capability(0))"
It should print cuda True 12.8 (12, 0).
Training needs nearly all of the card, so only one GPU job runs at a time, and LM Studio has to let go of its models first. Unloading them isn't enough while its server runs: anything that asks for a model makes LM Studio load it again. On my PC it was back within a second, and the training ran out of memory at its first step. That's why every training command below is wrapped in ~/llm-train/run_with_pause.sh. It unloads LM Studio's models and stops its server before the job, writes the job's output to the log you name with exit= and the exit code at the end, and starts the server again however the job ends. It also tries to stop a voice service from my own setup, which you won't have; that line does nothing on your PC.
If you write your own training scripts, three problems cost me time, and the scripts in brain/train/ already handle them. Calling prepare_model_for_kbit_training ran out of memory at load, because it copies parts of the model to 32-bit; turn on gradient checkpointing and enable_input_require_grads() instead. Testing the model straight after training gave garbage text until gradient checkpointing was turned off and use_cache back on. And with transformers 5, apply_chat_template returns a dictionary, so take its ["input_ids"].
The first thing I tried to teach was the project's own code, so a local model could write code in the project's style. It didn't work.
A lower training loss shows that the model expects your code better. It doesn't show that the code it writes works. So before trusting any coding model, I built a test that runs its code. brain/train/code_eval.py takes real functions from the robot's mind/ folder, removes each function's body (keeping its name and description), asks the model to write the function, puts the answer back into the file, and runs the repository's own unit tests on it. A task only counts if the original function passes those tests and an empty body fails them, so a pass means the model's code did the work. None of the models had seen this code, because it was written after their training.
It needs a plain git clone of the repository in ~/llm-train/repo, used only by the training scripts. I didn't record the clone command I ran. Then:
mkdir -p ~/code-eval && cd ~/code-eval && cp ~/llm-train/work/code_eval.py ~/llm-train/work/code_data.py .
git -C ~/llm-train/repo fetch -q origin rebuild && rm -rf snap && mkdir snap && git -C ~/llm-train/repo archive origin/rebuild mind brain/sim | tar -x -C snap
~/llm-train/bin/python code_eval.py tasks snap tasks.jsonl
~/llm-train/bin/python code_eval.py run snap tasks.jsonl rosorin-coder-v3 http://127.0.0.1:1234 res-rosorin-coder-v3.jsonl
~/llm-train/bin/python code_eval.py report res-*.jsonl
The tasks line ended with 55 tasks -> tasks.jsonl: 55 functions in 13 modules. Before trusting any score, I gave the test the original functions as answers, and 55 of 55 passed.
The run line takes the model's name as LM Studio knows it, the address of the LM Studio server holding it, and an output file. Put the name of a model you have loaded ("Merge, convert and serve a trained model" below shows how) in place of rosorin-coder-v3, in the output file name too, and run the line once for each model you want to compare. http://127.0.0.1:1234 is your PC's own LM Studio server. I served the models from LM Studio on my laptop through an SSH tunnel, so my run line had http://127.0.0.1:8085 there, and the line in this form hasn't been run. A model that thinks before answering needs room to do it: put MAX_TOKENS=8000 in front of the run line. A run that stops part way can be started again, and it skips the tasks already in its output file.
Without the plain base model the test can't tell you whether training helped, so download it too. It's Qwen's own 4-bit file, about 4.7 GB, into a folder LM Studio will find:
mkdir -p ~/.lmstudio/models/local/qwen2.5-coder-7b-base-GGUF && curl -fL -o ~/.lmstudio/models/local/qwen2.5-coder-7b-base-GGUF/qwen2.5-coder-7b-instruct-q4_k_m.gguf https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF/resolve/main/qwen2.5-coder-7b-instruct-q4_k_m.gguf
The file is 4,683,073,536 bytes. Run sha256sum on it; mine matched the sum Hugging Face lists:
509287f78cb4d4cf6b3843734733b914b2c158e43e22a7f4bf5e963800894d3c
The base model for every coder here is Qwen/Qwen2.5-Coder-7B-Instruct, which is already trained on public code and on following instructions. Training on your code is completion training: the files are cut into pieces of 2048 tokens and the model learns to continue each piece. Nothing is labelled; the code is its own answer. About one file in ten is held out, picked by a checksum of its path, so the same files are held out on every run. The loss on those files is the before and after number.
cd ~/llm-train/work && DATA=~/llm-train/data/code-v2 OUT=out-coder EPOCHS=2 ~/llm-train/run_with_pause.sh run.log ~/llm-train/bin/python code_qlora.py
DATA is the folder of files to train on and OUT is where the adapter goes. You won't have ~/llm-train/data/code-v2. Mine was a copy of the whole repository that a timer refreshed every hour for another tool, so it no longer holds what coder v2 trained on either. The code-only folder built further down is the one made for training, though no coder has been trained on it yet. The settings at the top of code_qlora.py are chosen to fit a 16 GB card. The model is stored in 4 bits and does its maths in bfloat16. The adapter has rank 16 and alpha 32, sits on every linear layer, and drops 5 percent of its inputs while training so it learns fewer files by heart; that is about 40 million trained numbers, half a percent of the model. It trains on one piece at a time and updates the weights once every 8 pieces. The learning rate is 1e-4, rising for 3 steps and then falling to zero. Every piece is seen twice. The optimizer keeps its state in 8 bits, and gradient checkpointing recomputes in-between results instead of storing them, which trades time for memory.
My second coder trained on 503 pieces in 23 minutes, at about 1,475 tokens a second, with a peak of 9.41 GiB on the card. When a job ends, the log's last line is exit= with its exit code, and out-coder/result.json holds base_loss and tuned_loss, the held-out loss before and after. For coder v2 it fell from 1.83 to 1.42. By that measure it worked.
Then I ran the code test on each model at temperature 0, each served from LM Studio at Q4_K_M (gpt-oss-20b in LM Studio's own format). gpt-oss-20b, a general model never trained on this code, passed 18 of the 55. The plain Qwen2.5-Coder-7B-Instruct base passed 9. Coder v2, trained on the project's code, passed 7. Coder v3, trained on more of it, passed 2.
Training on the project's code made the model worse at writing the project's code. Coder v3 mostly wrote the whole file back instead of the one function and got cut off; 48 of its 55 answers weren't usable code at all. Coder v2 passed two tasks the base failed and failed four the base passed.
When I looked at what the coders had trained on, the reason seemed clear, though it isn't proven. code_qlora.py reads every file in its folder as text, code or not. Of the 21.4 MB that coder v3 trained on, half was the guide's own build output, another fifth was guide chapters and notes, a tenth was pictures and other binary files read as text, and only 8.3 percent was code and configuration. That folder taught it mostly prose and noise. Its held-out loss still fell, from 2.01 to 1.02, partly because guide text it had seen under other file names was in the held-out files too. I haven't measured how much of the drop that explains. The falling loss didn't show that its code got better.
So brain/train/code_data.py now builds a folder of code only, from one commit. It keeps tracked files with a code extension and leaves out the guide, docs, maps, media, vendored libraries, files over 200 kB, binary files and files with lines over 1000 characters. --hold-out also leaves out every file the code test uses, so a model trained on the folder can still be tested fairly. Run the code test's first two commands first, because this one reads their tasks.jsonl:
git -C ~/llm-train/repo fetch -q origin rebuild
cd ~/code-eval && ~/llm-train/bin/python ~/llm-train/work/code_data.py ~/llm-train/repo origin/rebuild ~/llm-train/data/code-v4 --hold-out tasks.jsonl
It printed:
502 files, 3.13 MB from 92e10f3 -> /home/burgerbarn/llm-train/data/code-v4;
left out: {'not code': 516, 'docs, data, build output or vendored': 42, 'held out for code_eval': 25}
It also writes a manifest.json with the commit, the counts, and what it left out and why. No model has been trained on that folder yet. Until a coder beats both the plain base and a general model on this test, I write code with a general model reading excerpts of the project, not with a trained one.
The adapter only works on top of its base model. To serve a model, fold the adapter into a full copy, convert that to a single GGUF file and shrink it to 4 bits:
cd ~/llm-train/work && ~/llm-train/bin/python merge_adapter.py out-coder/adapter out-coder/merged
~/llm-train/bin/python ~/llm-train/llama.cpp/convert_hf_to_gguf.py out-coder/merged --outtype bf16 --outfile tmp.gguf && ~/llm-train/llama.cpp/build/bin/llama-quantize tmp.gguf my-model-Q4_K_M.gguf Q4_K_M
The merge runs on the processor in bfloat16, and the 7.6 billion weights alone take about 15 GB of ordinary memory. merge_adapter.py assumes the coder's base model; for another base, give it as a third argument, for example merge_adapter.py out-judge-qwen3-8b/adapter out-judge-qwen3-8b/merged Qwen/Qwen3-8B. My coder v2 came out at 4.68 GB in Q4_K_M.
Put the file in its own folder under ~/.lmstudio/models/local/, with a folder name ending in -GGUF. LM Studio lists it within seconds. Find its key and load it under a fixed name, with a context long enough for a whole file plus the answer:
~/.lmstudio/bin/lms ls --json | grep -o "\"modelKey\":\"[^\"]*coder[^\"]*\""; ~/.lmstudio/bin/lms load rosorin-coder-v3 --identifier rosorin-coder-v3 -c 16384 -y
The first command lists the keys of models with coder in their name. Put your model's key and the name you want in place of rosorin-coder-v3. The load ends with a line like To use the model in the API/SDK, use the identifier "rosorin-coder-7b-v2". lms unload rosorin-coder-v3 frees its 4.68 GB again.
The second thing I trained was a judge: a model that reads a command, its output and the check it was meant to prove, and answers PASS, DIFFERS, FAIL or UNSURE. My checks came from the checklists at the end of this guide's chapters, run on the robot. Each check is one line in ~/llm-train/data/judge/checks.jsonl (an id, the checklist item, the command, its output), and its correct verdict, with one sentence saying why, is a line in a labels*.jsonl file beside it, like {"id": "j0000", "gold": "FAIL", "why": "<one sentence quoting the output>"}. Most of my labels, and a set of made-up failures varied from real output, were written by a large hosted model reading the real recorded output. You can write labels by hand in the same shape; the training script doesn't need anything online.
cd ~/llm-train/work && ~/llm-train/run_with_pause.sh judge.log ~/llm-train/bin/python judge_train.py
It trains Qwen3-8B on the checks of the earlier chapters and tests it on the real checks of the later ones, so it is always judged on chapters it never saw. It prints the base model's score before training and the trained model's after.
The first round taught me to read the whole breakdown and not one number. It trained on 543 labelled checks in 14 minutes, with a peak of 9.95 GiB, and agreement went from 31 percent to 91 percent. That looked like a success. But it answered UNSURE to every one of the 14 real failures. A file-name pattern in the training script had left every failure example out of training, so the model had never seen one. If the first line of judge.log that starts with DATA shows (FAIL 0), the same thing has happened to you.
The second round trained on 1,864 checks, 553 of them failures, in about 45 minutes. On the held-out checks it agreed with the correct verdict on 322 of 401, 80.3 percent, against 31.2 percent for the untrained base model. For a judge, the number that matters most is false passes: a broken step called fine. Check that count before you trust any judge, and treat its PASS as a pointer, not proof.
The AI that runs the robot in the next two chapters, the mind, writes its own short programs. At each step it sets a goal, writes a small Python program against the robot's body and memory, and a sandbox runs it in a simulated room. mind-7b is the model that writes those programs. It is the same Qwen2.5-Coder-7B base, trained with QLoRA on programs the simulator checked: programs that ran and achieved something, such as putting a thing in its right place or learning its name. The programs it trains on came from a scripted teacher that plays the rooms with no model at all, from a stronger general model (gpt-oss-20b, chapter 14 says why), and from mind-7b's own runs. Each was kept only after its check in the simulator passed. On the real robot, chapter 13 uses gpt-oss-20b to write the programs, not mind-7b. I ran it in LM Studio on my laptop, and this chapter doesn't show its download.
The mind gets better in rounds, which I call sleep rounds. The script is mind/consolidate.sh. It collects every verified example from the folders of examples, never ones from the test rooms, never unverified ones and never duplicates. Then it stops LM Studio's server and unloads its models, refuses to start if the card or the disk is too full, trains a new candidate, starts the server again and builds the candidate's GGUF file.
A candidate is not the new model yet. Training on new data can make a model worse at what it already did, and a lower training loss doesn't show that. So two tests decide. In the held-out test, the mind runs in simulated test rooms it never trained in, once with the candidate and once with the current model. In the task check, each model gets 8 short tasks and the programs it writes are scored without being run, by whether they call the right tools. The candidate replaces the current model only if the things it found plus the things it named are not fewer, it causes no more contacts, has no failed runs, and passes no fewer tasks. The newest version of the script adds a third check, 40 made-up reports on the robot's health with planted faults, and the candidate must pass no fewer of those either. That check came after the model I serve now was chosen. A ledger keeps every round's numbers and its decision, and the previous model stays on disk; consolidate.sh --rollback serves it again.
Each round's training step prints a line like this one, from a round of 503 examples:
TRAIN loss=0.3822 time=16.5min peak_vram=12.12GiB
While it trains, LM Studio's server is stopped and nothing on your network gets an answer from the PC. Each round also keeps a 4.7 GB file in its own folder, and nothing deletes old ones.
The model I serve now, out-mind-7b-20261024, trained on 4,313 examples. In the simulator's held-out test it found 178 of 344 objects; the model before it found 175. In the task check it passed 4 of 8 tasks; the model before it passed none.
Beside it is a small self-judge. In the real room there is no simulator to say whether an answer was right, so the self-judge learns to tell right answers from wrong ones using only what the robot itself knows: how sure it was, how often it saw the thing, from how many views, whether it looked closely. It is a simple logistic regression in mind/self_judge.py, not a language model, so it runs anywhere. In its current file it is right on 85.9 percent of 2,056 recorded answers, with an AUC of 0.872. It gives a probability; it never decides alone.
All of this training and testing happened in simulation. None of it has been shown to carry over to the real robot.
Of the last 8 sleep rounds, 6 failed in training and never got as far as the test. Rounds started by a timer crashed at the first training step with a cuDNN Invalid handle error, while the same command typed in a shell trained. The cause found was a remote-desktop program that had put its own graphics library into LD_PRELOAD for my user services. The scripts now remove that variable, but that hasn't been shown to fix the crashes.
You can't start the mind's training from nothing with this chapter. consolidate.sh expects a current mind-7b in its ledger with its model file on disk, and refuses to run without one, and the examples it trains on come from the simulator in chapter 14. How the first mind-7b was made isn't written up here with output you could check against.
No coder has been trained on the code-only folder, so whether clean data fixes the coding results is still unknown. The judge's second round was measured on held-out checks, but it hasn't been put to work checking a real robot.
I also tried a small script that holds a "don't sleep" lock while the graphics card is busy, so that a suspend can't cut off an answer. The lock was refused every time with systemd-inhibit: Failed to inhibit: Access denied, even though the service reported itself active. Turning off automatic suspend is what keeps my PC awake.
You're ready for the next chapter when nvidia-smi shows your card with the NVIDIA driver, /var/lib/systemd/linger/burgerbarn exists, systemctl --user is-active lmstudio-server.service prints active after a reboot, the reasoning_effort test answers in well under a second once the model is loaded, and the model list printed from the robot includes google/gemma-4-12b. The training half of this chapter is optional for now. If you did set it up, PyTorch should print cuda True with your card, and any model you train should beat its own base model on a held-out test before you put it to use.