dropout-decay / src /dropout_decay /specs /model_spec.py
Mandeep Sidhu
Refactor experiment pipeline and add regime paper
e7a7275
Raw
History Blame Contribute Delete
1.43 kB
"""
Derived from Andrej Karpathy's nanochat project.
MIT License
Copyright (c) 2025 Andrej Karpathy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"""
from __future__ import annotations
from dataclasses import dataclass
from dropout_decay.models import GPTConfig
@dataclass(frozen=True)
class ModelSpec:
name: str
n_layer: int
n_head: int
n_embd: int
def config(self, vocab_size: int, block_size: int, dropout: float) -> GPTConfig:
return GPTConfig(
block_size=block_size,
vocab_size=vocab_size,
n_layer=self.n_layer,
n_head=self.n_head,
n_embd=self.n_embd,
dropout=dropout,
)
def to_dict(self) -> dict[str, int | str]:
return {
"model_name": self.name,
"n_layer": self.n_layer,
"n_head": self.n_head,
"n_embd": self.n_embd,
}