Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion deepseek/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@ The above plots try to answer this question -> `How much attention, on average,
- Expert 0–1 → grammar & attribution (“and”, “said”)
- Expert 2–3 → event & interaction semantics (“play”, “with”, “time”, “She”)
- NOUN peaks in Expert 2 (0.18) → this expert handles object and subject nouns (like “Lily”, “time”, “girl”).
- PUNCT high in Expert 1 → punctuation + quotation boundaries → this expert probably activates for dialogue and sentence ends.
- PUNCT high in Expert 1 → punctuation + quotation boundaries → this expert probably activates for dialogue and sentence ends.

### Model Architecture diagram
![model_architecture](images/deepseek_arch.png)
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README references 'deepseek_arch.png' but the added file is 'deepseek_arch.mermaid'. Either the image reference should point to the correct file extension or a PNG version needs to be generated from the Mermaid diagram.

Suggested change
![model_architecture](images/deepseek_arch.png)
```mermaid
%% See deepseek_arch.mermaid for the source diagram
%% Paste the contents of deepseek_arch.mermaid below
[PASTE THE CONTENTS OF deepseek_arch.mermaid HERE]

Copilot uses AI. Check for mistakes.
41 changes: 41 additions & 0 deletions deepseek/images/deepseek_arch.mermaid
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
flowchart TB
%% ====== Top-Level Model ======
subgraph Model["DeepseekInspiredModel"]
direction TB
X["Token IDs"]
Embed["Embedding Layer"]
H0["Hidden States (h₀)"]

%% --- Dense Blocks ---
subgraph Dense["Dense Blocks (count = num_dense_ffn = 2)"]
direction TB
DB["TransformerBlock\n→ Attention + Dense Expert FFN"]
end

%% --- MoE Blocks ---
subgraph MoE["MoE Blocks (count = num_moe_ffn = 4)"]
direction TB
MB["TransformerBlock\n→ Attention + MoE FFN"]
end

LN["Final RMSNorm"]
Head["Linear to vocab (tied weights)"]
Logits["Output Logits"]

X --> Embed --> H0 --> Dense --> MoE --> LN --> Head --> Logits
end

%% ====== MoE FFN Internals (high-level) ======
subgraph MoE_FFN["MoE FFN per token"]
direction TB
h["Input h"]
Gate["Gate: Linear → scores\n(top-k = 2)"]
Routed["Routed Experts (num = 16)\nOnly top-2 active per token"]
Shared["Shared Experts (num = 8)\nAlways active"]
Combine["Sum( Routed_output + Shared_output )"]

h --> Gate --> Routed --> Combine
h --> Shared --> Combine
end

MB --- MoE_FFN
Binary file added deepseek/images/deepseek_arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.