configuration_ernie.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright 2022 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. """ERNIE 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="nghuyong/ernie-3.0-base-zh")
  20. @strict
  21. class ErnieConfig(PreTrainedConfig):
  22. r"""
  23. task_type_vocab_size (`int`, *optional*, defaults to 3):
  24. The vocabulary size of the `task_type_ids` for ERNIE2.0/ERNIE3.0 model
  25. use_task_id (`bool`, *optional*, defaults to `False`):
  26. Whether or not the model support `task_type_ids`
  27. Examples:
  28. ```python
  29. >>> from transformers import ErnieConfig, ErnieModel
  30. >>> # Initializing a ERNIE nghuyong/ernie-3.0-base-zh style configuration
  31. >>> configuration = ErnieConfig()
  32. >>> # Initializing a model (with random weights) from the nghuyong/ernie-3.0-base-zh style configuration
  33. >>> model = ErnieModel(configuration)
  34. >>> # Accessing the model configuration
  35. >>> configuration = model.config
  36. ```"""
  37. model_type = "ernie"
  38. vocab_size: int = 30522
  39. hidden_size: int = 768
  40. num_hidden_layers: int = 12
  41. num_attention_heads: int = 12
  42. intermediate_size: int = 3072
  43. hidden_act: str = "gelu"
  44. hidden_dropout_prob: float | int = 0.1
  45. attention_probs_dropout_prob: float | int = 0.1
  46. max_position_embeddings: int = 512
  47. type_vocab_size: int = 2
  48. task_type_vocab_size: int = 3
  49. use_task_id: bool = False
  50. initializer_range: float = 0.02
  51. layer_norm_eps: float = 1e-12
  52. pad_token_id: int | None = 0
  53. use_cache: bool = True
  54. classifier_dropout: float | int | None = None
  55. is_decoder: bool = False
  56. add_cross_attention: bool = False
  57. bos_token_id: int | None = None
  58. eos_token_id: int | list[int] | None = None
  59. tie_word_embeddings: bool = True
  60. __all__ = ["ErnieConfig"]