configuration_eurobert.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  2. # This file was automatically generated from src/transformers/models/eurobert/modular_eurobert.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_eurobert.py file directly. One of our CI enforces this.
  6. # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
  7. # Copyright 2025 Nicolas Boizard, Duarte M. Alves, Hippolyte Gisserot-Boukhlef and the EuroBert team. All rights reserved.
  8. #
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License");
  11. # you may not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing, software
  17. # distributed under the License is distributed on an "AS IS" BASIS,
  18. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. # See the License for the specific language governing permissions and
  20. # limitations under the License.
  21. from ...configuration_utils import strict
  22. from ...modeling_rope_utils import RopeParameters
  23. from ...utils import auto_docstring
  24. from ..llama import LlamaConfig
  25. @auto_docstring(checkpoint="EuroBERT/EuroBERT-210m")
  26. @strict
  27. class EuroBertConfig(LlamaConfig):
  28. r"""
  29. mask_token_id (`int`, *optional*, defaults to 128002):
  30. Mask token id.
  31. classifier_pooling (`str`, *optional*, defaults to `"late"`):
  32. The pooling strategy to use for the classifier. Can be one of ['bos', 'mean', 'late'].
  33. ```python
  34. >>> from transformers import EuroBertModel, EuroBertConfig
  35. >>> # Initializing a EuroBert eurobert-base style configuration
  36. >>> configuration = EuroBertConfig()
  37. >>> # Initializing a model from the eurobert-base style configuration
  38. >>> model = EuroBertModel(configuration)
  39. >>> # Accessing the model configuration
  40. >>> configuration = model.config
  41. ```"""
  42. model_type = "eurobert"
  43. vocab_size: int = 128256
  44. hidden_size: int = 768
  45. intermediate_size: int = 3072
  46. num_hidden_layers: int = 12
  47. num_attention_heads: int = 12
  48. num_key_value_heads: int | None = None
  49. hidden_act: str = "silu"
  50. max_position_embeddings: int = 8192
  51. initializer_range: float = 0.02
  52. rms_norm_eps: float = 1e-05
  53. bos_token_id: int | None = 128000
  54. eos_token_id: int | list[int] | None = 128001
  55. pad_token_id: int | None = 128001
  56. mask_token_id: int = 128002
  57. pretraining_tp: int = 1
  58. tie_word_embeddings: bool = False
  59. rope_parameters: RopeParameters | dict | None = None
  60. attention_bias: bool = False
  61. attention_dropout: int | float = 0.0
  62. mlp_bias: bool = False
  63. head_dim: int | None = None
  64. classifier_pooling: str = "late"
  65. def __post_init__(self, **kwargs):
  66. if self.num_key_value_heads is None:
  67. self.num_key_value_heads = self.num_attention_heads
  68. super().__post_init__(**kwargs)
  69. __all__ = ["EuroBertConfig"]