configuration_convbert.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright The HuggingFace team. All rights reserved.
  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. """ConvBERT 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="YituTech/conv-bert-base")
  19. @strict
  20. class ConvBertConfig(PreTrainedConfig):
  21. r"""
  22. head_ratio (`int`, *optional*, defaults to 2):
  23. Ratio gamma to reduce the number of attention heads.
  24. num_groups (`int`, *optional*, defaults to 1):
  25. The number of groups for grouped linear layers for ConvBert model
  26. Example:
  27. ```python
  28. >>> from transformers import ConvBertConfig, ConvBertModel
  29. >>> # Initializing a ConvBERT convbert-base-uncased style configuration
  30. >>> configuration = ConvBertConfig()
  31. >>> # Initializing a model (with random weights) from the convbert-base-uncased style configuration
  32. >>> model = ConvBertModel(configuration)
  33. >>> # Accessing the model configuration
  34. >>> configuration = model.config
  35. ```"""
  36. model_type = "convbert"
  37. vocab_size: int = 30522
  38. hidden_size: int = 768
  39. num_hidden_layers: int = 12
  40. num_attention_heads: int = 12
  41. intermediate_size: int = 3072
  42. hidden_act: str = "gelu"
  43. hidden_dropout_prob: float | int = 0.1
  44. attention_probs_dropout_prob: float | int = 0.1
  45. max_position_embeddings: int = 512
  46. type_vocab_size: int = 2
  47. initializer_range: float = 0.02
  48. layer_norm_eps: float = 1e-12
  49. pad_token_id: int | None = 1
  50. bos_token_id: int | None = 0
  51. eos_token_id: int | list[int] | None = 2
  52. embedding_size: int = 768
  53. head_ratio: int = 2
  54. conv_kernel_size: int = 9
  55. num_groups: int = 1
  56. classifier_dropout: float | int | None = None
  57. is_decoder: bool = False
  58. add_cross_attention: bool = False
  59. tie_word_embeddings: bool = True
  60. __all__ = ["ConvBertConfig"]