Code-Trainer V9 — Qwen2.5-Coder-14B LoRA Adapter

A LoRA fine-tune of Qwen/Qwen2.5-Coder-14B-Instruct trained on the code-trainer-v9-mixed dataset. Designed for agentic code generation with structured tool calling via Hermes-format <tool_call> XML tags.

Part of the RTPI (Real-Time Pipeline Intelligence) project.

What's New in V9

V9 is a corrective release targeting <tool_call> tag emission reliability. The V8 model emitted correct tool names and JSON arguments but frequently omitted the <tool_call>/</tool_call> wrapper tags that Ollama and vLLM need for structured tool-call parsing. V9 applies five fixes:

Fix Description Impact
Tag density Tool-calling examples increased from 31% to 42% of dataset (19K glaive + synthetic multi-call) Stronger tag pattern learning
Stop-after-tag All assistant turns with </tool_call> stripped of trailing text Clean generation stop signal
SFTConfig dataset_text_field="text", packing=False prevents cross-example tag bleed Sharper token boundaries
Curriculum Two-phase training: 80% full dataset (lr=1e-4), then 20% tool-call-only polish (lr=2e-4) Format reinforcement
Q5_K_M Deployment quantization upgraded from Q4_K_M to Q5_K_M Better weight fidelity for tag sequences

Evaluation Results

Tool Call Eval (V10 — 14 scenarios)

Pass rate: 92.9% (13/14) | Target: 80%

Scenario Tool Result
list_directory LS Pass
read_file Read Pass
run_command Bash Pass
search_code Grep Pass
find_files Glob Pass
write_file Write Pass
edit_file Edit Pass
fetch_url WebFetch Pass
track_todos TodoWrite Pass
invoke_skill Skill Pass
delegate_to_subagent Task Pass
check_scope ScopeCheck Pass
no_tool_needed (none) Fail — hallucinated a tool call
run_tests Bash Pass

Agent Eval (V10 — 7 multi-turn scenarios)

Progress rate: 100% (7/7) | Target: 5/7

All scenarios (read_and_analyze, find_and_fix_bug, run_and_debug, scope_aware_recon, skill_invocation_scan, delegate_recon, investigate_and_report) passed with tool usage, correct explanations, no refusals, and no loops.

Training Metrics

Metric Value
Phase A eval_loss 0.4581
Phase B eval_loss (final) 0.4551
Phase A steps 2,020
Phase B steps 505
Phase B tool-call rows 25,957

Training Details

Dataset

cmndcntrlcyber/code-trainer-v9-mixed — 44,890 examples across 4 slices:

Slice Source Train Description
Tool calling glaiveai/glaive-function-calling-v2 17,125 Qwen-native <tool_call> format, multi-call synthetic examples
Agentic traces greghavens/fable-5-coding-and-debugging-traces 8,994 Multi-turn coding/debugging with tool use
Code generation cmndcntrlcyber/code-trainer-offsec-dataset 7,074 Offensive security code across 8 languages
Instruction teknium/OpenHermes-2.5 7,208 English instruction-following (language anchor)

64.2% of training examples contain tool calls.

Curriculum Training

Two-phase SFT with trl SFTTrainer:

  • Phase A (80% of steps): Full mixed dataset at lr=1e-4 with cosine scheduler
  • Phase B (20% of steps): Tool-calling-only subset (25,957 rows) at lr=2e-4 for format polish

Hyperparameters

Parameter Value
Base model Qwen/Qwen2.5-Coder-14B-Instruct
LoRA rank (r) 32
LoRA alpha 64
LoRA dropout 0.05
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Effective batch size 16 (bs=1, grad_accum=16)
Max sequence length 4,096
Precision BF16
Gradient checkpointing Yes (use_reentrant=False)
Packing False
Optimizer AdamW (weight_decay=0.01)
Warmup ratio 0.05 (Phase A), 0.10 (Phase B)

Compute

  • Hardware: NVIDIA A100-80GB (HuggingFace Jobs)
  • Training time: ~20 hours (Phase A + Phase B)
  • Framework: transformers 5.7.0, trl 1.3.0, peft 0.19.1, torch 2.11.0+cu128

Usage

With PEFT + Transformers

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

base = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-14B-Instruct",
    dtype=torch.bfloat16,
    device_map="auto",
)
model = PeftModel.from_pretrained(base, "cmndcntrlcyber/qwen14b-code-trainer-v9_mixed")
tokenizer = AutoTokenizer.from_pretrained("cmndcntrlcyber/qwen14b-code-trainer-v9_mixed")

messages = [
    {"role": "system", "content": "You are a coding assistant with access to tools."},
    {"role": "user", "content": "List the files in the current directory."},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(output[0], skip_special_tokens=False))

As GGUF (recommended for deployment)

See cmndcntrlcyber/qwen14b-code-trainer-gguf for merged + quantized Q5_K_M and Q4_K_M GGUF files ready for Ollama, llama.cpp, or vLLM.

Known Limitations

  • no_tool_needed scenario: The model occasionally hallucinated a tool call when no tool was needed (1/14 failure). The strong tool-call training bias makes the model eager to use tools even for pure knowledge questions.
  • Multilingual artifacts: Some responses still contain Unicode replacement characters at sequence boundaries (visible in eval previews as ). These are residual Qwen2.5 tokenizer artifacts that appear during greedy/sampling decoding.
  • Tag format inconsistency: While most responses use proper <tool_call> tags, some emit <toolcall> (no underscore). The nexus-harness fallback parser handles both variants.

Next Steps for Optimization

  1. V10 tag normalization: Add a post-processing tokenizer constraint or logit bias that forces the model to emit <tool_call> (with underscore) consistently, eliminating the <toolcall> variant.
  2. Negative examples for no-tool scenarios: Add 1-2K training examples where the user asks a knowledge question and the assistant responds with plain text (no tool call). This would fix the 1/14 hallucination failure.
  3. Special token registration: Register <tool_call> and </tool_call> as special tokens in the tokenizer (single token IDs) rather than multi-token text sequences. This would make the tags quantization-proof.
  4. Full 3-epoch training: V9 used 1 epoch with curriculum. A 3-epoch run with the same curriculum (Phase A 80% / Phase B 20% per epoch) may further reduce eval_loss.
  5. DPO/ORPO alignment: Use the tool-call eval failures as negative examples in a preference optimization pass to reduce hallucinated tool calls.
  6. Context length scaling: Current max_seq_length is 4096. Testing at 8192 with RoPE scaling could improve multi-turn agent performance.

Project

Framework Versions

  • PEFT 0.19.1
  • Transformers 5.7.0
  • TRL 1.3.0
  • PyTorch 2.11.0+cu128
Downloads last month
45
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for cmndcntrlcyber/qwen14b-code-trainer-v9_mixed

Base model

Qwen/Qwen2.5-14B
Adapter
(80)
this model

Dataset used to train cmndcntrlcyber/qwen14b-code-trainer-v9_mixed