UE5 MCP Tool-Calling LoRA — 2B

A PEFT/LoRA adapter that fine-tunes Qwen/Qwen3.5-2B to emit structured tool-calling responses for Unreal Engine 5 development tasks (function calls that conform to the UE5 MCP server's tool schema in config/mcp_config.json).

This is one of three adapters trained in the same recipe; the others are Yhyu13/Qwen3.5-2B-UE5-LoRA and Yhyu13/Qwen3.5-4B-UE5-LoRA. The training tooling, data and benchmark live in the parent project: Yhyu13/UE5_Training_MCP.

Model details

Item Value
Base model Qwen/Qwen3.5-2B
PEFT type LoRA (rank 16, α 32, dropout 0.05)
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Task CAUSAL_LM (tool-call text generation)
Training data data/splits/train.jsonl of Yhyu13/UE5_Training_MCP (a small UE5 corpus bundled with the training repo; not published as a separate HF dataset) (108 examples)
Eval data data/splits/val.jsonl (13 examples)
Max seq length 512
Epochs 3
Effective batch size 8 (per_device 4 × grad_accum 2)
Learning rate 3e-4
Wall-clock training 144.7s on 1×CUDA 12.1
Train framework PEFT 0.19.1 · Transformers 5.14.1 · TRL 0.26.2 · Torch 2.5.1+cu121
Adapter size 41.6 MB (adapter_model.safetensors)
Eval loss (val) 0.4876

How to use

Requires peft + transformers. From the base model + adapter:

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

BASE = "Qwen/Qwen3.5-2B"
ADAPTER = "Yhyu13/Qwen3.5-2B-UE5-LoRA"

tok = AutoTokenizer.from_pretrained(BASE, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    BASE, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
)
model = PeftModel.from_pretrained(model, ADAPTER)
model.eval()

# See Yhyu13/UE5_Training_MCP/eval/benchmark_questions.jsonl for prompt format.
prompt = open("eval/example_prompt.txt").read()
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
print(tok.decode(out[0], skip_special_tokens=True))

Or, with the bundled chat template baked in:

ADAPTER = "Yhyu13/Qwen3.5-2B-UE5-LoRA"
tok = AutoTokenizer.from_pretrained(ADAPTER, trust_remote_code=True)
print(tok.chat_template[:200], "...")   # matches the adapter's training chat template

Training procedure

Reproduce with the scripts in Yhyu13/UE5_Training_MCP:

git clone https://huggingface.co/Yhyu13/UE5_Training_MCP
cd UE5_Training_MCP
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
python scripts/train_qwen35.py \
    --base_model Qwen/Qwen3.5-2B \
    --train data/splits/train.jsonl \
    --val   data/splits/val.jsonl   \
    --out   outputs/models/qwen3.5-2b-ue5-lora

Hyperparameters come from train_meta.json (bundled in this repo).

Evaluation

final_eval.json records the validation loss after the third epoch. The full side-by-side benchmark (base vs. fine-tuned, tool-call exact-match rate, JSON schema conformance, and lm_eval results) lives in Yhyu13/UE5_Training_MCP/outputs/results/.

Limitations & intended use

  • Trained on a small UE5-specific corpus (~hundreds of examples). Expect strong in-distribution behaviour on UE5 engine-API tool calls, weak generalising to non-UE5 or non-MCP tool schemas.
  • Domain coverage leans to editor scripting (cmd_*), Blueprint→Python (py_*), and the introspection tools declared in the bundled config/mcp_config.json.
  • Always validate emitted tool calls against the actual MCP server schema before executing against a running UE5 instance.

License

Apache-2.0 — same as the base Qwen3.5 model.

Downloads last month
7
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Yhyu13/Qwen3.5-2B-UE5-LoRA

Finetuned
Qwen/Qwen3.5-2B
Adapter
(139)
this model