configuration_arcee.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  2. # This file was automatically generated from src/transformers/models/arcee/modular_arcee.py.
  3. # Do NOT edit this file manually as any edits will be overwritten by the generation of
  4. # the file from the modular. If any change should be done, please apply the change to the
  5. # modular_arcee.py file directly. One of our CI enforces this.
  6. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  7. # Copyright 2025 Arcee AI and the HuggingFace Inc. team. All rights reserved.
  8. #
  9. # Licensed under the Apache License, Version 2.0 (the "License");
  10. # you may not use this file except in compliance with the License.
  11. # You may obtain a copy of the License at
  12. #
  13. # http://www.apache.org/licenses/LICENSE-2.0
  14. #
  15. # Unless required by applicable law or agreed to in writing, software
  16. # distributed under the License is distributed on an "AS IS" BASIS,
  17. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. # See the License for the specific language governing permissions and
  19. # limitations under the License.
  20. from huggingface_hub.dataclasses import strict
  21. from transformers.utils import auto_docstring
  22. from ...configuration_utils import PreTrainedConfig
  23. from ...modeling_rope_utils import RopeParameters
  24. @auto_docstring(checkpoint="arcee-ai/AFM-4.5B")
  25. @strict
  26. class ArceeConfig(PreTrainedConfig):
  27. r"""
  28. ```python
  29. >>> from transformers import ArceeModel, ArceeConfig
  30. >>> # Initializing an Arcee AFM-4.5B-Base style configuration
  31. >>> configuration = ArceeConfig()
  32. >>> # Initializing a model from the AFM-4.5B-Base style configuration
  33. >>> model = ArceeModel(configuration)
  34. >>> # Accessing the model configuration
  35. >>> configuration = model.config
  36. ```"""
  37. model_type = "arcee"
  38. keys_to_ignore_at_inference = ["past_key_values"]
  39. base_model_tp_plan = {
  40. "layers.*.self_attn.q_proj": "colwise",
  41. "layers.*.self_attn.k_proj": "colwise",
  42. "layers.*.self_attn.v_proj": "colwise",
  43. "layers.*.self_attn.o_proj": "rowwise",
  44. "layers.*.mlp.up_proj": "colwise",
  45. "layers.*.mlp.down_proj": "rowwise",
  46. }
  47. base_model_pp_plan = {
  48. "embed_tokens": (["input_ids"], ["inputs_embeds"]),
  49. "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
  50. "norm": (["hidden_states"], ["hidden_states"]),
  51. }
  52. vocab_size: int = 32000
  53. hidden_size: int = 2560
  54. intermediate_size: int = 18432
  55. num_hidden_layers: int = 32
  56. num_attention_heads: int = 32
  57. num_key_value_heads: int | None = None
  58. hidden_act: str = "relu2"
  59. max_position_embeddings: int = 4096
  60. initializer_range: float = 0.02
  61. rms_norm_eps: float = 1e-5
  62. use_cache: bool = True
  63. pad_token_id: int | None = None
  64. bos_token_id: int | None = 128000
  65. eos_token_id: int | list[int] | None = 128001
  66. tie_word_embeddings: bool = False
  67. rope_parameters: RopeParameters | dict | None = None
  68. attention_bias: bool = False
  69. attention_dropout: float | int = 0.0
  70. mlp_bias: bool = False
  71. head_dim: int | None = None
  72. def __post_init__(self, **kwargs):
  73. if self.head_dim is None:
  74. self.head_dim = self.hidden_size // self.num_attention_heads
  75. if self.num_key_value_heads is None:
  76. self.num_key_value_heads = self.num_attention_heads
  77. super().__post_init__(**kwargs)
  78. def validate_architecture(self):
  79. """Part of `@strict`-powered validation. Validates the architecture of the config."""
  80. if self.hidden_size % self.num_attention_heads != 0:
  81. raise ValueError(
  82. f"The hidden size ({self.hidden_size}) is not a multiple of the number of attention "
  83. f"heads ({self.num_attention_heads})."
  84. )
  85. __all__ = ["ArceeConfig"]