Synapse v2 is a 3.67M parameter decoder-only Transformer built entirely from scratch — no HuggingFace Trainer, no pre-built architecture. Every component is implemented manually: the attention mechanism, BPE tokenizer, positional embeddings, training loop, and inference pipeline.
This is the second generation of the Synapse series, representing a 4.6× parameter scale-up and 3× depth increase from Synapse v1 — with a core focus on transitioning from memorization to generalization.
"This work prioritizes understanding over performance. Building from first principles reveals what production models abstract away."
— Abhinav Tyagi
Evolution: v1 → v2
Metric
Synapse v1
Synapse v2
Factor
Parameters
800K
3.67M
4.6×
Layers
4
12
3×
Vocabulary
1,500 (basic BPE)
1,037 (Turbo BPE)
Professional
Context Window
128 tokens
64 tokens
Optimized
Regularization
None
Dropout 0.1
Added
Training Loss
0.05 (memorization)
2.04
Better generalization
Validation Loss
Not measured
3.26
Tracked
Perplexity
1.05 (overfit)
7.7 train / 26.1 val
Learned patterns
Capability
Text continuation
Instruction following
Functional
The core lesson: systematic scaling + regularization + quality data = generalization.
This ensures correct handling of contractions, numbers, punctuation, and whitespace — preventing cross-boundary merges that degrade tokenization quality.
Optimizations implemented:
Doubly-linked list for O(1) merge updates (vs O(n) list rebuilding)
Hash map for O(1) pair lookup
Position sets to track all occurrences efficiently
Hybrid instruction-tuned corpus (~18–20K pairs, ~200–500K tokens):
Component
Size
Purpose
Dolly-15k
~15K instructions
Reasoning, QA, summarization
Creator Profile
~500 examples
Identity grounding
GenAI Knowledge
~2K examples
Technical expertise
Domain Facts
~1K examples
Grounded world knowledge
Training Configuration
Hyperparameter
Value
Optimizer
Adam
Learning Rate
1e-3
Batch Size
4
Training Steps
5,000
Dropout
0.1
Context Length
64 tokens
Training Results
Metric
Value
Initial Loss
8.54
Final Training Loss
2.04
Final Validation Loss
3.26
Train Perplexity
7.7
Validation Perplexity
26.1
Starting from random initialization (loss 8.54 ≈ log(1037)), the model converged to 2.04 — demonstrating genuine learning, not memorization. The train/val gap (2.04 vs 3.26) confirms effective regularization via dropout.
Key Design Decisions Explained
Why 12 layers?
Enables hierarchical learning: syntax (lower layers) → semantics (middle) → reasoning (upper). Empirically validated as the sweet spot for ~4M parameter models.
Why pre-norm (LayerNorm before attention)?
More stable training — gradients don't explode or vanish as easily. Standard in modern architectures (GPT-3, Claude). Allows higher learning rates.
Why dropout 0.1?
The v1 model had a perplexity of 1.05 — pure memorization, useless for generalization. Dropout forced the model to learn robust patterns. The validation gap (3.26 vs 2.04) proves it worked.
Why 64-token context (smaller than v1's 128)?
Most conversational turns fit in 50–80 tokens. Reduces O(T²) attention cost by 4× — faster training, same capability for dialogue tasks.
Abhinav Tyagi is an LLM Engineer who builds AI systems from the ground up — from custom tokenizers and transformer architectures to production RAG pipelines and agentic systems.
1@misc{tyagi2026synapsev2,
2 author = {Tyagi, Abhinav},
3 title = {Synapse v2: A Decoder-Only Transformer Language Model Built from First Principles},
4 year = {2026},
5 url = {https://huggingface.co/Abhinav-Tyagi/synapse_v2}
6}
License
MIT — free to use, modify, and distribute with attribution.
"Understanding requires building. Building requires breaking things. Breaking things requires documentation."
— Abhinav Tyagi