LoRA adapter for
Qwen/Qwen3.5-4B, fine-tuned as the inference backbone for
Mimir — a professional knowledge assistant focused on GRC (Governance, Risk, Compliance) and Information Security.
The Round 2 data was generated by Claude Sonnet 4 from 46 hand-written seed patterns. Full generator script + seeds:
Bharambe-NL/mimir-training.
Monotonic improvement across all 4 evals (step 500, 1000, 1500, 1894). No plateau, no overfit.
Tool density on the other five families shifted upward slightly (CVE 1.8→2.1, New Regulation 1.4→2.0, Product 1.3→1.9, TPRM 1.6→1.9, Threading 1.2→1.4), suggesting the model got more decisive on genuinely-tool-requiring queries rather than under-calling them.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5base_model_id = "Qwen/Qwen3.5-4B"
6adapter_id = "Bharambe-NL/mimir-qwen3-4b-lora-v2"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
9model = AutoModelForCausalLM.from_pretrained(
10 base_model_id,
11 torch_dtype=torch.bfloat16,
12 device_map="auto",
13 trust_remote_code=True,
14)
15model = PeftModel.from_pretrained(model, adapter_id)
16model.eval()
17if tokenizer.pad_token is None:
18 tokenizer.pad_token = tokenizer.eos_token
19
20# Example inference
21messages = [
22 {"role": "system", "content": "You are Mimir ..."}, # full system prompt at link below
23 {"role": "user", "content": "What's the difference between ISO 27001 and SOC 2?"},
24]
25text = tokenizer.apply_chat_template(
26 messages,
27 tokenize=False,
28 add_generation_prompt=True,
29 enable_thinking=False, # important: skips Qwen3's default reasoning scaffold
30)
31inputs = tokenizer(text, return_tensors="pt").to(model.device)
32
33outputs = model.generate(
34 **inputs,
35 max_new_tokens=512,
36 temperature=0.1,
37 do_sample=True,
38 pad_token_id=tokenizer.eos_token_id,
39 eos_token_id=[
40 tokenizer.eos_token_id,
41 tokenizer.convert_tokens_to_ids("<|im_end|>"), # stops cleanly after the turn
42 ],
43)
44response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
45print(response)
Qwen3.5 is a hybrid architecture — linear-attention layers require these kernels to run on GPU:
Without them, the model silently falls back to pure-torch CPU paths and inference is ~20 × slower. For pre-built wheels that match your torch version, see the
causal-conv1d releases page.
Complete training and eval infrastructure (scripts, seeds, eval set):
Bharambe-NL/mimir-training.
1@misc{mimir-qwen3-4b-lora-v2,
2 author = {Bharambe, Sagar},
3 title = {Mimir-Qwen3-4B-LoRA v2: LoRA adapter for a GRC/InfoSec knowledge assistant},
4 year = {2026},
5 url = {https://huggingface.co/Bharambe-NL/mimir-qwen3-4b-lora-v2},
6}