Nessim-48M-Base / configuration_nessim.py
Nessim's picture
Nessim-48M-Base: final checkpoint of the from-scratch run (step 123,999, 26.4B tokens)
4acaaff verified
Raw History Blame Contribute Delete
3.07 kB
"""Configuration of Nessim-48M-Base, a KLM 1.6 based model with a looped core and four token-level programs.
Derived from configuration_klm.py of KLM 1.6 (Apache-2.0, https://huggingface.co/MinimaLabs/KLM-1.6). Changes: the
24 unshared layers become `n_prelude` + `n_core` + `n_coda` layers with the core applied `loops` times, and the
fields of the four programs (previous-token and induction inputs, copy pointer, distance biases) are added.
This file ships inside the model directory and must not import anything from the training repository.
"""
from __future__ import annotations
from transformers import PretrainedConfig
class NessimConfig(PretrainedConfig):
model_type = "nessim"
def __init__(
self,
vocab_size: int = 4160,
hidden_size: int = 512,
n_prelude: int = 2,
n_core: int = 6,
n_coda: int = 2,
loops: int = 4,
attention_every: int = 4,
gdn_heads: int = 4,
gdn_head_dim: int = 128,
num_attention_heads: int = 8,
num_key_value_heads: int = 4,
intermediate_size: int = 1536,
max_position_embeddings: int = 2048,
rope_theta: float = 10000.0,
n_bigrams: int = 125000,
n_trigrams: int = 38000,
ngram_dim: int = 32,
rms_norm_eps: float = 1e-6,
gdn_norm_eps: float = 1e-5,
decay_floor: float = -20.0,
previous_tokens: int = 2,
induction_inputs: bool = True,
front_rank: int = 32,
copy_pointer: bool = True,
pointer_chunk: int = 128,
distance_bias: bool = True,
bos_token_id: int = 1,
eos_token_id: int = 2,
pad_token_id: int = 0,
tie_word_embeddings: bool = True,
**kwargs,
):
self.vocab_size = vocab_size
self.hidden_size = hidden_size
self.n_prelude = n_prelude
self.n_core = n_core
self.n_coda = n_coda
self.loops = loops
self.num_hidden_layers = n_prelude + n_core + n_coda
self.attention_every = attention_every
self.gdn_heads = gdn_heads
self.gdn_head_dim = gdn_head_dim
self.num_attention_heads = num_attention_heads
self.num_key_value_heads = num_key_value_heads
self.intermediate_size = intermediate_size
self.max_position_embeddings = max_position_embeddings
self.rope_theta = rope_theta
self.n_bigrams = n_bigrams
self.n_trigrams = n_trigrams
self.ngram_dim = ngram_dim
self.rms_norm_eps = rms_norm_eps
self.gdn_norm_eps = gdn_norm_eps
self.decay_floor = decay_floor
self.previous_tokens = previous_tokens
self.induction_inputs = induction_inputs
self.front_rank = front_rank
self.copy_pointer = copy_pointer
self.pointer_chunk = pointer_chunk
self.distance_bias = distance_bias
super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id,
pad_token_id=pad_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs)