h3rb3rn commited on
Commit
54bbe89
·
verified ·
1 Parent(s): 5577009

docs: upload comprehensive model card for moe-expert-coder-4b

Browse files
Files changed (1) hide show
  1. README.md +141 -0
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - de
5
+ license: apache-2.0
6
+ base_model: Qwen/Qwen3.5-4B
7
+ tags:
8
+ - compound-ai
9
+ - domain-expert
10
+ - coding
11
+ - refactoring
12
+ - ast-validation
13
+ - gguf
14
+ - lumi-g
15
+ - moe-sovereign
16
+ datasets:
17
+ - moe-sovereign/expert-coder-sft
18
+ pipeline_tag: text-generation
19
+ library_name: transformers
20
+ ---
21
+
22
+ # 💻 MoE Sovereign Coder Expert 4B (`moe-expert-coder-4b`)
23
+ *High-Assurance Code Synthesis, Refactoring & AST-Verified Tool Execution*
24
+
25
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
26
+ [![Base Model: Qwen 3.5 4B Hybrid Mamba](https://img.shields.io/badge/Base_Model-Qwen3.5--4B-violet.svg)](https://huggingface.co/Qwen/Qwen3.5-4B)
27
+ [![Trained on: LUMI-G Supercomputer](https://img.shields.io/badge/Trained_on-LUMI--G_MI250X-green.svg)](https://www.lumi-supercomputer.eu/)
28
+
29
+ ---
30
+
31
+ ## 📌 Executive Summary
32
+
33
+ **`moe-expert-coder-4b`** is a domain-specialized 4-billion parameter Small Language Model (SLM) distilled from **DeepSeek-Coder-V2 (236B)** and **DeepSeek-V3** on the **LUMI-G Supercomputer** (8× AMD Instinct™ MI250X 128GB GPUs).
34
+
35
+ It functions as the dedicated **Software Engineering & High-Assurance Coding Expert** within the MoE Sovereign compound AI architecture. The model is specifically tuned to generate syntax-validated Python, Rust, Go, TypeScript, and C++ code, write atomic unified diffs, adhere to strict static analysis and typing constraints, and correct runtime stack traces through persistent Correction Memory.
36
+
37
+ ---
38
+
39
+ ## 🎯 Target Use Cases & Functional Scope
40
+
41
+ 1. **Deterministic Code Generation:** Synthesizes production-ready algorithms, microservices, and system-level routines with explicit error handling and type signatures.
42
+ 2. **AST-Compliant Refactoring & Atomic Diffs:** Produces minimal, robust diff chunks suitable for automated CI/CD integration without broken syntax trees.
43
+ 3. **Static Analysis & Type Checking Compliance:** Generates code guaranteed to satisfy strict Linters (`mypy`, `ruff`, `clippy`, `eslint`).
44
+ 4. **Execution Log & Stack Trace Triage:** Rapidly pinpoints root causes in multi-tier error traces and formulates minimal regression-tested patches.
45
+
46
+ ---
47
+
48
+ ## 🔬 Behavioral Comparison: Stock Qwen 3.5 4B vs. Distilled Coder
49
+
50
+ | Capability | Base Stock Qwen 3.5 4B | `moe-expert-coder-4b` (Distilled) |
51
+ | :--- | :--- | :--- |
52
+ | **Code Structure** | Explanatory text surrounding code blocks | **Pure, AST-Parsable Code Artifacts** and precise unified diffs |
53
+ | **Typing Discipline** | Optional or inconsistent type hints | **Strict Type Annotations** across all parameters and return types |
54
+ | **Edge Case Handling** | Omits boundary checks or fallback paths | **Defensive Error Handling** with explicit exceptions and error types |
55
+ | **Diff Accuracy** | Generates full-file rewrites prone to hallucination | **Surgical Unified Diffs** with exact line ranges and matching context |
56
+ | **Tool Calling Integration**| Generic code snippet generation | **MCP-Aligned Code Execution Payloads** ready for sandbox execution |
57
+
58
+ ---
59
+
60
+ ## 🏋️ Training Setup & Distillation Methodology
61
+
62
+ ```
63
+ +-----------------------------------------------------------------------------------+
64
+ | LUMI-G DISTILLATION PIPELINE |
65
+ | |
66
+ | [ Teachers: DeepSeek-Coder-V2 (236B) + DeepSeek-V3 ] |
67
+ | | |
68
+ | v (AST Parse Validation + PyTest Execution Verification) |
69
+ | [ SFT Dataset: 32,500 High-Assurance Coding & Refactoring Trajectories ] |
70
+ | | |
71
+ | v (DeepSpeed ZeRO-2, ROCm 7.0, PyTorch 2.6, 8x MI250X) |
72
+ | [ Student: Qwen3.5-4B Hybrid Linear Attention + Mamba Base ] |
73
+ | | |
74
+ | v (LoRA r=16, alpha=32, target_modules: q/k/v/o/gate/up/down)|
75
+ | [ Output: final_adapter -> CPU-BF16 Merge -> GGUF Q4_K_M & Q8_0 ] |
76
+ +-----------------------------------------------------------------------------------+
77
+ ```
78
+
79
+ ### Hyperparameters:
80
+ - **Compute Cluster:** LUMI-G (8× AMD Instinct MI250X 128GB GPUs, Slurm Job `#21190761`)
81
+ - **Base Architecture:** Qwen3.5-4B (Hybrid Linear Attention + Mamba in BF16)
82
+ - **Dataset Size:** 32,500 AST-validated code synthesis trajectories
83
+ - **Epochs:** 3.0
84
+ - **Effective Batch Size:** 128 (Micro-batch 4 × 8 GPUs × Gradient Accumulation 4)
85
+ - **Learning Rate:** $1.5 \times 10^{-5}$ with Cosine Decay and Warmup
86
+ - **LoRA Configuration:** $r=16$, $\alpha=32$, Dropout $0.05$, Target Modules: `q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj`
87
+ - **Training Loss (Final):** `0.0106`
88
+ - **Token Accuracy (Final):** **`99.62 %`**
89
+
90
+ ---
91
+
92
+ ## 💻 Quickstart Guide (Ollama & Llama.cpp)
93
+
94
+ ### 1. Ollama `Modelfile`
95
+ ```dockerfile
96
+ FROM ./moe-expert-coder-4b-Q4_K_M.gguf
97
+ PARAMETER num_ctx 262144
98
+ PARAMETER temperature 0.1
99
+ TEMPLATE """{{ if .System }}<|im_start|>system
100
+ {{ .System }}<|im_end|>
101
+ {{ end }}{{ if .Prompt }}<|im_start|>user
102
+ {{ .Prompt }}<|im_end|>
103
+ {{ end }}<|im_start|>assistant
104
+ {{ .Response }}<|im_end|>"""
105
+ ```
106
+
107
+ ### 2. Python Inference
108
+ ```python
109
+ import torch
110
+ from transformers import AutoModelForCausalLM, AutoTokenizer
111
+
112
+ model_id = "h3rb3rn/moe-expert-coder-4b"
113
+
114
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
115
+ model = AutoModelForCausalLM.from_pretrained(
116
+ model_id,
117
+ torch_dtype=torch.bfloat16,
118
+ device_map="auto",
119
+ trust_remote_code=True
120
+ )
121
+
122
+ prompt = "<|im_start|>user\nWrite a thread-safe asynchronous WAL writer in Rust with CRC32 checksum framing.<|im_end|>\n<|im_start|>assistant\n"
123
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
124
+ outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.1)
125
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 📑 Citation
131
+
132
+ ```bibtex
133
+ @misc{moe_sovereign_2026_coder4b,
134
+ author = {Horn, Philipp and MoE Sovereign Core AI Team},
135
+ title = {MoE Sovereign Coder Expert 4B: High-Assurance Code Synthesis & Refactoring SLM},
136
+ year = {2026},
137
+ publisher = {Hugging Face},
138
+ howpublished = {\url{https://huggingface.co/h3rb3rn/moe-expert-coder-4b}},
139
+ note = {Trained on the EuroHPC LUMI-G Supercomputer}
140
+ }
141
+ ```