Released by AutoTrust AI Lab · Adapted by Hai Yu (cloudyu)
What is DeepSeek-V4-Flash-4E?
DeepSeek-V4-Flash is a 284B-parameter Mixture-of-Experts (MoE) language model with 13B activated parameters, supporting a context length of one million tokens. The original model uses num_experts_per_tok=6 by default.
DeepSeek-V4-Flash-4E is a post-processed variant of the same model with the number of activated experts per token reduced from 6 → 4, while keeping all other weights identical. This change:
Reduces inference compute by ~33% (fewer active experts per forward pass)
Improves generation throughput by ~8–11%
Maintains or improves accuracy on both code generation and knowledge benchmarks
Uses the same FP4 + FP8 mixed precision format as the original
Why top_k=4 Instead of 6?
The original num_experts_per_tok=6 is not a power of 2. In practice, this means:
GPU tensor core utilization is suboptimal for certain MoE dispatch shapes
Memory alignment and warp scheduling are less efficient compared to power-of-2 expert counts
The routing decision per token requires computing softmax over 6 logits instead of 4, introducing unnecessary overhead
Setting top_k to 4 (a power of 2) gives the GPU's SIMT architecture a natural alignment for expert dispatch and attention masking, while activating 33% fewer parameters per token with no accuracy degradation—and in many reasoning-heavy tasks, a measurable accuracy improvement.
Key Changes from the Original
Configuration
Original (top_k=6)
This Model (top_k=4)
num_experts_per_tok
6
4
Activated params
~13B
~11B
Total params
284B
284B
Routing method
noaux_tc
noaux_tc
All other weights
identical
identical
The tid2eid (expert routing) weight tensors have been reshaped from [vocab_size, 6] to [vocab_size, 4] — only the first 4 columns are retained, matching the original training distribution order. No additional training or fine-tuning was performed; this is purely an inference-time configuration change.
Both configurations fail on the same 4 problems (has_close_elements, decode_cyclic, is_nested, order_by_points), suggesting these are inherent model capability limitations rather than routing artifacts.
+3.69 percentage points higher accuracy across 12,032 questions
~8% faster generation
Category Breakdown
Category
top_k=4
top_k=6
Delta
biology
68.62% (492/717)
72.66% (521/717)
−4.04pp
business
39.04% (308/789)
21.67% (171/789)
+17.36pp
chemistry
14.58% (165/1132)
7.16% (81/1132)
+7.42pp
computer science
47.80% (196/410)
44.63% (183/410)
+3.17pp
economics
66.35% (560/844)
65.05% (549/844)
+1.30pp
engineering
25.39% (246/969)
13.21% (128/969)
+12.18pp
health
59.54% (487/818)
63.08% (516/818)
−3.55pp
history
50.13% (191/381)
59.58% (227/381)
−9.45pp
law
33.51% (369/1101)
35.88% (395/1101)
−2.36pp
math
28.13% (380/1351)
15.47% (209/1351)
+12.66pp
other
55.09% (509/924)
56.71% (524/924)
−1.62pp
philosophy
53.91% (269/499)
55.71% (278/499)
−1.80pp
physics
20.32% (264/1299)
14.55% (189/1299)
+5.77pp
psychology
69.17% (552/798)
71.93% (574/798)
−2.76pp
Key observations:
top_k=4 dominates STEM and business: business (+17.36pp), math (+12.66pp), engineering (+12.18pp), chemistry (+7.42pp), physics (+5.77pp), computer science (+3.17pp). These categories require precise numerical computation, formula derivation, or logical reasoning — activating fewer experts produces more stable outputs.
top_k=6 leads modestly in humanities/life sciences: history (+9.45pp), biology (+4.04pp), health (+3.55pp), psychology (+2.76pp), law (+2.36pp), philosophy (+1.80pp). These categories rely more on knowledge recall and semantic understanding.
Net advantage: top_k=4 correctly answers 1040 questions that top_k=6 gets wrong, while top_k=6 only answers 597 questions that top_k=4 misses — a 1.74× advantage for top_k=4.
Confidence Analysis
top_k=4 consistently produces cleaner output on multiple-choice questions — it is more likely to emit a single letter answer (A-J) directly, whereas top_k=6 occasionally generates verbose or malformed responses that fail to match the extraction regex. This contributes partially to the accuracy gap.
top_k=6 activates 50% more experts per token but wall-clock generation time increases by only ~9–13%, confirming that GPU compute and memory bandwidth are partially overlapped.
Summary
top_k=4 wins in all practical metrics: higher or equal accuracy, faster inference, lower memory bandwidth usage
The improvement is particularly pronounced on math, engineering, business, chemistry, and physics reasoning tasks
The original top_k=6 provides marginal benefits only in humanities/life sciences categories
For production deployment, top_k=4 is the recommended configuration
Full evaluation reports, scripts, and raw results are available in the eval/ directory of this repository.
This release does not include a Jinja-format chat template. Instead, the encoding/ folder provides Python scripts and test cases demonstrating how to encode messages in OpenAI-compatible format into input strings for the model, and how to parse the model's text output. Please refer to the encoding/README.md for full documentation.
Note: This encoding script is only needed when using the model through HuggingFace Transformers or vLLM directly. Inference engines that natively support the DeepSeek-V4 chat format (e.g., ds4) handle prompt construction internally and do not require it.
How to Run Locally
Please refer to the inference/ folder for detailed instructions on running DeepSeek-V4 locally using the official DeepSeek inference code, including model weight conversion and interactive chat demos.
For local deployment, we recommend setting the sampling parameters to temperature = 1.0, top_p = 1.0. For the Think Max reasoning mode, we recommend setting the context window to at least 384K tokens.
License
This repository and the model weights are licensed under the MIT License.
Contact
If you have any questions, please raise an issue on HuggingFace.