Upload model/config.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
from dataclasses import dataclass
@dataclass
class ModelConfig:
vocab_size: int = 50000
hidden_size: int = 1024
num_layers: int = 18
num_heads: int = 16
intermediate_size: int = 2816
max_seq_len: int = 512
use_rope: bool = True
rope_theta: float = 10000.0
causal: bool = True
norm_eps: float = 1e-5
activation: str = "silu"
dropout: float = 0.0
initializer_range: float = 0.02
use_bias: bool = False
pad_token_id: int = 0
bos_token_id: int = 1
eos_token_id: int = 2
unk_token_id: int = 3
# Trade compute for memory: recompute activations
# inside each block instead of storing them.
# Essential for fitting the 500M model on an
# 8 GB laptop GPU.
gradient_checkpointing: bool = False
def neo_500m() -> ModelConfig:
"""
Production configuration (~500.8M params).
Parameter math (tied embeddings):
embedding: 50,000 x 1024 = 51.20M
per block: 4*1024^2 (attention) = 4.19M
+ 3*1024*2816 (SwiGLU) = 8.65M
+ 2*1024 (norms) = 0.002M
-> 12.85M per block
35 blocks = 449.65M
total = 500.85M
"""
return ModelConfig(
vocab_size=50000,
hidden_size=1024,
num_layers=35,
num_heads=16,
intermediate_size=2816,
max_seq_len=512,
)
model/config.pyAdded+57