configuration_helium.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright 2024 The Kyutai and HuggingFace Inc. teams. All rights reserved.
  2. #
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...modeling_rope_utils import RopeParameters
  18. from ...utils import auto_docstring
  19. @auto_docstring(checkpoint="kyutai/helium-1-preview")
  20. @strict
  21. class HeliumConfig(PreTrainedConfig):
  22. r"""
  23. Example:
  24. ```python
  25. >>> from transformers import HeliumModel, HeliumConfig
  26. >>> # Initializing a Helium 2b style configuration
  27. >>> configuration = HeliumConfig()
  28. >>> # Initializing a model from the Helium 2b style configuration
  29. >>> model = HeliumModel(configuration)
  30. >>> # Accessing the model configuration
  31. >>> configuration = model.config
  32. ```"""
  33. model_type = "helium"
  34. keys_to_ignore_at_inference = ["past_key_values"]
  35. default_theta = 100000.0
  36. base_model_tp_plan = {
  37. "layers.*.self_attn.q_proj": "colwise",
  38. "layers.*.self_attn.k_proj": "colwise",
  39. "layers.*.self_attn.v_proj": "colwise",
  40. "layers.*.self_attn.o_proj": "rowwise",
  41. "layers.*.mlp.gate_proj": "colwise",
  42. "layers.*.mlp.up_proj": "colwise",
  43. "layers.*.mlp.down_proj": "rowwise",
  44. }
  45. base_model_pp_plan = {
  46. "embed_tokens": (["input_ids"], ["inputs_embeds"]),
  47. "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
  48. "norm": (["hidden_states"], ["hidden_states"]),
  49. }
  50. vocab_size: int = 48000
  51. hidden_size: int = 2560
  52. intermediate_size: int = 7040
  53. num_hidden_layers: int = 24
  54. num_attention_heads: int = 20
  55. num_key_value_heads: int = 20
  56. head_dim: int = 128
  57. hidden_act: str = "silu"
  58. attention_dropout: float | int = 0.0
  59. max_position_embeddings: int = 4096
  60. initializer_range: float = 0.02
  61. rms_norm_eps: float = 1e-8
  62. use_cache: bool = True
  63. tie_word_embeddings: bool = False
  64. rope_parameters: RopeParameters | dict | None = None
  65. pad_token_id: int | None = 3
  66. eos_token_id: int | list[int] | None = 2
  67. bos_token_id: int | None = 1
  68. attention_bias: bool = False
  69. mlp_bias: bool = False
  70. __all__ = ["HeliumConfig"]