A research-focused Small Language Model (SLM) combining DeepSeek-style MLA + MoE, Kimi Attention Residuals, and the Muon optimizer into a single custom architecture trained from scratch on consumer-grade hardware.
Overview
CodeMind-1B is an experimental, coding-focused SLM designed to explore the next generation of efficient transformer architectures. Unlike standard LLaMA/Mistral derivatives, CodeMind is built around a fully custom stack developed from scratch.
This release is the Base Pre-training Checkpoint. It was trained to validate architecture stability, optimizer behavior, and sparse routing efficiency on a single NVIDIA A40 GPU.
Architecture Highlights
Multi-Head Latent Attention (MLA)
DeepSeek-style KV compression using latent-space attention reconstruction.
Benefits: Massive KV-cache reduction, inherently long-context friendly, lower VRAM usage, and superior inference scaling.
Mixture of Experts (MoE)
Fine-grained routed experts designed for sparse, efficient compute.
25% General: FineWeb-Edu (Teaching general language and knowledge)
Training Metrics
The model demonstrated textbook convergence across all custom objectives without divergence, proving the stability of the hybrid optimizer and custom architecture.
Training Loss & Tokens Seen
Train Loss
Tokens Seen
MTP & Load Balancing Loss
MTP Loss
Load Balancing Loss
Z-Loss & Muon Learning Rate
Z-Loss
Muon Learning Rate
Initial Loss: ~10.5 ➔ Final Loss: ~3.1
MoE Load Balancing: Stable at ~0.35, proving experts are actively sharing the workload.
Throughput: Sustained ~1,940 Tok/s on a single A40.
Current Capabilities & Limitations
This Model can:
Generate valid Python syntax and complete basic functions.
Understand indentation, classes, and structure.
Follow standard code patterns.
This checkpoint cannot:
Perform robust logic (147M tokens is enough for syntax, not reasoning).
Answer conversational questions (It is not Instruction Tuned).
Avoid hallucinations on complex algorithms.
How to Load the Model
Because CodeMind uses a heavily customized architecture, it cannot be loaded via standard Hugging Face AutoModel classes. You must use the repository source code directly.
python
1import torch
2from safetensors.torch import load_file
3from config.model_config import CodeMindConfig
4from tokenizer.tokenizer import CodeMindTokenizer
5from model.codemind import CodeMindSLM
67# 1. Initialize config and tokenizer8config = CodeMindConfig()9tokenizer = CodeMindTokenizer()1011# 2. Build the architecture12model = CodeMindSLM(config).to("cuda").to(torch.bfloat16)1314# 3. Load weights15state_dict = load_file("model.safetensors")1617# 4. Remove torch.compile prefixes if present18cleaned_dict ={19 k.replace("_orig_mod.",""): v
20for k, v in state_dict.items()21}2223model.load_state_dict(cleaned_dict, strict=False)24print("✅ CodeMind loaded successfully!")
Acknowledgements & References
This architecture was built entirely from scratch, drawing heavy inspiration from the following groundbreaking papers: