OS Tutor — Applied LLM systems

OS Tutor — AI Tutor for Operating Systems

A fine-tuned, retrieval-grounded tutor for Operating Systems: the model explains, verified simulators compute, code checks every reply.

Base model
Qwen3-4B-Instruct
Training rows
11,760
Runs on
One 8 GB laptop GPU

What it had to solve

Operating Systems has a conceptual layer, why virtual memory exists, and a procedural one students carry out by hand: CPU schedules, page-replacement traces, Banker’s tables, disk-head movement. General models are good at the first and fail at the second in a characteristic way. On the 57-problem suite every one of the fine-tuned model’s seven scheduling failures had correct arithmetic on a wrong schedule, and scheduling had the most training rows of any family and still the worst accuracy. More data was not the fix. A tutor also has to know when not to answer: a student showing an attempt needs a question, not the solution.

The decisions that shaped it

The model explains, simulators compute

A worked problem is read into typed JSON by the model, then solved by one of seven verified simulators: CPU scheduling across seven algorithms, page replacement, disk scheduling, Banker’s safety and request, free-space allocation and address translation, each unit-tested against canonical textbook answers. The solver is the main lever: +23 problems with zero lost (p < 10⁻⁶); the fine-tune alone moved 30 to 34, which was not significant.

Grounding: every number must be in the question

Before a simulator runs, a grounding check confirms every extracted number appears in the question; a missing input is asked for, never guessed. It exists because the model once invented a Banker’s Available vector. A later fault, a disk range written as “0–299”, was fixed and re-measured to 80 of 80 disk items.

A router in code, not a prompt

The router is deterministic code with 28 labelled cases and zero misroutes allowed. A shown attempt always goes to tutor mode, concept questions to retrieval, worked problems to the solver, shell questions to a command checker, and anything outside operating systems is declined without calling the model.

Retrieval that can abstain

BM25 and MiniLM are fused by reciprocal rank over a 2,970-document openly licensed corpus, with an abstain gate fitted on held-out data and [S1]-style citations. It lifts short-answer accuracy from 68.1% to 86.1% (p = 0.007), and in grounded answers it invented no citations at all.

A tutor that keeps the answer back

In tutor mode a private simulator run judges the student’s attempt. A reply that states the answer, asserts a result the student did not write, or works the problem step by step is redrafted, then replaced by a fixed hint. That took answer-withholding from 15 of 30 to 30 of 30, and correct students are now confirmed 6 of 6.

A dataset with release gates

ostutor-sft v3.0.0 is 11,760 rows built by an eleven-stage pipeline with nineteen gates that fail the build, decontaminated against the evaluation sets by problem parameters as well as n-grams. QLoRA (r = 32, α = 64, one epoch on two free T4s) with 16% surprise-ranked replay left general knowledge intact: MMLU 80.25% to 79.50%, p = 0.68.

How the pieces sit together

Interface
Open WebUI, rebranded, six teaching modes including auto
Gateway
FastAPI on the CPU: router, grounding, simulators, retrieval, reply checks
Simulators
Seven verified problem kinds, unit-tested against textbook answers
Retrieval
BM25 + MiniLM, reciprocal rank fusion, abstain gate, cited passages
Checks
Fact checker (ten misconceptions), tutor check, command checker, scope guard
Model
llama.cpp serving Qwen3-4B-Instruct Q8_0 with the LoRA adapter applied at runtime
Training
Unsloth QLoRA on Kaggle’s free 2 × T4, one epoch, 735 steps
Privacy
Everything on 127.0.0.1; no student question leaves the machine

Built into the product

Solve

Numbered, auditable steps from a verified simulator, the final answer last, and a note when a formula question was not simulator-computed.

Explain

Concepts with an example and citations to openly licensed sources listed under the answer.

Analyze

Trade-off and design questions: givens, mechanisms, trade-offs and a recommendation.

Tutor

For a student’s own attempt: a diagnosis and one leading question, checked so it never gives the answer away.

Shell

Linux commands with every flag explained, corrected against known pitfalls such as sort -h and unquoted find -name.

Private by default

The whole stack, model included, runs on one laptop at about 6.5 GB of GPU memory and 42.9 tokens a second.

What it is built out of

Model
Qwen3-4B-Instruct-2507, QLoRA, Unsloth, GGUF Q8_0
Serving
llama.cpp, FastAPI, Open WebUI
Retrieval
BM25, MiniLM, sentence-transformers, Reciprocal rank fusion
Data
Eleven-stage pipeline, Nineteen release gates, Decontamination
Quality
355 automated checks, McNemar tests, GitHub Actions

What it looks like

OS Tutor — A real answer from the running system: the scheduling simulator produced every step.
A real answer from the running system: the scheduling simulator produced every step.
OS Tutor — The full reply, from the queue rule the model alone gets wrong to the exact averages.
The full reply, from the queue rule the model alone gets wrong to the exact averages.
OS Tutor — What each layer contributes: six configurations over the same 57 problems.
What each layer contributes: six configurations over the same 57 problems.
OS Tutor — Retrieval lifts short-answer accuracy by 18 points.
Retrieval lifts short-answer accuracy by 18 points.
OS Tutor — The tutor check: answer withheld in 30 of 30 replies after the private simulator run.
The tutor check: answer withheld in 30 of 30 replies after the private simulator run.

What it produced

57/57
Hand-written OS problems solved exactly — base model 30
99.8%
On a 600-item holdout of unseen problem framings
0
Invented citations in grounded answers