This repository contains a tiny DeepseekV3ForCausalLM Mixture-of-Experts
language model trained from scratch on the full TinyStories training corpus.
The model has 2,803,272 total parameters and approximately 1,807,944
parameters active per token. It retains the main DeepSeek-V3 inference
building blocks at a deliberately small scale: Multi-Head Latent Attention
(MLA), Q and KV low-rank compression, interleaved RoPE, routed and shared
experts, sigmoid top-k routing, and correction-bias-based load balancing.
This is an independently trained synthetic tiny checkpoint. It is not an
official DeepSeek model, contains no weights from an original DeepSeek
checkpoint, and should not be expected to match the capabilities of production
DeepSeek models.
Repository contents
hf/: the final Hugging Face checkpoint and tokenizer
example_generate.py: a minimal local generation example
eval_text_generation.json: generations from the final training evaluation
artifact_metadata.json: training arguments, metrics, router usage, and the
expanded configuration
deepseek_v3_config_dump.json: a standalone configuration dump
Optimizer checkpoints, packed training data, and the full training log are
intentionally omitted from the distribution package.
Architecture identity
This checkpoint loads through the standard Transformers classes:
It does not use DeepseekV2ForCausalLM with a renamed model card. Important
V3-specific behavior includes sigmoid routing, normalized selected routing
weights, interleaved RoPE, Q LoRA compression, and an expert correction bias.
Every layer uses DeepSeek MLA rather than conventional GQA. Queries are
compressed through a rank-64 Q projection, while keys and values share a
rank-64 latent representation before expansion to eight attention heads.
Each query/key head combines a 16-dimensional non-positional component and a
16-dimensional rotary component. Values use 32 dimensions per head.
num_key_value_heads equals num_attention_heads because MLA compresses the
shared KV latent state before expanding it to the attention heads. Setting a
smaller KV-head count would describe GQA, not this MLA implementation.
DeepSeekMoE routing
The first decoder layer is dense. Each of the remaining four layers contains
four routed experts and one always-active shared expert. One routed expert is
selected for each token.
The V3 router computes sigmoid affinity scores. Selection uses the affinity
score plus a non-gradient correction bias, while the routed expert weight uses
the original affinity score. During training, the correction bias was adjusted
after every batch: overloaded experts were decreased and underloaded experts
were increased. A very small complementary sequence-wise balance objective was
also used.
All routed experts received traffic. Aggregate fractions across the complete
training run ranged from approximately 0.140 to 0.496 depending on layer and
expert. These aggregate values reflect learned routing specialization and are
not expected to be exactly uniform.
MTP scope
The checkpoint contains the standard Transformers DeepSeek-V3 causal language
model used for inference. It does not contain a training-only Multi-Token
Prediction (MTP) draft module:
Transformers 5.14.1 exposes the V3 MTP count in configuration but does not
instantiate or train the original DeepSeek-V3 MTP module in
DeepseekV3ForCausalLM. The checkpoint therefore preserves the V3 main-model
inference graph and V3 routing behavior, but does not claim to reproduce the
complete original V3 pretraining recipe.
Training data
The model was trained on the full TinyStories training corpus using an
independent 1% validation split:
Validation loss was computed over 32 batches, or 131,072 tokens, from the
independent packed validation split. These values are compact checkpoint
diagnostics, not general language-model benchmark results.
Example generation
A representative final sampled generation begins:
text
1Once upon a time, there was a little girl named Lily. She had long black,
2white hair that she loved to play with every day. One day, Lily's mom asked
3her to clean up her bedroom. Lily didn't want to clean up, so she started to
4pick up her toys and put them away in the closet.
An independent greedy reload test produced:
text
1Once upon a time, there was a little girl named Lily. She loved to play
2outside in the sunshine and pick flowers. One day, she saw a big, scary dog
3running towards her. The dog ran away and Lily was sad.
Sampling is stochastic. The model produces recognizable TinyStories-style
English, but contradictions, incorrect pronouns, invented words, repetition,
and unfinished stories remain possible at this size.
Usage
Install the requirements:
pip install -r requirements.txt
Run the included example from the repository root:
compact inference-engine and architecture experiments
testing generate(), save_pretrained(), and from_pretrained()
It is not intended for:
instruction following or chat
factual question answering
reasoning benchmarks
production deployment
safety-critical use
comparison with full-size DeepSeek models
Limitations
only 2.80 million total parameters
small 1,003-token tokenizer
English TinyStories-only pretraining
no instruction tuning and no chat template
no MTP training module or MTP objective
weak factual knowledge and reasoning
occasional grammatical and semantic errors
possible mojibake inherited from training-text byte sequences
no capability-equivalence claim with official DeepSeek models
Citation and references
This is a synthetic tiny DeepSeek-V3-compatible MoE checkpoint trained from
scratch on TinyStories. It is intended for implementation validation,
debugging, education, and small-scale architecture experiments.