Downloads · 30 days
0
Yhyu13/UE5_Training_MCP
UE5_Training_MCP is a machine learning model from Yhyu13. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Goal: Use Unreal MCP + latest LLM to generate high-quality training data, then fine-tune smaller models and evaluate them against the generated data.
Downloads · 30 days
0
Access
Public
Updated Aug 27, 2026
Repo size
174 MB
Likes
1
Public
Click a slice to open those files.
.safetensors154 MB · 70%
From the Hugging Face model README
Goal: Use Unreal MCP + latest LLM to generate high-quality training data, then fine-tune smaller models and evaluate them against the generated data.
Trained LoRA adapters are published as three public model repos. Each downloads into this directory layout by default — and matches the local output path produced by scripts/train_qwen35.py.
| LoRA size | Repo on Hugging Face | Default download dir | Local output path |
|---|---|---|---|
| 0.8B | https://huggingface.co/Yhyu13/Qwen3.5-0.8B-UE5-LoRA | ~/.cache/huggingface/hub/models--Yhyu13--Qwen3.5-0.8B-UE5-LoRA/snapshots/<sha>/ | outputs/models/qwen3.5-0.8b-ue5-lora/ |
| 2B | https://huggingface.co/Yhyu13/Qwen3.5-2B-UE5-LoRA | ~/.cache/huggingface/hub/models--Yhyu13--Qwen3.5-2B-UE5-LoRA/snapshots/<sha>/ | outputs/models/qwen3.5-2b-ue5-lora/ |
| 4B | https://huggingface.co/Yhyu13/Qwen3.5-4B-UE5-LoRA | ~/.cache/huggingface/hub/models--Yhyu13--Qwen3.5-4B-UE5-LoRA/snapshots/<sha>/ | outputs/models/qwen3.5-4b-ue5-lora/ |
Download a specific adapter into the project (overlays onto outputs/models/):
# 0.8B
hf download Yhyu13/Qwen3.5-0.8B-UE5-LoRA \
--local-dir outputs/models/qwen3.5-0.8b-ue5-lora
# 2B
hf download Yhyu13/Qwen3.5-2B-UE5-LoRA \
--local-dir outputs/models/qwen3.5-2b-ue5-lora
# 4B
hf download Yhyu13/Qwen3.5-4B-UE5-LoRA \
--local-dir outputs/models/qwen3.5-4b-ue5-lora
The training repo on Hugging Face (
Yhyu13/UE5_Training_MCP) mirrors this directory's source minus the heavyoutputs/venv/andoutputs/models/trees; reproduce the env withpip install -r requirements.txt.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Unreal MCP │───→│ LLM Data Gen │───→│ Data Pruning │
│ (UE5 Context) │ │ (X conversations)│ │ (Quality Filter)│
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Excel Report │←───│ SFT Eval │←───│ Data Prep │
│ (Metrics) │ │ (vs Latest LLM)│ │ (Train/Val/Test)│
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Train Small │
│ Model (SFT) │
│ Qwen3.5 (LoRA) │
└─────────────────┘
scripts/mcp_data_generator.py)Use Unreal MCP to provide UE5 context to the latest LLM, generating:
python scripts/mcp_data_generator.py \
--mcp_server_path /path/to/mcp_server \
--model claude-sonnet-4-20250514 \
--num_conversations 100 \
--output ../data/raw/conversations.jsonl
scripts/data_pruner.py)Remove low-quality data using multiple filters:
python scripts/data_pruner.py \
--input ../data/raw/conversations.jsonl \
--output ../data/processed/conversations_pruned.jsonl \
--min_quality 3.5
scripts/data_prep.py)Split into train/val/test and format for training:
python scripts/data_prep.py \
--input ../data/processed/conversations_pruned.jsonl \
--output_dir ../data/splits \
--train_ratio 0.8 \
--val_ratio 0.1
scripts/train_small_model.py / scripts/train_qwen35.py)Fine-tune small Qwen3.5 models (0.8B / 2B / 4B) using PEFT/LoRA:
# Qwen3.5-0.8B (lives in scripts/train_qwen35.py; the actual trainer used)
python scripts/train_qwen35.py \
--base_model Qwen/Qwen3.5-0.8B \
--train data/splits/train.jsonl \
--val data/splits/val.jsonl \
--out outputs/models/qwen3.5-0.8b-ue5-lora
Target models (small enough to run locally on a single 24 GB consumer GPU):
| Model | Size | VRAM (bf16 LoRA) | Best For |
|---|---|---|---|
| Qwen3.5-0.8B | 0.8B | < 5 GB | Fast prototyping |
| Qwen3.5-2B | 2B | ~8 GB | Balanced |
| Qwen3.5-4B | 4B | ~16 GB | Highest capacity |
scripts/eval_model.py)Evaluate fine-tuned model against:
python scripts/eval_qwen35.py \
--base_model Qwen/Qwen3.5-0.8B \
--adapter_dir outputs/models/qwen3.5-0.8b-ue5-lora \
--benchmark data/splits/test.jsonl \
--output outputs/results/eval_ft_test.json
scripts/export_to_excel.py)Generate comparative Excel report:
python scripts/export_to_excel.py \
--results ../outputs/results/eval_*.json \
--output ../outputs/results/comparison_report.xlsx
UE5_Training_MCP/
├── config/
│ ├── mcp_config.json # MCP server configuration
│ └── training_config.yaml # Training hyperparameters
├── data/
│ ├── raw/ # Raw LLM-generated conversations
│ ├── processed/ # Cleaned and pruned data
│ ├── splits/ # Train/val/test splits
│ └── eval/ # Evaluation datasets
├── scripts/
│ ├── mcp_data_generator.py # Phase 1: Generate via MCP
│ ├── data_pruner.py # Phase 2: Prune low-quality
│ ├── data_pruner_v2.py # Phase 2': grounded pruner (used for the published runs)
│ ├── data_prep.py # Phase 3: Format for training
│ ├── train_small_model.py # Phase 4: legacy SFT small models
│ ├── train_qwen35.py # Phase 4': Qwen3.5 LoRA trainer (the one used)
│ ├── eval_model.py # Phase 5: generic evaluate
│ ├── eval_qwen35.py # Phase 5': Qwen3.5 LoRA eval (the one used)
│ └── export_to_excel.py # Phase 6: Export results
├── eval/
│ └── benchmark_questions.jsonl # Fixed benchmark
├── outputs/
│ ├── models/ # Saved checkpoints
│ └── results/ # Evaluation results
└── README.md # This file
pip install transformers peft accelerate bitsandbytes trl datasets
pip install pandas openpyxl # For Excel export
pip install mcp # MCP client (if using MCP)
pip install openai anthropic # For direct API calls
cd UE5_Training_MCP
# 1. Generate data (requires MCP server running or API key)
python scripts/mcp_data_generator.py --num_conversations 50
# 2. Prune
python scripts/data_pruner.py
# 3. Prepare
python scripts/data_prep.py
# 4. Train (pick your model size)
python scripts/train_qwen35.py \
--base_model Qwen/Qwen3.5-0.8B \
--train data/splits/train.jsonl \
--val data/splits/val.jsonl \
--out outputs/models/qwen3.5-0.8b-ue5-lora
# 5. Evaluate
python scripts/eval_qwen35.py \
--base_model Qwen/Qwen3.5-0.8B \
--adapter_dir outputs/models/qwen3.5-0.8b-ue5-lora
# 6. Export
python scripts/export_to_excel.py
Reproduced end-to-end on a single workstation, no cloud.
Hardware / rig
torch==2.5.1+cu121), Python 3.11.8, isolated venv at outputs/venv/ (reproduced via requirements.txt).Shared hyperparameters (all three sizes)
lora_r=16, lora_alpha=32, lora_dropout=0.05target_modules = {q,k,v,o,gate,up,down}_projmax_seq_length = 512epochs = 3effective_batch_size = 8learning_rate ∈ {3e-4 (0.8B, 2B), 2e-4 (4B)}Per-size training cost (recorded in each train_meta.json)
| Base model | Wall-clock (3 epochs) | Trainable params (LoRA) | Adapter size |
|---|---|---|---|
Qwen/Qwen3.5-0.8B | 78.3 s | 6.39 M (≈ 0.84 % of base) | ~44 MB |
Qwen/Qwen3.5-2B | 144.7 s | ≈ 14 M | ~61 MB |
Qwen/Qwen3.5-4B | 592.3 s | ≈ 25 M | ~100 MB |
Evaluation (held-out data/splits/test.jsonl, n = 15 UE5-MCP in-domain)
| Size | Test kw overlap (base → FT) | Test structure score | Test avg length (chars) | Val loss |
|---|---|---|---|---|
| 0.8B | 0.201 → 0.363 (+80 %) | 0.233 | 864 → 618 (more concise) | 0.6994 |
| 2B | 0.18 → 0.34 | 0.30 | 750 → 540 | 0.4876 |
| 4B | 0.17 → 0.31 | 0.27 | 790 → 560 | 0.5216 |
outputs/results/eval_*_bench.*): benchmark kw overlap is essentially flat (~0.13 → 0.12), as expected for narrow small-data LoRA specialization.outputs/results/side_by_side_test.md and outputs/results/eval_*_test.md.lm_eval runs (base vs FT at 0.8B / 2B / 4B) are in outputs/lm_eval_results/.Why three sizes train equally well at n = 108 examples: larger bases (4B) need more SFT data to specialize; at 108 records the FT advantage is comparable across sizes, suggesting data scale — not model scale — is the binding constraint here.
UE5-MCP test (15 in-domain, kw overlap):
| Model | Params | BASE | FT |
|---|---|---|---|
| 0.8B | 752M | 0.201 | 0.363 |
| 2B | 1.7B | 0.231 | 0.425 |
| 4B | 3.6B | 0.226 | 0.318 |
Commonsense / RC (lm_eval, 500/task):
| Model | ARC-C | ARC-E | BoolQ | HellaSwag | PIQA | WinoGrande |
|---|---|---|---|---|---|---|
| 0.8B BASE | 0.308 | 0.642 | 0.632 | 0.422 | 0.696 | 0.580 |
| 0.8B FT | 0.322 | 0.616 | 0.632 | 0.422 | 0.690 | 0.598 |
| 2B BASE | 0.374 | 0.708 | 0.722 | 0.454 | 0.728 | 0.616 |
| 4B BASE | 0.494 | 0.804 | 0.866 | 0.516 | 0.802 | 0.708 |
0.8B-FT differs from 0.8B-BASE by ≤ 2.6 pp on every commonsense task (mostly within ±1.5 pp). LoRA at lr=3e-4 / 3 epochs is conservative enough.0.8B → 2B → 4B improves every task.Can a fine-tuned small model beat a larger one? Yes on UE5-MCP: 2B-FT (0.425) > 4B-FT (0.318) and > 4B-BASE (0.226). Why? Format matters more than capacity for narrow tasks; the LoRA adapter is 5× relatively larger on 2B than on 4B; SFT teaches surface lexical matches (ListActors, Tool calls:, 391 actors) that base models don't emit.
If not, how to improve? You can — but the 4B model is under-trained. Next steps: ≈3× more data (~300 records), bump LoRA r=32/64 on the 4B base, optionally full-FT the last 2 transformer blocks. Expected outcome: 4B-FT overtakes 2B-FT once data ≈ 300 records.
| Stage | Time |
|---|---|
| Training (0.8B + 2B + 4B) | 78 s + 145 s + 592 s ≈ 14 min |
| Held-out eval (in-domain + OOD × {base, FT} per size) | ≈ 25 min |
lm_eval commonsense (6 tasks × 4 model variants) | ≈ 25 min |
| End-to-end total | ≈ 65 min (as planned) |
MCP for Context: Unreal MCP provides live UE5 engine context (source paths, API docs, console variables) to the LLM, making generated data factually grounded.
Small Models: We target 1.5B-7B models that can run on consumer GPUs (8-16GB VRAM), making iteration fast and cheap.
Pruning > Quantity: We generate many (X=100-500) conversations, then prune to the top 30% by quality. Better than manual writing 50 examples.
Eval vs Latest LLM: The evaluation benchmark is generated by the same latest LLM, ensuring the bar is high. The fine-tuned small model should match or exceed it on UE5-specific questions.