Specification field | Frozen value |
|---|---|
Architecture | Decoder-only causal Transformer |
Parameters | 123,688,704 trainable parameters |
Language | English only |
Vocabulary | 32,000-token byte-level BPE |
Context length | 2,048 tokens |
Pretraining budget | 2.5 billion training tokens |
Framework | PyTorch |
Training GPU | NVIDIA A100 40 GB |
Precision | BF16 mixed precision |
Version | W-1.1-125M v1.0 |
1. Executive Architecture Summary
W-1.1-125M is an English-only, decoder-only autoregressive Transformer designed for pretraining from random initialization. It contains 123,688,704 trainable parameters and uses a 32,000-token byte-level BPE vocabulary, 768-dimensional hidden states, 14 Transformer blocks, 12 attention heads, RoPE positional encoding, RMSNorm, SwiGLU feed-forward networks and tied input/output embeddings.
The base model learns next-token prediction from 2.5 billion English training tokens. It is trained in PyTorch using BF16 on an NVIDIA A100 40 GB GPU. Pretraining produces a base completion model; instruction following and conversational behavior are added later through a separately versioned supervised instruction-tuning stage.
Frozen-design rule: Once full pretraining begins, changes to vocabulary order, special-token IDs, architecture dimensions, context length or optimizer recipe require a new model version. They must never be changed silently inside the same run. |
2. Frozen Model Identity
Property | Final value | Reason |
|---|---|---|
Model family | W-1.1-125M | Small production-oriented English LM |
Model class | Decoder-only Transformer | Efficient autoregressive text generation |
Objective | Next-token cross entropy | Standard causal-language-model pretraining |
Unique parameters | 123,688,704 | Approximately 125M model class |
Training language | English only | Maximizes token efficiency for the chosen scope |
Base/chat separation | Separate checkpoints | Protects the pretrained base model |
3. End-to-End Architecture Flow
Figure 1. Token flow through the decoder-only W-1.1-125M architecture.
For an input sequence x₁…xₜ, the model predicts the distribution of xₜ₊₁ using only the current and earlier tokens. Strict causal masking prevents every position from attending to future tokens. Generation repeats this process one token at a time, using a key/value cache for efficiency.
4. Exact Architecture Configuration
Configuration key | Frozen value |
|---|---|
vocab_size | 32,000 |
d_model | 768 |
n_layers | 14 |
n_heads | 12 |
head_dim | 64 |
ffn_hidden_size | 2,048 |
max_seq_len | 2,048 |
position_encoding | RoPE |
rope_theta | 10,000.0 |
normalization | Pre-norm RMSNorm |
rms_norm_eps | 1e-5 |
activation | SwiGLU / SiLU |
linear_bias | False |
tie_word_embeddings | True |
dropout | 0.0 |
5. Token Embedding and Input Representation
Each integer token ID indexes a learned embedding matrix with shape 32,000 × 768. The result is a sequence of 768-dimensional vectors. There is no learned absolute-position embedding table; positions are incorporated inside attention using rotary positional encoding.
Item | Shape | Parameters |
|---|---|---|
Token embedding | 32,000 × 768 | 24,576,000 |
Input tensor | batch × sequence | Token IDs |
Embedded tensor | batch × sequence × 768 | Activations |
Output head | Uses transposed embedding matrix | No separate weight matrix |
5.1 Weight Tying
The input embedding and final language-model head share the same weight matrix. Weight tying saves 24,576,000 parameters, reduces memory use and ensures that input and output token representations remain linked. Checkpoint loading must preserve this shared relationship.
6. Decoder Block × 14
Each of the fourteen blocks uses pre-normalization and two residual sublayers in this exact order:
- RMSNorm on the residual stream.
- Causal multi-head self-attention with RoPE on queries and keys.
- Attention output projection followed by residual addition.
- Second RMSNorm.
- SwiGLU feed-forward transformation.
- MLP down projection followed by residual addition.
Residual-stream additions should remain numerically stable; main matrix multiplications use BF16, while accumulation and sensitive reductions may use FP32 where PyTorch kernels provide it.
7. Causal Multi-Head Self-Attention
Property | Value |
|---|---|
Query heads | 12 |
Key/value heads | 12 — standard multi-head attention |
Head dimension | 64 |
Model width | 12 × 64 = 768 |
Q projection | 768 → 768 |
K projection | 768 → 768 |
V projection | 768 → 768 |
Output projection | 768 → 768 |
Attention mask | Strict causal mask |
Kernel | PyTorch scaled-dot-product attention; Flash-compatible |
The attention score for a query and key is scaled by 1/√64 = 1/8 before the softmax. RoPE rotates query and key coordinates according to token position. Values are not rotated. During inference, keys and values from previous tokens are stored in a per-layer cache.
8. Rotary Positional Encoding
RoPE setting | Frozen value |
|---|---|
Applied to | Queries and keys |
Rotary dimension | All 64 dimensions of each head |
Base theta | 10,000 |
Trained maximum context | 2,048 tokens |
Implementation | Precomputed/cached sin and cos frequencies |
Long-context extension | Not assumed; requires separate evaluation and version |
9. RMSNorm
Every block contains two RMSNorm layers and the network ends with one final RMSNorm. RMSNorm has one learned scale parameter per hidden dimension and no bias. Epsilon is fixed at 1e-5. Pre-normalization keeps the residual path clean and supports stable deep optimization.
10. SwiGLU Feed-Forward Network
The feed-forward sublayer uses two parallel 768 → 2,048 projections. One branch is passed through SiLU and multiplied elementwise by the other branch. A 2,048 → 768 down projection returns the result to the residual width. All three linear transformations are bias-free.
Projection | Shape | Parameters per block |
|---|---|---|
Gate | 768 × 2,048 | 1,572,864 |
Up | 768 × 2,048 | 1,572,864 |
Down | 2,048 × 768 | 1,572,864 |
Total SwiGLU weights | 4,718,592 |
11. Final Normalization and Output
After block 14, the model applies final RMSNorm and multiplies the normalized hidden states by the transposed token-embedding matrix. The result has shape batch × sequence × 32,000. Cross-entropy loss compares these logits with the next-token targets. Padding or deliberately masked positions must use ignore_index and must not contribute to the loss.
12. Exact Parameter Budget
Component | Formula | Parameters |
|---|---|---|
Tied token embedding / LM head | 32,000 × 768 | 24,576,000 |
Attention per block | 4 × 768 × 768 | 2,359,296 |
SwiGLU per block | 3 × 768 × 2,048 | 4,718,592 |
Two RMSNorms per block | 2 × 768 | 1,536 |
One decoder block | Sum of block components | 7,079,424 |
Fourteen decoder blocks | 14 × 7,079,424 | 99,111,936 |
Final RMSNorm | 768 | 768 |
TOTAL | 123,688,704 |
13. Parameter Allocation Chart
Figure 2. Exact parameter allocation. Norm scales are too small to appear prominently beside the matrix weights.
The model name “125M” is a size-class label. The exact unique trainable parameter count is 123,688,704. Distorting dimensions merely to reach exactly 125,000,000 would provide no architectural benefit.
14. English Tokenizer Specification
Tokenizer property | Final rule |
|---|---|
Family | Byte-level BPE |
Vocabulary size | 32,000 tokens |
Training language | English only |
Coverage | Byte fallback guarantees representability |
Normalization | Minimal; preserve case, punctuation, numbers and meaningful Unicode |
Required special tokens | PAD=0, BOS=1, EOS=2, DOC_SEP=3 |
Training sample | Representative sample from every approved data category |
Versioning | Vocabulary, merges, IDs and hash immutable after pretraining begins |
Tokenizer QA must measure round-trip decoding, average tokens per English word, code and punctuation handling, number/date splitting, whitespace behavior, special-token collisions and stability across long documents.
15. Pretraining Dataset Architecture
Figure 3. Planned English-only mixture for the 2.5-billion-token training split.
Data category | Share | Training tokens |
|---|---|---|
Quality web and educational text | 45% | 1.125B |
Licensed books and reference text | 20% | 0.500B |
STEM and research text | 15% | 0.375B |
Approved code with English documentation | 10% | 0.250B |
News and factual writing | 5% | 0.125B |
Stories and dialogue | 5% | 0.125B |
TOTAL | 100% | 2.500B |
15.1 Data Quality and Governance
- Use only sources with a documented license or permitted usage basis.
- Record source name, snapshot/version, retrieval date, document ID and processing history.
- Normalize encoding and remove corrupt, spam, boilerplate and extremely low-quality records.
- Remove exact duplicates and perform document-level near-duplicate detection before splitting.
- Filter credential dumps, secrets and sensitive personal data where feasible.
- Create train, validation and test splits at document level before token packing.
- Insert EOS or DOC_SEP between documents; never concatenate boundaries silently.
- Save shard manifests, counts, checksums and deterministic processing configuration.
16. Data Storage and Packing
Artifact | Purpose |
|---|---|
tokenizer.json / vocab / merges | Frozen token mapping |
train shards | Packed 2,048-token training sequences |
validation shards | Fixed held-out sequences used throughout training |
test shards | Untouched final evaluation data |
manifest.json | Source proportions, shard counts and hashes |
dataset_card.md | Provenance, licenses, processing and limitations |
The 32,000-token vocabulary fits in uint16 storage. A raw 2.5-billion-token stream occupies about 5 GB as uint16 before indexes, document metadata, validation/test sets and backups. Shards should be sized for sequential reading and fast checkpoint-resume positioning.
17. Training Hardware and Precision
Training component | Frozen value |
|---|---|
GPU | NVIDIA A100 40 GB |
Framework | PyTorch |
Primary precision | BF16 autocast |
Matrix kernels | TF32/BF16 Tensor Core paths where appropriate |
Attention | PyTorch SDPA / Flash-compatible kernel |
Optimizer implementation | Fused AdamW when validated |
Compilation | torch.compile only after correctness baseline passes |
Memory strategy | Activation checkpointing only if pilot memory requires it |
Throughput target: 250,000 training tokens per second is a performance goal, not an architectural guarantee. The 500-step pilot must measure the achieved throughput before the full-run schedule is accepted. |
18. Full Training Configuration
Hyperparameter | Frozen starting value |
|---|---|
Objective | Autoregressive next-token cross entropy |
Optimizer | AdamW |
Betas | β₁=0.9, β₂=0.95 |
Optimizer epsilon | 1e-8 |
Peak learning rate | 3e-4 |
Final learning rate | 3e-5 |
Schedule | Linear warm-up then cosine decay |
Warm-up | 100 optimizer updates |
Weight decay | 0.1; exclude RMSNorm scales and embeddings |
Gradient clipping | Global norm 1.0 |
Dropout | 0.0 |
Sequence length | 2,048 |
Micro-batch | 8 full sequences, subject to pilot memory test |
Gradient accumulation | 32 |
Global tokens/update | 524,288 |
Target optimizer updates | 4,769 |
Actual scheduled tokens | 2,500,329,472 |
Evaluation cadence | Every 100 updates |
Checkpoint cadence | Every 250 updates; permanent milestones every 1,000 |
At 524,288 non-padding tokens per update, 4,769 optimizer updates process 2,500,329,472 tokens, slightly exceeding the 2.5-billion target. The final partial batch may instead be truncated if the sampler supports exact token accounting.
19. Pilot and Go/No-Go Gate
Pilot check | Pass condition |
|---|---|
Forward/backward correctness | Finite loss; expected tensor shapes; strict causal behavior |
Memory | No OOM with safety margin for evaluation and checkpointing |
Throughput | Measured tokens/second recorded; data loader does not starve GPU |
Resume | Weights, optimizer, scheduler, RNG and data position reproduce correctly |
Numerics | No unexplained NaN/Inf; gradient norms finite |
Tiny overfit | Small controlled sample can be overfit to verify learning |
20. Checkpoint and Reproducibility Contract
- Save model weights in SafeTensors for distribution.
- Save optimizer, scheduler, scaler state if used, global step, tokens seen and RNG states for training resume.
- Store the exact model configuration and tokenizer beside every checkpoint.
- Record dataset-manifest version, shard hashes, source proportions, code commit and package versions.
- Maintain best-validation, latest-resumable and permanent milestone checkpoints.
- Verify exact resume with a deterministic short test before full pretraining.
21. Validation and Base-Model Evaluation
Evaluation area | Required measurement |
|---|---|
Language modeling | Held-out loss and perplexity overall and by domain |
Generation | Grammar, repetition, topic drift, EOS behavior and context handling |
English quality | Reading comprehension, completion and age-appropriate language tasks |
Factuality | Closed-book factual prompts with explicit hallucination scoring |
Reasoning | Small arithmetic, logic and multi-step tasks; limitations reported honestly |
Code | Syntax completion and basic code-generation tests |
Contamination | Exact and near-duplicate overlap checks against evaluation sets |
Efficiency | Tokens/s, GPU memory, latency and KV-cache correctness |
Benchmark targets are not fabricated in advance. The pilot and early checkpoints establish credible baselines; release gates then require measurable improvement and no unexplained late-run regression.
22. Instruction Tuning and Chat Model
The pretrained checkpoint is a base next-token model, not yet a reliable assistant. Production conversational behavior is created in a separate stage so the original base model remains preserved.
- Train on a carefully licensed English instruction/conversation dataset.
- Define and version one chat template with explicit system, user and assistant boundaries.
- Reserve or reuse control tokens consistently; never remap pretrained token IDs.
- Evaluate instruction following, summarization, question answering, refusal behavior and hallucination.
- Compare general-language loss before and after tuning to detect catastrophic degradation.
- Optionally run preference optimization only when reliable preference data and evaluation are available.
23. Production Inference Architecture
Serving feature | Requirement |
|---|---|
Model loading | Configuration-driven strict loading and tokenizer-hash compatibility |
KV cache | Per-layer K/V cache with reference-vs-cached-logit tests |
Precision | BF16/FP16 reference; INT8 and INT4 only after quality comparison |
Batching | Dynamic batching for concurrent requests |
Sampling | Temperature, top-p, top-k, repetition penalty and deterministic seed |
Streaming | Incremental token streaming |
Stop handling | EOS plus application-defined stop sequences |
Limits | Server-enforced context and maximum-new-token limits |
API | Validated inference endpoint, health check and model-version endpoint |
Observability | Latency, tokens/s, queue time, memory, errors and request counts |
24. Reliability, Safety and Security
- Validate all request fields and reject oversized or malformed inputs.
- Apply authentication, authorization, rate limiting, timeouts and concurrency limits at the API layer.
- Do not log sensitive prompt content by default; define retention and redaction policy.
- Test prompt injection, unsafe requests, memorization, data leakage and denial-of-service patterns.
- Document that a 125M model has limited knowledge and reasoning and can hallucinate.
- Keep dependency versions pinned, scan container images and restrict checkpoint write permissions.
- Release model and data cards covering intended use, excluded use, data categories, evaluation and limitations.
25. Production-Ready Acceptance Gates
Gate | Pass condition |
|---|---|
Correctness | Unit/integration tests pass for masking, RoPE, RMSNorm, SwiGLU, tying, serialization and KV cache. |
Training stability | No unresolved NaN/Inf; losses and gradients monitored; exact resume verified. |
Data integrity | No train/validation/test document overlap; deduplication and provenance audit complete. |
Model quality | Held-out and generation results beat documented baselines without severe degeneration. |
Instruction model | Chat template fixed; instruction and safety evaluation completed. |
Inference | Reference and cached logits match tolerance; limits, streaming and batching tested. |
Optimization | Every quantized build compared against reference quality and latency. |
Documentation | Model card, data card, licenses, hashes, configuration and usage examples complete. |
26. Implementation Module Layout
Module | Responsibility |
|---|---|
config.py | Frozen model and training configuration |
tokenizer/ | Tokenizer training, encode/decode and QA |
model.py | RMSNorm, RoPE, attention, SwiGLU, block and W-1.1 model |
data.py | Shard reading, sequence packing, sampling and resume position |
train.py | BF16 training loop, accumulation, schedule, logging and evaluation |
checkpoint.py | Safe save/resume and state validation |
evaluate.py | Loss, perplexity and benchmark adapters |
generate.py | KV-cached generation and sampling controls |
serve.py | Production API, streaming, validation and observability |
tests/ | Shapes, masking, RoPE, tying, resume, cache and tiny-overfit tests |
27. Frozen Configuration Contract
Key | Value |
|---|---|
vocab_size | 32000 |
d_model | 768 |
n_layers | 14 |
n_heads | 12 |
head_dim | 64 |
ffn_hidden_size | 2048 |
max_seq_len | 2048 |
rope_theta | 10000.0 |
rms_norm_eps | 1e-5 |
attention_type | causal_mha |
activation | swiglu |
tie_word_embeddings | true |
linear_bias | false |
dropout | 0.0 |
parameter_count | 123688704 |
training_tokens | 2500000000 |
framework | pytorch |
training_gpu | nvidia_a100_40gb |
precision | bf16 |
28. Final Frozen Blueprint
Architecture: 32K English byte-level BPE → 768-dimensional tied embeddings → 14 × [RMSNorm → 12-head causal MHA with RoPE → residual → RMSNorm → 2,048-wide SwiGLU → residual] → final RMSNorm → tied 32K language-model head → next-token logits. |
Final item | Frozen decision |
|---|---|
Language | English only |
Model type | Decoder-only autoregressive Transformer |
Exact parameters | 123,688,704 |
Training tokens | 2.5 billion |
Context | 2,048 tokens |
Framework | PyTorch |
GPU | NVIDIA A100 40 GB |
Precision | BF16 |
Base checkpoint | Preserved before instruction tuning |
Production path | Pretrain → evaluate → instruction tune → safety test → optimize → serve |
29. Research Basis
The design is informed by the following primary research. These references justify mechanisms and scaling choices; they do not guarantee a particular W-1.1 benchmark score.
- Vaswani et al. (2017), “Attention Is All You Need.”
- Radford et al. (2019), “Language Models are Unsupervised Multitask Learners.”
- Su et al. (2021), “RoFormer: Enhanced Transformer with Rotary Position Embedding.”
- Zhang and Sennrich (2019), “Root Mean Square Layer Normalization.”
- Shazeer (2020), “GLU Variants Improve Transformer.”
- Dao et al. (2022), “FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.”
- Hoffmann et al. (2022), “Training Compute-Optimal Large Language Models.”
Final Conclusion
W-1.1-125M v1.0 is now defined as an English-only, decoder-only PyTorch language model with 123,688,704 trainable parameters and a 2.5-billion-token pretraining budget. Its architecture combines RoPE, RMSNorm, SwiGLU, tied embeddings, causal attention and KV-cached inference. Training uses BF16 on an NVIDIA A100 40 GB, with a mandatory pilot before the full run. Production readiness is achieved only after data governance, reproducible pretraining, evaluation, instruction tuning, safety testing, optimization, API hardening and complete documentation have all passed their acceptance gates.