-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzen-coder_whitepaper.tex
More file actions
417 lines (346 loc) · 13 KB
/
zen-coder_whitepaper.tex
File metadata and controls
417 lines (346 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{listings}
\usepackage[dvipsnames]{xcolor}
\usepackage{booktabs}
\usepackage{float}
\usepackage{geometry}
\geometry{margin=1in}
% Color definitions
\definecolor{zenblue}{RGB}{41,121,255}
\definecolor{zengreen}{RGB}{52,199,89}
\definecolor{zenorange}{RGB}{255,149,0}
\definecolor{codegray}{RGB}{245,245,245}
% Hyperref setup
\hypersetup{
colorlinks=true,
linkcolor=zenblue,
urlcolor=zenblue,
citecolor=zenblue
}
% Code listing setup
\lstset{
backgroundcolor=\color{codegray},
basicstyle=\ttfamily\small,
breaklines=true,
captionpos=b,
frame=single,
numbers=left,
numberstyle=\tiny\color{gray}
}
\title{
\vspace{-2cm}
\Large \textbf{Zen AI Model Family} \\
\vspace{0.5cm}
\Huge \textbf{Zen Coder} \\
\vspace{0.3cm}
\large Agentic Code Generation Models (4B - 1T) \\
\vspace{0.5cm}
\normalsize Technical Report v2.0
}
\author{
Antje Worring, Zach Kelling\thanks{zach@lux.network} \\
\texttt{research@hanzo.ai} \\
\\
Zoo Labs Foundation \\
\texttt{foundation@zoo.ngo}
}
\date{December 2025}
\begin{document}
\maketitle
\begin{abstract}
We present \textbf{Zen Coder}, a family of agentic code generation models ranging from 4B to 1T parameters,
trained on the \textbf{Zen Agentic Dataset}---8.47 billion tokens of real-world Claude Code sessions,
git history, and professional software development spanning 15 years across 1,452 repositories.
Unlike synthetic datasets, our training data captures actual debugging workflows, multi-file refactoring decisions,
tool use patterns, and error recovery from production AI development. The model family includes dense models
(4B, 24B, 123B) and MoE architectures (358B, 1T), covering edge deployment to frontier capabilities.
\end{abstract}
\tableofcontents
\newpage
\section{Introduction}
The emergence of agentic AI systems---where models interact with tools, execute multi-step plans, and
maintain context across complex workflows---has created demand for models specifically trained on
real agentic programming patterns. \textbf{Zen Coder} addresses this by training on actual Claude Code
debug sessions rather than synthetic instruction-following data.
\subsection{Model Family}
\begin{table}[H]
\centering
\begin{tabular}{llllll}
\toprule
\textbf{Model} & \textbf{Size} & \textbf{Base} & \textbf{VRAM} & \textbf{Context} & \textbf{Status} \\
\midrule
Zen Coder 4B & 4B & Zen-4B-Instruct & 8 GB & 32K & Trained \\
Zen Coder 24B & 24B & Zen Coder 24B-Instruct & 24 GB & 256K & Trained \\
Zen Coder 123B & 123B & Zen Coder 123B & 128 GB & 256K & Training \\
Zen Coder Max & 358B (MoE) & Zen Coder Max & 180 GB & 200K & Planned \\
Zen Coder Ultra & 1T (MoE) & Zen MoDE Ultra & 256 GB & 128K & Planned \\
\bottomrule
\end{tabular}
\caption{Zen Coder Model Family}
\end{table}
\subsection{Key Innovations}
\begin{itemize}
\item \textbf{Real Agentic Data}: Trained on actual Claude Code sessions, not synthetic instruction data
\item \textbf{Production Code}: 15 years of battle-tested software across AI, Web3, cryptography
\item \textbf{Multi-Architecture}: Dense (4B-123B) and MoE (358B-1T) models for different deployment needs
\item \textbf{Open Training}: Full training framework available via \href{https://github.com/zenlm/zen-trainer}{zen-trainer}
\end{itemize}
\section{Training Data: Zen Agentic Dataset}
The \textbf{Zen Agentic Dataset} comprises 8.47 billion tokens derived from real software development
and Claude Code interactions, distinguishing it from synthetic datasets.
\begin{table}[H]
\centering
\begin{tabular}{lrrr}
\toprule
\textbf{Data Source} & \textbf{Tokens (B)} & \textbf{\%} & \textbf{Description} \\
\midrule
Git History & 4.03 & 48\% & 15 years of commits, diffs, source files \\
Claude Debug Sessions & 2.42 & 29\% & Real debugging workflows with tool use \\
Claude Conversations & 1.14 & 13\% & Architecture discussions, code reviews \\
Claude Interactions & 0.86 & 10\% & Multi-turn coding assistance \\
\midrule
\textbf{Total} & \textbf{8.47} & 100\% & 3.35M training samples \\
\bottomrule
\end{tabular}
\caption{Zen Agentic Dataset Composition}
\end{table}
\subsection{Dataset Statistics}
\begin{table}[H]
\centering
\begin{tabular}{ll}
\toprule
\textbf{Metric} & \textbf{Value} \\
\midrule
Total Tokens & 8.47 billion \\
Training Samples & 3.35 million \\
Validation Samples & 100,000 \\
Total Size & 27 GB \\
Repositories & 1,452 \\
Time Span & 15 years (2010-2025) \\
\bottomrule
\end{tabular}
\caption{Dataset Statistics}
\end{table}
\subsection{Domain Coverage}
\subsubsection{Agentic AI \& LLM Infrastructure}
\begin{itemize}
\item Model Context Protocol (MCP) - 260+ tool implementations
\item Multi-agent orchestration - Claude, GPT-4, Gemini, Zen integrations
\item Agent frameworks - Planning, memory, tool use, reflection
\item LLM Gateway - Unified proxy for 100+ providers
\end{itemize}
\subsubsection{Web3 \& Blockchain}
\begin{itemize}
\item Smart contracts - Solidity, Vyper (ERC20, ERC721, ERC1155, DeFi)
\item Consensus engines - Snow family, BFT, DAG-based protocols
\item Cross-chain bridges - Multi-VM architecture
\item DeFi protocols - AMMs, lending, staking, governance
\end{itemize}
\subsubsection{Cryptography \& Security}
\begin{itemize}
\item Post-quantum cryptography - Kyber, Dilithium, SPHINCS+
\item Threshold cryptography - MPC, secret sharing, DKG
\item Zero-knowledge proofs - zkSNARKs, zkSTARKs experimentation
\item Key management - HD wallets, hardware integration
\end{itemize}
\subsubsection{Modern Development}
\begin{itemize}
\item Full-stack TypeScript - Next.js 14+, React 18+, Node.js
\item Systems programming - Rust, Go, Python, C/C++
\item DevOps - Docker, Kubernetes, CI/CD pipelines
\item Real-time systems - Event sourcing, CQRS, message queues
\end{itemize}
\subsection{Language Distribution}
\begin{table}[H]
\centering
\begin{tabular}{lll}
\toprule
\textbf{Tier 1 (Core)} & \textbf{Tier 2 (Infrastructure)} & \textbf{Tier 3 (Specialized)} \\
\midrule
Python & SQL & Solidity \\
TypeScript & Bash/Shell & C/C++ \\
JavaScript & YAML/TOML & Protobuf \\
Rust & Dockerfile & GraphQL \\
Go & Makefile & Move \\
\bottomrule
\end{tabular}
\caption{Language Coverage by Tier}
\end{table}
\section{Model Architectures}
\subsection{Dense Models (4B, 24B, 123B)}
The smaller models use dense transformer architectures optimized for different deployment scenarios:
\begin{table}[H]
\centering
\begin{tabular}{llll}
\toprule
\textbf{Model} & \textbf{Base Architecture} & \textbf{Layers} & \textbf{Hidden Dim} \\
\midrule
Zen Coder 4B & Zen-4B-Instruct & 40 & 2560 \\
Zen Coder 24B & Zen Coder 24B-Instruct & 56 & 5120 \\
Zen Coder 123B & Zen Coder 123B & 80 & 8192 \\
\bottomrule
\end{tabular}
\caption{Dense Model Specifications}
\end{table}
\subsection{MoE Models (358B, 1T)}
The larger models employ Mixture of Experts architectures for efficient scaling:
\begin{table}[H]
\centering
\begin{tabular}{llll}
\toprule
\textbf{Model} & \textbf{Total Params} & \textbf{Active Params} & \textbf{Experts} \\
\midrule
Zen Coder Max & 358B & ~60B & 128 experts, top-8 \\
Zen Coder Ultra & 1T & ~150B & 256 experts, top-8 \\
\bottomrule
\end{tabular}
\caption{MoE Model Specifications}
\end{table}
\section{Training Methodology}
\subsection{Training Framework}
We developed \href{https://github.com/zenlm/zen-trainer}{zen-trainer}, an open-source framework
supporting multiple backends:
\begin{itemize}
\item \textbf{MLX}: Apple Silicon optimization (M1/M2/M3 Pro/Max/Ultra)
\item \textbf{Unsloth}: 2x faster NVIDIA training with memory optimization
\item \textbf{DeepSpeed}: Multi-GPU and multi-node training
\end{itemize}
\subsection{Fine-tuning Configuration}
\begin{table}[H]
\centering
\begin{tabular}{lllll}
\toprule
\textbf{Model} & \textbf{LoRA r} & \textbf{LoRA $\alpha$} & \textbf{Batch} & \textbf{LR} \\
\midrule
4B & 64 & 128 & 4 & 2e-4 \\
24B & 32 & 64 & 2 & 1e-4 \\
123B & 16 & 32 & 1 & 5e-5 \\
Max & 16 & 32 & 1 & 5e-6 \\
Ultra & 8 & 16 & 1 & 1e-6 \\
\bottomrule
\end{tabular}
\caption{QLoRA Fine-tuning Hyperparameters}
\end{table}
\subsection{Training Costs}
For 3.35M samples (8.47B tokens) on 8xH200 @ \$35/hr:
\begin{table}[H]
\centering
\begin{tabular}{llll}
\toprule
\textbf{Model} & \textbf{Cloud Hours} & \textbf{Cloud Cost} & \textbf{Local (Mac Studio)} \\
\midrule
Zen Coder 4B & 9h & \$326 & 2 days (FREE) \\
Zen Coder 24B & 23h & \$814 & 5 days (FREE) \\
Zen Coder 123B & 62h & \$2,171 & 13 days (FREE) \\
Zen Coder Max & 116h & \$4,071 & 19 days (FREE) \\
Zen Coder Ultra & 310h & \$10,856 & N/A (too large) \\
\bottomrule
\end{tabular}
\caption{Training Cost Estimates}
\end{table}
\section{Usage}
\subsection{Installation}
\begin{lstlisting}[language=bash, caption=Install zen-trainer]
pip install zen-trainer
\end{lstlisting}
\subsection{Training Example}
\begin{lstlisting}[language=Python, caption=Fine-tuning with zen-trainer]
from zen_trainer import ZenTrainer
trainer = ZenTrainer(
model_key="zen-coder-4b",
dataset_path="hanzoai/zen-agentic-dataset-private",
output_dir="./output/zen-coder-4b",
)
trainer.train()
\end{lstlisting}
\subsection{Inference Example}
\begin{lstlisting}[language=Python, caption=Using Zen Coder for inference]
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"zenlm/zen-coder-4b",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("zenlm/zen-coder-4b")
messages = [
{"role": "user", "content": "Write a Python function to validate email addresses"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
\end{lstlisting}
\section{What Makes This Unique}
\subsection{Real Agentic Programming}
Unlike synthetic datasets, the Zen Agentic Dataset contains \textbf{actual Claude Code sessions} showing:
\begin{itemize}
\item Real debugging workflows with trial and error
\item Complex multi-file refactoring decisions
\item Architecture discussions and trade-offs
\item Tool use patterns (file ops, search, git, tests)
\item Error recovery and iterative refinement
\end{itemize}
\subsection{Production Code Quality}
\begin{itemize}
\item Code that shipped to production systems
\item Security-audited smart contracts
\item Performance-optimized infrastructure
\item Battle-tested patterns from real deployments
\end{itemize}
\section{Evaluation}
Models are evaluated on agentic coding benchmarks including:
\begin{itemize}
\item \textbf{SWE-bench Verified}: Real GitHub issue resolution
\item \textbf{TAU-Bench}: Tool-agent-user interaction
\item \textbf{BFCL V3}: Berkeley Function Call Leaderboard
\item \textbf{Terminal-Bench}: Terminal environment tasks
\item \textbf{LiveCodeBench}: Real-time coding challenges
\end{itemize}
\section{Licensing \& Access}
\subsection{Models}
\begin{itemize}
\item Zen Coder 4B, 24B: Apache 2.0
\item Zen Coder 123B: Zen Commercial License v1.0
\item Zen Coder Max: Zen Commercial License v1.0
\item Zen Coder Ultra: Zen Commercial License v1.0
\end{itemize}
\subsection{Dataset Access}
The Zen Agentic Dataset is available for research and commercial licensing.
Contact \texttt{z@hanzo.ai} for access.
\section{Supported Organizations}
\begin{table}[H]
\centering
\begin{tabular}{lll}
\toprule
\textbf{Organization} & \textbf{Focus} & \textbf{Role} \\
\midrule
Hanzo AI & AI infrastructure & Primary maintainer \\
Zen LM & Open model research & Model training \\
Zoo Labs & Decentralized AI & Research grants \\
Lux Network & AI compute settlement & Infrastructure \\
\bottomrule
\end{tabular}
\caption{Supporting Organizations}
\end{table}
\section{Conclusion}
Zen Coder represents a new approach to code generation model training: using real agentic programming
data rather than synthetic instructions. By training on actual Claude Code sessions from 15 years of
production software development, these models learn genuine debugging patterns, tool use workflows,
and the iterative nature of real programming.
The complete model family---from 4B for edge deployment to 1T for frontier capabilities---provides
options for every use case. The open training framework (\href{https://github.com/zenlm/zen-trainer}{zen-trainer})
enables the community to train custom models on their own data.
\section*{Links}
\begin{itemize}
\item Models: \href{https://huggingface.co/zenlm}{huggingface.co/zenlm}
\item Dataset: \href{https://huggingface.co/datasets/hanzoai/zen-agentic-dataset}{huggingface.co/datasets/hanzoai/zen-agentic-dataset}
\item Training: \href{https://github.com/zenlm/zen-trainer}{github.com/zenlm/zen-trainer}
\item Website: \href{https://zenlm.org}{zenlm.org}
\item Contact: \href{mailto:z@hanzo.ai}{z@hanzo.ai}
\end{itemize}
\end{document}