Qim-4B
Qim-4B is a 4B bilingual (English & Russian) coding, reasoning, and general assistant model fine-tuned from Qwen/Qwen3-4B-Instruct-2507 with a focus on C++20, Dear ImGui (1.93.1, IMGUI_DISABLE_OBSOLETE_FUNCTIONS), Python, and on-demand <think>...</think> reasoning.
Created by Antinimus.
- Model Family / Base:
Qwen/Qwen3-4B-Instruct-2507(4.06Bparams,36layers, GQA32Q / 8KV) - Weights Format: Standalone merged BF16 weights (
model.safetensors, with the LoRA adapter and calibrated<think>/</think>embedding & LM-head rows already merged — no separate LoRA loading required). All GGUF files are quantized directly from these merged BF16 weights. - Context Length:
262,144tokens (256K) native context window (max_position_embeddings: 262144,rope_theta: 5,000,000inconfig.json; SFT training sequence cutoff:1,536tokens; benchmark evaluation generation limit:2,048tokens).
Highlights
- +50% More Compiling C++20 / Dear ImGui 1.93.1 Solutions: On Europa ImPlus BenchMark (EIPB), improved compilation rate from 28 / 100 (
Qwen3-4B-Instruct-2507Base) to 42 / 100 (+14tasks), and +75% Solved Tasks (7 / 100vs4 / 100), lifting Strict EIPB Score from2.59%to4.66%and Partial EIPB Score from5.79%to7.69%. - On-Demand
<think>...</think>Reasoning Restored:Qwen3-4B-Instruct-2507is originally a non-thinking checkpoint where<think>and</think>embeddings are collapsed near<tool_call>(cos = 0.9901). Targeted embedding + LoRA calibration separated<think>/</think>cleanly (cos = 0.4454), enabling<think>...</think>reasoning when requested while staying concise and direct on normal coding/chat requests. - Compiler & Headless-Verified Dear ImGui 1.93.1 Data: Curated with zero mid-response truncation (
missing_eos = 0) and verified usingg++ 16.2.0 -std=c++20 -DIMGUI_DISABLE_OBSOLETE_FUNCTIONSplus 3-frame headlessImGui::NewFrame()/Render()execution (57/57Dear ImGui1.93.1modules passed). - Verified GGUF Quantizations: Standalone merged
Q4_K_M,Q5_K_M, andQ8_0GGUF builds tested end-to-end withllama.cpp b12843(llama-cli -ngl 99 -st).
Benchmark & Evaluation — Europa ImPlus BenchMark (EIPB)
Evaluated on Europa ImPlus BenchMark (EIPB): 100 executable C++20 / Dear ImGui 1.93.1 (docking, IMGUI_DISABLE_OBSOLETE_FUNCTIONS) tasks across 8 categories (31 easy, 45 medium, 24 hard).

How EIPB Scoring Works
- Difficulty Weights: Each task is weighted by difficulty (1 for
easy, 2 formedium, 3 forhard), summing to 193 max points. - Strict Score (
EIPB Score): Percentage of the 193 points awarded only for tasks where 100% of hidden headless UI unit tests pass. - Partial Score (
EIPB Partial): Percentage of the 193 points giving fractional credit(passed_tests / total_tests) * task_points, reflecting compiling solutions and partial test passes. - Local Testbed: Windows 11, MinGW-W64 WinLibs
g++ 16.2.0(UCRT,-std=c++20). Local Qwen models were evaluated with greedy decoding (temperature=0.0,max_new_tokens=2048).
Overall Comparison (Local WinLibs GCC 16.2.0 Harness)
| Model | Protocol / Notes | Compiled | Solved (pass@1) | Strict (EIPB Score) | Partial (EIPB Partial) |
|---|---|---|---|---|---|
Antinimus/Qim-1.5B | Local BF16 (temp=0.0, WinLibs GCC 16.2.0) | 25 / 100 | 1 / 100 (1.0%) | 0.52% | 1.99% |
Qwen/Qwen3-4B-Instruct-2507 (Base) | Local BF16 (temp=0.0, WinLibs GCC 16.2.0) | 28 / 100 | 4 / 100 (4.0%) | 2.59% | 5.79% |
Qim-4B (Ours) | Local BF16 (temp=0.0, WinLibs GCC 16.2.0) | 42 / 100 | 7 / 100 (7.0%) | 4.66% | 7.69% |
Claude Opus 5.5 (Reference) | Web Chat (effort: High, 2026-11-29, WinLibs GCC 16.2.0) | 94 / 100 | 89 / 100 (89.0%) | 88.08% | 90.07% |
Reproducibility note: All local models and the
Claude Opus 5.5reference were graded on the exact same Windows 11 / WinLibs GCC 16.2.0 harness shown above (on its separate Linux GCC + ASan/TSan run, those sameClaude Opus 5.5answers scored100/100compiled,97/100solved,97.41%strict,98.88%partial).
Per-Category Breakdown (Partial% (Strict%, Solved))
Category (Tasks / Max Pts) | Qim-1.5B | Qwen3-4B-Instruct-2507 (Base) | Qim-4B (Ours) | Claude Opus 5.5 (High, WinLibs) |
|---|---|---|---|---|
Core Widgets (15 / 19) | 11.4% (5.3%, 1/15) | 27.2% (21.1%, 3/15) | 49.1% (31.6%, 5/15) | 100.0% (100.0%, 15/15) |
Input & Popups (15 / 31) | 2.2% (0.0%, 0/15) | 12.4% (3.2%, 1/15) | 7.5% (3.2%, 1/15) | 100.0% (100.0%, 15/15) |
Layout & Tables (15 / 30) | 1.7% (0.0%, 0/15) | 1.7% (0.0%, 0/15) | 6.7% (6.7%, 1/15) | 100.0% (100.0%, 15/15) |
Custom Rendering (15 / 30) | 0.0% (0.0%, 0/15) | 0.0% (0.0%, 0/15) | 0.0% (0.0%, 0/15) | 100.0% (100.0%, 15/15) |
Fonts, Style & IO (12 / 24) | 0.0% (0.0%, 0/12) | 0.0% (0.0%, 0/12) | 0.0% (0.0%, 0/12) | 70.8% (66.7%, 9/12) |
Architecture C++ (13 / 29) | 0.0% (0.0%, 0/13) | 2.3% (0.0%, 0/13) | 2.3% (0.0%, 0/13) | 77.0% (69.0%, 9/13) |
Debugging (10 / 16) | 3.1% (0.0%, 0/10) | 6.2% (0.0%, 0/10) | 3.1% (0.0%, 0/10) | 65.6% (62.5%, 6/10) |
Projects (5 / 14) | 0.0% (0.0%, 0/5) | 0.0% (0.0%, 0/5) | 0.0% (0.0%, 0/5) | 100.0% (100.0%, 5/5) |
GGUF Quantizations
All GGUF builds were exported from the standalone merged BF16 weights (llama.cpp b12843) — no separate LoRA adapter is required — and verified on AMD Vulkan (RX 9060 XT) using llama-cli -ngl 99 -st for Qwen chat formatting, <think> tag generation, and clean EOS stopping:
| File | Quant | Size | Verified Speed (RX 9060 XT Vulkan) | Notes |
|---|---|---|---|---|
gguf/Qim-4B-Q4_K_M.gguf | Q4_K_M | 2.33 GiB (2,497,278,912 B) | ~104.8 t/s | Compact 4-bit build for fast local inference |
gguf/Qim-4B-Q5_K_M.gguf | Q5_K_M | 2.69 GiB (2,889,511,872 B) | ~93.1–93.7 t/s | Recommended balance of speed and coding/reasoning quality |
gguf/Qim-4B-Q8_0.gguf | Q8_0 | 3.99 GiB (4,280,403,392 B) | ~67.9 t/s | Near-lossless 8-bit quantization |
Quickstart
transformers (Standalone Merged BF16)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Antinimus/Qim-4B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype="auto",
device_map="auto",
)
messages = [
{"role": "system", "content": "You are Qim. Think concisely inside <think>...</think> when helpful."},
{"role": "user", "content": "Think inside <think>...</think> before answering: If 3x + 7 = 22, what is x^2 + 1?"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
top_p=0.8,
top_k=20,
do_sample=True,
)
response = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
print(response)
llama.cpp (GGUF — llama-cli & llama-server)
Install prebuilt binaries or build from source via the official ggml-org/llama.cpp repository (Releases).
CLI single-turn inference:
llama-cli -m Qim-4B-Q5_K_M.gguf -ngl 99 --temp 0.7 --top-p 0.8 --top-k 20 -st -p "Напиши короткий виджет Dear ImGui 1.93.1 с чекбоксом VSync и слайдером Scale."
OpenAI-compatible API server (port 9931 for Pi, Hermes, OpenClaw, or local IDE clients at http://localhost:9931/v1):
llama-server -hf Antinimus/Qim-4B:Q5_K_M --port 9931 -ngl 99 --temp 0.7 --top-p 0.8 --top-k 20
vLLM (BF16 OpenAI-Compatible Server)
vllm serve Antinimus/Qim-4B --port 9931
Docker Model Runner (GGUF)
docker model run hf.co/Antinimus/Qim-4B:Q5_K_M
Training Details
- Base Model:
Qwen/Qwen3-4B-Instruct-2507(4.06Bparameters,36layers,262,144-token context) - Method & Weight Merging:
- LoRA SFT (
r=16,lora_alpha=32,lora_dropout=0.05, all linear projections:q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj;33,030,144trainable params /0.8145%) - At the end of Stage 2, the LoRA adapter and the calibrated
<think>/</think>embedding & LM-head rows were merged directly into thebfloat16checkpoint (model.safetensors), and all GGUF quantizations were exported from that merged BF16 model.
- LoRA SFT (
- Stage 1 — Domain, Coding & Bilingual Mix (
367optimizer steps,val_loss = 0.5508):imgui_v4_clean:280rows at Stage 1 (47headless-verified Dear ImGui1.93.1modules × 2 EN/RU =94+179C++20 algorithms +7compact UI examples), repeated×2=560raw rows- C++ instructions (
1,600) + Python code instructions (1,200) + Bilingual chat (900 RU + 600 EN = 1,500) +Bespoke-Stratos-17kreasoning traces (1,200) - Exact Stage 1 Sample Count:
560 + 1,600 + 1,200 + 1,500 + 1,200 = 6,060raw rows ->97% / 3%train/val split (5,878 / 182) -> strictlen(input_ids) <= 1,536filter removed8train +1val overlength rows ->5,870train /181val (missing_eos = 0, zero mid-response truncation) bs=1,grad_accum=16, cosinelr=2.5e-5
- Stage 2 — Targeted
<think>Token & C++20 Calibration (100optimizer steps,val_loss = 0.5852):imgui_v4_cleanexpanded by+10headless Dear ImGui1.93.1modules (57 × 2 = 114EN/RU +179C++20 algorithms +7compact UI =300rows, weighted×1) + C++ (350) + Python (250) + EN/RU chat (300) + concise<think>set (450=40curated EN/RU pairs +410<= 1,150-token traces fromBespoke-Stratos-17k)- Exact Stage 2 Sample Count:
300 + 350 + 250 + 300 + 450 = 1,650raw rows ->97% / 3%split ->1,600train /50val (0filtered out,missing_eos = 0) - Gentle LoRA (
lr=8e-6) + dedicated FP32 2-row embedding/LM-head optimization (--train-think-tokens,lr=2e-3on<think>/</think>)
- Hardware & Runtime: AMD Radeon RX 9060 XT (16 GiB VRAM), Windows 11, PyTorch
2.9.1+rocm7.13with Chunked Cross-Entropy Loss and AOTriton efficient SDPA attention
Training Data & Upstream Licenses
| Component | Source Repository / Dataset | Role | Upstream License |
|---|---|---|---|
| Base Model | Qwen/Qwen3-4B-Instruct-2507 | Pretrained & instruct backbone (4B, 256K ctx) | Apache-2.0 |
Dear ImGui 1.93.1 UI & Demo Snippets | ocornut/imgui + custom headless-verified cookbook modules | Bilingual EN/RU Dear ImGui 1.93.1 coding tasks | MIT |
C++20 Algorithms (179 rows) | TheAlgorithms/C-Plus-Plus | Modern C++20 data structures & algorithms | MIT |
| C++ Instruction Pairs | m-a-p/CodeFeedback-Filtered-Instruction, ise-uiuc/Magicoder-OSS-Instruct-75K | General C++ coding & explanations | Apache-2.0 / MIT |
| Python Code Corpus | iamtarun/python_code_instructions_18k_alpaca, CodeFeedback-Filtered-Instruction, Magicoder-OSS-Instruct-75K | Python retention mix | Unspecified in HF metadata (python_code_instructions_18k_alpaca); Apache-2.0 / MIT |
Russian Chat (900 rows) | Vikhrmodels/GrandMaster-PRO-MAX | Russian conversational & reasoning fluency | Apache-2.0 |
English Chat (600 rows) | HuggingFaceH4/ultrachat_200k | English instruction following | MIT |
<think> Reasoning Traces | bespokelabs/Bespoke-Stratos-17k + custom concise EN/RU pairs | On-demand <think>...</think> calibration | Apache-2.0 |
Limitations
- Complex multi-file architecture, custom draw-list rendering, dynamic font-atlas textures, and multi-component project tasks remain challenging for 4B-parameter models (see EIPB category table above).
- Under pure greedy decoding (
temperature=0.0, no repetition penalty),12/100long UI prompts still hit the2,048-token cap before closing their code block (88/100extracted vs96/100for Base); use the recommended Qwen3 sampling (temperature=0.7,top_p=0.8,top_k=20) in interactive use. - Target Dear ImGui API knowledge is aligned with
1.93.1(IMGUI_DISABLE_OBSOLETE_FUNCTIONS). - While merged model weights are released under
Apache-2.0matchingQwen/Qwen3-4B-Instruct-2507, one subset component (iamtarun/python_code_instructions_18k_alpaca) does not specify a license field in its Hugging Face card metadata.
Acknowledgments
Built on top of Qwen/Qwen3-4B-Instruct-2507, bespokelabs/Bespoke-Stratos-17k, and the Europa ImPlus BenchMark (EIPB) / Dear ImGui (1.93.1) ecosystem.
Support
If you find Qim-4B useful and want to support future releases and benchmarks:
| Network | Address |
|---|---|
| ETH | 0x9e708ebD5A80867002Bb2e8d5901d50B192E5cc3 |
| BTC | bc1q5762nneqpkjza5v37lwgjmfm3y3m4gu6td6kpc |
| SOL | Ez2VDw5cAz3HGNvhVifRisJ39doebUWELBwm6Hc7rThJ |
| TRON (TRC20) | TEPG7QPjZF2vjAdNn6DN9wUcpSBn2UiSS2 |
| POLYGON | 0x9e708ebD5A80867002Bb2e8d5901d50B192E5cc3 |