configuration_squeezebert.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright 2020 The SqueezeBert authors and The HuggingFace Inc. team.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """SqueezeBERT model configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="squeezebert/squeezebert-uncased")
  19. @strict
  20. class SqueezeBertConfig(PreTrainedConfig):
  21. r"""
  22. q_groups (`int`, *optional*, defaults to 4):
  23. The number of groups in Q layer.
  24. k_groups (`int`, *optional*, defaults to 4):
  25. The number of groups in K layer.
  26. v_groups (`int`, *optional*, defaults to 4):
  27. The number of groups in V layer.
  28. post_attention_groups (`int`, *optional*, defaults to 1):
  29. The number of groups in the first feed forward network layer.
  30. intermediate_groups (`int`, *optional*, defaults to 4):
  31. The number of groups in the second feed forward network layer.
  32. output_groups (`int`, *optional*, defaults to 4):
  33. The number of groups in the third feed forward network layer.
  34. Examples:
  35. ```python
  36. >>> from transformers import SqueezeBertConfig, SqueezeBertModel
  37. >>> # Initializing a SqueezeBERT configuration
  38. >>> configuration = SqueezeBertConfig()
  39. >>> # Initializing a model (with random weights) from the configuration above
  40. >>> model = SqueezeBertModel(configuration)
  41. >>> # Accessing the model configuration
  42. >>> configuration = model.config
  43. ```
  44. """
  45. model_type = "squeezebert"
  46. vocab_size: int = 30522
  47. hidden_size: int = 768
  48. num_hidden_layers: int = 12
  49. num_attention_heads: int = 12
  50. intermediate_size: int = 3072
  51. hidden_act: str = "gelu"
  52. hidden_dropout_prob: float | int = 0.1
  53. attention_probs_dropout_prob: float | int = 0.1
  54. max_position_embeddings: int = 512
  55. type_vocab_size: int = 2
  56. initializer_range: float = 0.02
  57. layer_norm_eps: float = 1e-12
  58. pad_token_id: int | None = 0
  59. bos_token_id: int | None = None
  60. eos_token_id: int | list[int] | None = None
  61. embedding_size: int = 768
  62. q_groups: int = 4
  63. k_groups: int = 4
  64. v_groups: int = 4
  65. post_attention_groups: int = 1
  66. intermediate_groups: int = 4
  67. output_groups: int = 4
  68. tie_word_embeddings: bool = True
  69. __all__ = ["SqueezeBertConfig"]