MonkeyGrab Qwen3-0.6B RAG
A 0.6B answer model for retrieval-augmented question answering over PDFs. It is
Qwen3-0.6B fine-tuned and
distilled from qwen3:4b-instruct-2507 on the exact prompts of
MonkeyGrab, a local RAG
app for PDFs (hybrid BM25 plus embedding retrieval, Ollama generation).
It is the default answer model of MonkeyGrab's rag-lite build, meant for
GPUs with 4 GB of VRAM, where it serves every role (answers, chat, query
decomposition) next to the BGE reranker: 126 of 136 answered and 143 of 156
overall on that profile's gate (8k context), at 1058 MiB for the model and
2676 MiB with the reranker, against 3354 MiB for the 4B alone. The 8 GB build keeps
the 4B teacher, which fits there and answers eight more evaluation cases.
GGUF for Ollama and llama.cpp: nadiva1243/MonkeyGrab-Qwen3-0.6B-RAG-GGUF.
This repository holds the merged bf16 weights (the LoRA was merged at the end of
training; the adapter was not kept on its own) and the training logs.
Training code and the full experiment log: training/.
Use
With Ollama, take the GGUF repository:
ollama pull hf.co/nadiva1243/MonkeyGrab-Qwen3-0.6B-RAG-GGUF:Q4_K_M
With transformers:
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "nadiva1243/MonkeyGrab-Qwen3-0.6B-RAG"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="auto", device_map="auto")
messages = [
{"role": "system", "content": "<MonkeyGrab's SYSTEM_PROMPT_RAG>"},
{"role": "user", "content": "<context>...</context>\n\nQuestion: ..."},
]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=False, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=512, temperature=0.6, top_p=0.95, top_k=20, do_sample=True)
print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))
The prompt it was trained on is SYSTEM_PROMPT_RAG and the user message built
by Answer.build_user_message in MonkeyGrab; it performs best with exactly
that format.
Logs
logs/live.jsonl: one line per optimizer step (loss, grad norm, lr, tokens per second, VRAM) and every eval loss, plus the run's configuration and its probe questions.logs/phases.json: wall time of training, export and dev evaluation.logs/EXPERIMENTS.md: every run of the project (nine trained variants), its data, timings, dev and gate scores, and the 24 findings that led here.
Evaluation
MonkeyGrab's evaluation gate (tests/eval/run_eval.py): 136 hand-verified
questions with a checked expected answer each, over 17 papers and Wikipedia
articles per language in English, Spanish and Catalan. 124 cases are factual
(a number, a name, a date read from the document) and 12 are study modes
(summary, outline, quiz), graded on structure and sources. Every model in a
row was compared in the same run, with the same retrieval.
| Model | Answered /136 | Study /12 | Median s/case | VRAM in Ollama |
|---|---|---|---|---|
qwen3:0.6b, stock | 104 to 105 | 10 | 6.5 | |
| this model, Q4_K_M | 126 to 127 (six runs) | 12 | 6.2 | 1.52 GB |
qwen3:4b-instruct-2507, teacher | 135 | 12 | 9.6 | 3.90 GB |
RTX 4060 Laptop (8 GB), Ollama 0.40, 16k context (the gate's rag_num_ctx), KV cache q8_0. VRAM is the
peak size_vram Ollama reported while answering.
None of the gate documents was used for training.
Training
- Data: 3364 rows over 65 documents (arXiv papers and Wikipedia articles,
English, Spanish and Catalan), disjoint from the gate corpus:
- extractive questions written by the teacher over indexed chunks, answered by the teacher through MonkeyGrab's own retrieval and prompt, and kept only when the gate's grader passed the answer;
- those answers judged by Claude Haiku against a rubric, the fixable ones rewritten by Claude Sonnet, both audited on a sample by Claude Opus;
- question and answer pairs aimed at tables and numbers, written by Claude Sonnet and verified one by one by Claude Haiku;
- the teacher's study artifacts (summary, outline, quiz) for every document and language, so the short-answer data does not erase them.
- Method: LoRA r32 (alpha 64) on every attention and MLP projection,
loss on answer tokens only, sequences up to 14336 tokens, 2 epochs, lr 2e-4
cosine, effective batch 8, bf16. Logit distillation on top: the teacher's
top-32 log-probabilities at every answer position, loss
0.5 * CE + 0.5 * KL(teacher || student). 4 h 37 min on one RTX 4060 Laptop, 5.9 GB peak. - Export: LoRA merged, converted with llama.cpp b11669, quantized.
What was tried and did not beat it, each measured on the same gate: DPO on graded on-policy samples (tie), a heavier teacher weight of 0.8 (10 cases lost), a third epoch (one case behind), Q5_K_M and Q8_0 weights (within one case). The training data is not published: its contexts are verbatim passages of arXiv papers, several of which do not allow redistribution. The scripts rebuild it from the sources.
Limitations
- Trained and measured on MonkeyGrab's system prompt and context format. On other RAG prompts it is a Qwen3-0.6B with a bias toward short extractive answers, nothing more.
- It was trained on reranked evidence. With an 8k context and no reranker it drops to 115 of 136 on MonkeyGrab's gate; keep a reranker in front of it.
- Its remaining errors are mostly a wrong number read from a table.
- With an empty context it invents an answer instead of declining, as does the stock model.
- A q4_0 KV cache breaks it on long contexts (57/136 on the gate): the answers degenerate and run on. Use q8_0 or f16.
License
Apache-2.0, like Qwen3-0.6B and the teacher.