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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
base_model: Qwen/Qwen3.5-27B
|
| 4 |
+
tags:
|
| 5 |
+
- text-generation-inference
|
| 6 |
+
- peft
|
| 7 |
+
- qwen3_5
|
| 8 |
+
- code
|
| 9 |
+
- vision-language
|
| 10 |
+
- fsharp
|
| 11 |
+
- svelte
|
| 12 |
+
- typescript
|
| 13 |
+
- dotnet
|
| 14 |
+
- docker
|
| 15 |
+
- kubernetes
|
| 16 |
+
license: apache-2.0
|
| 17 |
+
language:
|
| 18 |
+
- en
|
| 19 |
+
datasets:
|
| 20 |
+
- odytrice/kenichi-sft
|
| 21 |
+
pipeline_tag: image-text-to-text
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# Kenichi Thinking β Domain-Specialized Coding Assistant with Vision (27B)
|
| 25 |
+
|
| 26 |
+
Kenichi Thinking is a reasoning-first coding model fine-tuned from [Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B) for domain-specialized code generation. It retains the base model's vision capabilities, making it suitable for planning agents that can interpret screenshots, architecture diagrams, and UI mockups alongside code.
|
| 27 |
+
|
| 28 |
+
## Model Details
|
| 29 |
+
|
| 30 |
+
### Model Description
|
| 31 |
+
|
| 32 |
+
Kenichi Thinking is a vision-language model specialized in F#, .NET, Svelte 5, TypeScript, Docker, and Kubernetes development. It was created through multi-teacher distillation from five frontier models, with all F# samples verified by the F# compiler. The model uses Qwen3.5's hybrid Gated DeltaNet + standard attention architecture with a frozen Pixtral vision tower.
|
| 33 |
+
|
| 34 |
+
- **Developed by:** [odytrice](https://huggingface.co/odytrice)
|
| 35 |
+
- **Model type:** Vision-Language Model (Image-Text-to-Text), LoRA fine-tuned
|
| 36 |
+
- **Language(s) (NLP):** English
|
| 37 |
+
- **License:** Apache 2.0
|
| 38 |
+
- **Finetuned from model:** [Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B)
|
| 39 |
+
|
| 40 |
+
### Model Sources
|
| 41 |
+
|
| 42 |
+
- **Repository:** [github.com/odytrice/models](https://github.com/odytrice/models)
|
| 43 |
+
- **Training Dataset:** [odytrice/kenichi-sft](https://huggingface.co/datasets/odytrice/kenichi-sft)
|
| 44 |
+
- **GGUF Quantizations:** [odytrice/kenichi-thinking-GGUF](https://huggingface.co/odytrice/kenichi-thinking-GGUF)
|
| 45 |
+
|
| 46 |
+
## Uses
|
| 47 |
+
|
| 48 |
+
### Direct Use
|
| 49 |
+
|
| 50 |
+
Kenichi Thinking is designed as a coding assistant for the following domains:
|
| 51 |
+
|
| 52 |
+
- **F#** β core language, FsToolkit, Giraffe, Akka.NET, linq2db, Farmer, FAKE
|
| 53 |
+
- **.NET / ASP.NET** β web APIs, Minimal API, middleware, dependency injection
|
| 54 |
+
- **Svelte 5 / SvelteKit** β runes (`$state`, `$derived`, `$effect`), server routes, form actions
|
| 55 |
+
- **TypeScript** β type-safe patterns, generics, utility types
|
| 56 |
+
- **Docker & Kubernetes** β Dockerfiles, Compose, Helm charts, deployments, services
|
| 57 |
+
- **Agentic SWE** β tool use, multi-step reasoning, code review, debugging workflows
|
| 58 |
+
|
| 59 |
+
The model also accepts image inputs (screenshots, diagrams, architecture drawings) for visual code understanding tasks.
|
| 60 |
+
|
| 61 |
+
### Downstream Use
|
| 62 |
+
|
| 63 |
+
Suitable for integration into:
|
| 64 |
+
- AI coding assistants and IDE plugins
|
| 65 |
+
- Planning agents that need visual + code understanding
|
| 66 |
+
- Code review and refactoring pipelines
|
| 67 |
+
- Documentation generation from code or diagrams
|
| 68 |
+
|
| 69 |
+
### Out-of-Scope Use
|
| 70 |
+
|
| 71 |
+
- General-purpose chat (the model is specialized for coding tasks)
|
| 72 |
+
- Languages and frameworks outside the training domains
|
| 73 |
+
- Safety-critical code generation without human review
|
| 74 |
+
- Image generation (the model can read images, not create them)
|
| 75 |
+
|
| 76 |
+
## Bias, Risks, and Limitations
|
| 77 |
+
|
| 78 |
+
- The model is specialized for a narrow set of technologies. Performance on other programming languages or frameworks may be worse than the base Qwen3.5-27B model.
|
| 79 |
+
- Training data was generated by teacher models (MiniMax M2.7, Kimi K2.5, DeepSeek R1, GLM-5, Nvidia Nemotron) and may inherit their biases.
|
| 80 |
+
- F# samples were compiler-verified, but samples in other domains were not mechanically verified.
|
| 81 |
+
- The model should not be used as a sole source of truth for production code without human review.
|
| 82 |
+
|
| 83 |
+
### Recommendations
|
| 84 |
+
|
| 85 |
+
Users should validate all generated code, especially for security-sensitive applications. The model performs best when given detailed, domain-specific prompts within its specialization areas.
|
| 86 |
+
|
| 87 |
+
## How to Get Started with the Model
|
| 88 |
+
|
| 89 |
+
Use the following system prompt for best results:
|
| 90 |
+
|
| 91 |
+
> You are Kenichi, an expert coding assistant specialized in F#, .NET, Svelte 5, SvelteKit, TypeScript, Docker, and Kubernetes. You write clean, idiomatic, and well-structured code with clear explanations.
|
| 92 |
+
|
| 93 |
+
### Python
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
from transformers import AutoModelForImageTextToText, AutoTokenizer
|
| 97 |
+
|
| 98 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 99 |
+
"odytrice/kenichi-thinking",
|
| 100 |
+
torch_dtype="bfloat16",
|
| 101 |
+
device_map="auto",
|
| 102 |
+
)
|
| 103 |
+
tokenizer = AutoTokenizer.from_pretrained("odytrice/kenichi-thinking")
|
| 104 |
+
|
| 105 |
+
messages = [
|
| 106 |
+
{"role": "system", "content": "You are Kenichi, an expert coding assistant specialized in F#, .NET, Svelte 5, SvelteKit, TypeScript, Docker, and Kubernetes. You write clean, idiomatic, and well-structured code with clear explanations."},
|
| 107 |
+
{"role": "user", "content": "Write an F# function that uses FsToolkit to parse and validate a configuration file with error accumulation."}
|
| 108 |
+
]
|
| 109 |
+
|
| 110 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
|
| 111 |
+
outputs = model.generate(inputs, max_new_tokens=2048, temperature=0.7)
|
| 112 |
+
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
### Ollama
|
| 116 |
+
|
| 117 |
+
```bash
|
| 118 |
+
ollama run odytrice/kenichi-thinking:32gb
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
Available tags: `:24gb` (Q4_K_M), `:32gb` (Q4_K_M), `:48gb` (Q5_K_M), `:96gb` (Q8_0), `:full` (F16)
|
| 122 |
+
|
| 123 |
+
## Training Details
|
| 124 |
+
|
| 125 |
+
### Training Data
|
| 126 |
+
|
| 127 |
+
[odytrice/kenichi-sft](https://huggingface.co/datasets/odytrice/kenichi-sft) β 7,953 samples across 7 domains, generated via multi-teacher distillation.
|
| 128 |
+
|
| 129 |
+
| Domain | Samples | % |
|
| 130 |
+
|--------|---------|---|
|
| 131 |
+
| F# (core + libraries) | 3,913 | 49.2% |
|
| 132 |
+
| Svelte 5 / TypeScript | 1,200 | 15.1% |
|
| 133 |
+
| Docker / Kubernetes | 800 | 10.1% |
|
| 134 |
+
| .NET / ASP.NET | 750 | 9.4% |
|
| 135 |
+
| Agentic SWE | 640 | 8.0% |
|
| 136 |
+
| Cross-domain | 400 | 5.0% |
|
| 137 |
+
| General coding | 250 | 3.1% |
|
| 138 |
+
|
| 139 |
+
#### Teacher Models
|
| 140 |
+
|
| 141 |
+
| Teacher | Contribution |
|
| 142 |
+
|---------|-------------|
|
| 143 |
+
| MiniMax M2.7 | 42.0% |
|
| 144 |
+
| Kimi K2.5 | 27.2% |
|
| 145 |
+
| DeepSeek R1 | 14.9% |
|
| 146 |
+
| GLM-5 | 9.6% |
|
| 147 |
+
| Nvidia Nemotron | 6.3% |
|
| 148 |
+
|
| 149 |
+
All F# samples were verified by the F# compiler (`dotnet fsi` / `dotnet build`).
|
| 150 |
+
|
| 151 |
+
### Training Procedure
|
| 152 |
+
|
| 153 |
+
#### Preprocessing
|
| 154 |
+
|
| 155 |
+
- Training data formatted in ChatML (Qwen) format with system prompt injected at training time
|
| 156 |
+
- Sequences packed to 16,384 tokens maximum (due to VRAM constraints from 248K vocab size)
|
| 157 |
+
- 110 samples (1.5%) truncated at 16K tokens; remaining 98.5% fit without truncation
|
| 158 |
+
- Vision tower frozen during training to preserve visual capabilities
|
| 159 |
+
|
| 160 |
+
#### Training Hyperparameters
|
| 161 |
+
|
| 162 |
+
- **Training regime:** BF16 mixed precision
|
| 163 |
+
- **Method:** LoRA (rank 16, alpha 32, dropout 0.0)
|
| 164 |
+
- **Trainable parameters:** 116.7M (0.42% of 27.4B)
|
| 165 |
+
- **Epochs:** 1
|
| 166 |
+
- **Effective batch size:** 8 (micro batch 1 x gradient accumulation 8)
|
| 167 |
+
- **Learning rate:** 1e-4 (cosine schedule, 5% warmup)
|
| 168 |
+
- **Weight decay:** 0.01
|
| 169 |
+
- **Optimizer:** AdamW 8-bit
|
| 170 |
+
- **Packing:** Enabled (16K max packed sequence length)
|
| 171 |
+
- **Attention:** flash_attention_2 (with monkey-patch for Qwen3.5 3D position IDs bug)
|
| 172 |
+
|
| 173 |
+
#### LoRA Target Modules
|
| 174 |
+
|
| 175 |
+
GDN layers: `in_proj_qkv`, `in_proj_z`, `in_proj_b`, `in_proj_a`, `out_proj`
|
| 176 |
+
Standard attention: `q_proj`, `k_proj`, `v_proj`, `o_proj`
|
| 177 |
+
All MLPs: `gate_proj`, `up_proj`, `down_proj`
|
| 178 |
+
|
| 179 |
+
#### Speeds, Sizes, Times
|
| 180 |
+
|
| 181 |
+
- **Training time:** 3 hours 24 minutes
|
| 182 |
+
- **Steps:** 194
|
| 183 |
+
- **Speed:** 63 seconds/step
|
| 184 |
+
- **Final train loss:** 0.34
|
| 185 |
+
- **Final token accuracy:** 90.3%
|
| 186 |
+
|
| 187 |
+
## Evaluation
|
| 188 |
+
|
| 189 |
+
### Testing Data, Factors & Metrics
|
| 190 |
+
|
| 191 |
+
#### Testing Data
|
| 192 |
+
|
| 193 |
+
397 held-out validation samples from [odytrice/kenichi-sft](https://huggingface.co/datasets/odytrice/kenichi-sft) (`chatml_val` split).
|
| 194 |
+
|
| 195 |
+
#### Metrics
|
| 196 |
+
|
| 197 |
+
- **Training loss:** 0.34 (1 epoch)
|
| 198 |
+
- **Token accuracy:** 90.3%
|
| 199 |
+
|
| 200 |
+
### Results
|
| 201 |
+
|
| 202 |
+
Formal evaluation on the held-out validation set is pending.
|
| 203 |
+
|
| 204 |
+
## Environmental Impact
|
| 205 |
+
|
| 206 |
+
- **Hardware Type:** NVIDIA H200 SXM 141GB
|
| 207 |
+
- **Hours used:** 3.4
|
| 208 |
+
- **Cloud Provider:** RunPod
|
| 209 |
+
- **Compute Region:** US
|
| 210 |
+
- **Carbon Emitted:** Estimated ~1.2 kg CO2eq
|
| 211 |
+
|
| 212 |
+
## Technical Specifications
|
| 213 |
+
|
| 214 |
+
### Model Architecture and Objective
|
| 215 |
+
|
| 216 |
+
Qwen3.5-27B is a hybrid vision-language model:
|
| 217 |
+
|
| 218 |
+
- **64 layers:** 48 Gated DeltaNet (GDN) linear attention + 16 standard attention
|
| 219 |
+
- **Vision tower:** Pixtral (24 layers, ~460M params) β frozen during fine-tuning
|
| 220 |
+
- **Total parameters:** 27.4B
|
| 221 |
+
- **Vocab size:** 248,320 tokens
|
| 222 |
+
- **Context length:** 131,072 tokens (base model)
|
| 223 |
+
|
| 224 |
+
### Compute Infrastructure
|
| 225 |
+
|
| 226 |
+
#### Hardware
|
| 227 |
+
|
| 228 |
+
NVIDIA H200 SXM 141GB (single GPU)
|
| 229 |
+
|
| 230 |
+
#### Software
|
| 231 |
+
|
| 232 |
+
- PyTorch 2.5.1 + CUDA 12.4
|
| 233 |
+
- Transformers 5.3.0
|
| 234 |
+
- PEFT 0.18.1
|
| 235 |
+
- TRL 0.24
|
| 236 |
+
- flash-attn 2.x
|
| 237 |
+
- causal-conv1d 1.6.1
|
| 238 |
+
- flash-linear-attention 0.3.2
|
| 239 |
+
|
| 240 |
+
### Known Issues
|
| 241 |
+
|
| 242 |
+
- **flash_attention_2 bug:** Qwen3.5's 3D M-RoPE position IDs trigger a bug in transformers 5.3.0's `_is_packed_sequence()`. A monkey-patch is required during training/inference. See [GitHub issue #44643](https://github.com/huggingface/transformers/issues/44643).
|
| 243 |
+
- **GDN layer dependencies:** Efficient inference requires `causal-conv1d` and `flash-linear-attention` (fla). Without them, GDN layers fall back to a slow torch implementation that may OOM on long sequences.
|
| 244 |
+
|
| 245 |
+
## Related Models
|
| 246 |
+
|
| 247 |
+
- **[Kenichi Flash](https://huggingface.co/odytrice/kenichi-flash)** β Devstral Small 2 24B variant, optimized for fast agentic coding (text-only)
|
| 248 |
+
|
| 249 |
+
## Model Card Authors
|
| 250 |
+
|
| 251 |
+
[odytrice](https://huggingface.co/odytrice)
|
| 252 |
+
|
| 253 |
+
## Model Card Contact
|
| 254 |
+
|
| 255 |
+
[odytrice](https://huggingface.co/odytrice)
|