Hermione Docs

The assistant

Train your own model

Everything used to train Hermione AI is in the repository's ml/ folder: the data generator, the training script, the evaluation, the export, and a one-command script for a rented GPU. You can retrain it, try another base model, or teach it your own way of working.

flowchart TB
  A[tools.ts] -->|pnpm ai:schema| B[ml/tools.json]
  B --> C[generate_dataset.py<br/>30,000 conversations]
  C --> D[train.py<br/>QLoRA on Qwen3.5-2B]
  D --> E[export_gguf.sh<br/>merge, Q4_K_M]
  E --> F[eval.py<br/>500 held-out, 85% gate]
  F -->|passes| G[Signed models.json<br/>+ Hugging Face]
  G --> H[Hermione downloads,<br/>verifies, runs]

#1. The data

pnpm ai:schema                                  # copy the app's tools and prompt into ml/tools.json
cd ml
python3 generate_dataset.py --count 30000       # data/train.jsonl, val.jsonl, test.jsonl
python3 generate_dataset.py --count 30000 --web --out data-web   # for the + Web model

generate_dataset.py needs no packages and no network, and is deterministic with --seed. Each example is a made-up project (people, a workflow, sprints, 8 to 30 issues), a request written the way people type, and the exact tool calls that carry it out. It covers 26 kinds of request: creating, moving, assigning, follow-ups ("and make it urgent"), corrections ("oops, I meant in progress"), several requests in one sentence, vague requests that should get a question back, and plain chat that needs no tool at all. The last two matter: small models fine-tuned on tools tend to forget when not to call one.

The format is OpenAI-style chat JSONL with tools, which Hugging Face chat templates for Qwen, Llama and others accept directly.

#2. Train it

#On a MacBook (free, overnight)

cd ml
python3.12 -m venv .venv && source .venv/bin/activate
pip install -r requirements-mac.txt
python3 train_mlx.py --preset air16             # 16 GB Mac: Qwen3 4B; air8 for 8 GB: Qwen3.5 2B

Uses Apple's MLX. Close other apps on an 8 GB Mac. The full guide, with presets and timings: training on a Mac.

#On a rented GPU (fast, a few dollars)

On a RunPod pod with PyTorch and CUDA 12:

git clone https://github.com/ansarbuilds/Hermione && cd Hermione
QUICK=1 ml/runpod.sh            # a few minutes: checks the pod works
ml/runpod.sh                    # the real run

runpod.sh generates the data, trains each model, exports it, scores it against the untrained base and the pass mark, and writes ml/out/models.src.json. Set HF_REPO and HF_TOKEN to upload what passes. Hermione's own run cost $17.35 of GPU time across three pods. The step-by-step guide with budget and fixes: ml/POD.md.

#The settings Hermione AI used

Base unsloth/Qwen3.5-2B (Apache-2.0)
Method QLoRA (4-bit base, LoRA adapter) with Unsloth and TRL
LoRA rank 32, alpha 32
Learning rate 2e-4, cosine schedule
Batch 8
Epochs 1
Context 4,096 tokens
Examples 30,000 per model

Use only Apache-2.0 or similarly open bases if you plan to share or sell the result. Qwen2.5-3B, for example, is research-only.

#3. Evaluate it

llama-server -m hermione-2b-Q4_K_M.gguf --jinja --port 8080 &
python3 eval.py --base-url http://127.0.0.1:8080 --model hermione \
  --data data/test.jsonl --report runs/trained.json --min-exact 0.85 --compare runs/base.json

eval.py reports exact match (the right calls with the right arguments), tool match (the right tools, any arguments), and accuracy per kind of request, then lists the misses. It exits with an error below --min-exact, so a script can't publish a model that fails.

#4. Export and use it

./export_gguf.sh runs/q35-2b/merged hermione-2b     # merge, convert, quantise to Q4_K_M

Then in Hermione, Settings → Assistant → Your model, run the file with llama-server (as above) or load it in Ollama or LM Studio, and connect.

#5. Teach it your habits

Turn on Keep examples to improve the model in Settings → Assistant. The requests the assistant handled and you kept are saved, on your Mac, in the same format as the generated data. Download them from Recent actions as hermione-training.jsonl and add them to the training set.

Edit this page on GitHub