configuration_albert.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
  2. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
  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. """ALBERT model configuration"""
  16. from huggingface_hub.dataclasses import strict
  17. from ...configuration_utils import PreTrainedConfig
  18. from ...utils import auto_docstring
  19. @auto_docstring(checkpoint="albert/albert-xxlarge-v2")
  20. @strict
  21. class AlbertConfig(PreTrainedConfig):
  22. r"""
  23. num_hidden_groups (`int`, *optional*, defaults to 1):
  24. Number of groups for the hidden layers, parameters in the same group are shared.
  25. inner_group_num (`int`, *optional*, defaults to 1):
  26. The number of inner repetition of attention and ffn.
  27. Examples:
  28. ```python
  29. >>> from transformers import AlbertConfig, AlbertModel
  30. >>> # Initializing an ALBERT-xxlarge style configuration
  31. >>> albert_xxlarge_configuration = AlbertConfig()
  32. >>> # Initializing an ALBERT-base style configuration
  33. >>> albert_base_configuration = AlbertConfig(
  34. ... hidden_size=768,
  35. ... num_attention_heads=12,
  36. ... intermediate_size=3072,
  37. ... )
  38. >>> # Initializing a model (with random weights) from the ALBERT-base style configuration
  39. >>> model = AlbertModel(albert_xxlarge_configuration)
  40. >>> # Accessing the model configuration
  41. >>> configuration = model.config
  42. ```"""
  43. model_type = "albert"
  44. vocab_size: int = 30000
  45. embedding_size: int = 128
  46. hidden_size: int = 4096
  47. num_hidden_layers: int = 12
  48. num_hidden_groups: int = 1
  49. num_attention_heads: int = 64
  50. intermediate_size: int = 16384
  51. inner_group_num: int = 1
  52. hidden_act: str = "gelu_new"
  53. hidden_dropout_prob: int | float = 0.0
  54. attention_probs_dropout_prob: int | float = 0.0
  55. max_position_embeddings: int = 512
  56. type_vocab_size: int = 2
  57. initializer_range: float = 0.02
  58. layer_norm_eps: float = 1e-12
  59. classifier_dropout_prob: int | float = 0.1
  60. pad_token_id: int | None = 0
  61. bos_token_id: int | None = 2
  62. eos_token_id: int | list[int] | None = 3
  63. tie_word_embeddings: bool = True
  64. __all__ = ["AlbertConfig"]