KitsuVp commited on
Commit
7c7f806
·
verified ·
1 Parent(s): 6e488b2

Update configuration_neollm.py

Browse files
Files changed (1) hide show
  1. configuration_neollm.py +45 -0
configuration_neollm.py CHANGED
@@ -171,6 +171,23 @@ class NeoLLMConfig(PretrainedConfig):
171
  periodicities in the feature space.
172
  dropout_rate (:obj:`float`, *optional*, defaults to 0.1):
173
  General dropout probability for attention outputs and MLP states.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  use_embedding_input_norm (:obj:`bool`, *optional*, defaults to ``True``):
175
  Controls only the first pre-attention normalisation applied to the
176
  raw embedding stream. When ``True``, layer 0 instantiates and applies
@@ -638,6 +655,9 @@ class NeoLLMConfig(PretrainedConfig):
638
  fan_ratio=0.125,
639
  fan_ratio_ffn=0.0625,
640
  dropout_rate=0.1,
 
 
 
641
  # ── Embedding input normalization ─────────────────────────────────
642
  use_embedding_input_norm=True,
643
  # ── Leviathan continuous token generator ──────────────────────────
@@ -703,6 +723,27 @@ class NeoLLMConfig(PretrainedConfig):
703
  )
704
  tie_word_embeddings = False
705
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
706
  # ── JTok-M / generator dependency ─────────────────────────────────
707
  if use_jtokm and not use_token_generator:
708
  raise ValueError(
@@ -906,6 +947,10 @@ class NeoLLMConfig(PretrainedConfig):
906
  # ── Regularization ────────────────────────────────────────────────
907
  self.dropout_rate = dropout_rate
908
 
 
 
 
 
909
  # ── Embedding input normalization ─────────────────────────────────
910
  # True preserves the previous layer-0 pre-norm path:
911
  # embeddings -> SeeDNorm -> LNS -> attention.
 
171
  periodicities in the feature space.
172
  dropout_rate (:obj:`float`, *optional*, defaults to 0.1):
173
  General dropout probability for attention outputs and MLP states.
174
+ use_learnable_multipliers (:obj:`bool`, *optional*, defaults to ``True``):
175
+ Enable Learnable Multipliers on the matrix layers where the
176
+ Velikanov et al. placement recommends them. When ``True``, the
177
+ model keeps row multipliers on ``q_proj`` and MLP ``gate_proj``,
178
+ row+column multipliers on dense ``o_proj`` and MLP ``down_proj``,
179
+ and no extra multipliers on ``k_proj``, ``v_proj`` or ``up_proj``.
180
+ When ``False``, those multiplier parameters are not instantiated
181
+ and the wrapped linear layers behave as ordinary ``nn.Linear``
182
+ modules.
183
+ use_embedding_multipliers (:obj:`bool`, *optional*, defaults to ``True``):
184
+ Add vocabulary-row and hidden-channel multipliers to the standard
185
+ ``nn.Embedding`` matrix, matching the Learnable Multipliers paper's
186
+ recommendation for embeddings. This flag is effective only when
187
+ ``use_learnable_multipliers=True``, ``use_token_generator=False``
188
+ and ``tie_word_embeddings=False``. It is intentionally disabled for
189
+ tied input/output embeddings and for the Leviathan generator path so
190
+ it does not break parameter sharing or wrap a non-matrix generator.
191
  use_embedding_input_norm (:obj:`bool`, *optional*, defaults to ``True``):
192
  Controls only the first pre-attention normalisation applied to the
193
  raw embedding stream. When ``True``, layer 0 instantiates and applies
 
655
  fan_ratio=0.125,
656
  fan_ratio_ffn=0.0625,
657
  dropout_rate=0.1,
658
+ # ── Learnable Multipliers (Velikanov et al., 2026) ─────────────────
659
+ use_learnable_multipliers=False,
660
+ use_embedding_multipliers=False,
661
  # ── Embedding input normalization ─────────────────────────────────
662
  use_embedding_input_norm=True,
663
  # ── Leviathan continuous token generator ──────────────────────────
 
723
  )
724
  tie_word_embeddings = False
725
 
726
+ # ── Embedding multiplier applicability ─────────────────────────────
727
+ if use_embedding_multipliers:
728
+ if not use_learnable_multipliers:
729
+ logger.warning(
730
+ "`use_embedding_multipliers=True` is inactive because "
731
+ "`use_learnable_multipliers=False`. No embedding multiplier "
732
+ "parameters will be instantiated."
733
+ )
734
+ elif use_token_generator:
735
+ logger.warning(
736
+ "`use_embedding_multipliers=True` is inactive because "
737
+ "`use_token_generator=True` replaces the standard embedding "
738
+ "matrix with LeviathanGenerator."
739
+ )
740
+ elif tie_word_embeddings:
741
+ logger.warning(
742
+ "`use_embedding_multipliers=True` is inactive because "
743
+ "`tie_word_embeddings=True`; embedding multipliers would "
744
+ "break clean input/output parameter sharing."
745
+ )
746
+
747
  # ── JTok-M / generator dependency ─────────────────────────────────
748
  if use_jtokm and not use_token_generator:
749
  raise ValueError(
 
947
  # ── Regularization ────────────────────────────────────────────────
948
  self.dropout_rate = dropout_rate
949
 
950
+ # ── Learnable Multipliers ─────────────────────────────────────────
951
+ self.use_learnable_multipliers = use_learnable_multipliers
952
+ self.use_embedding_multipliers = use_embedding_multipliers
953
+
954
  # ── Embedding input normalization ─────────────────────────────────
955
  # True preserves the previous layer-0 pre-norm path:
956
  # embeddings -> SeeDNorm -> LNS -> attention.