configuration_ibert.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright 2021 The I-BERT Authors (Sehoon Kim, Amir Gholami, Zhewei Yao,
  2. # Michael Mahoney, Kurt Keutzer - UC Berkeley) and The HuggingFace Inc. team.
  3. # Copyright (c) 20121, NVIDIA CORPORATION. All rights reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. """I-BERT configuration"""
  17. from huggingface_hub.dataclasses import strict
  18. from ...configuration_utils import PreTrainedConfig
  19. from ...utils import auto_docstring
  20. @auto_docstring(checkpoint="kssteven/ibert-roberta-base")
  21. @strict
  22. class IBertConfig(PreTrainedConfig):
  23. r"""
  24. type_vocab_size (`int`, *optional*, defaults to 2):
  25. The vocabulary size of the `token_type_ids` passed when calling [`IBertModel`]
  26. quant_mode (`bool`, *optional*, defaults to `False`):
  27. Whether to quantize the model or not.
  28. force_dequant (`str`, *optional*, defaults to `"none"`):
  29. Force dequantize specific nonlinear layer. Dequantized layers are then executed with full precision.
  30. `"none"`, `"gelu"`, `"softmax"`, `"layernorm"` and `"nonlinear"` are supported. As default, it is set as
  31. `"none"`, which does not dequantize any layers. Please specify `"gelu"`, `"softmax"`, or `"layernorm"` to
  32. dequantize GELU, Softmax, or LayerNorm, respectively. `"nonlinear"` will dequantize all nonlinear layers,
  33. i.e., GELU, Softmax, and LayerNorm.
  34. """
  35. model_type = "ibert"
  36. vocab_size: int = 30522
  37. hidden_size: int = 768
  38. num_hidden_layers: int = 12
  39. num_attention_heads: int = 12
  40. intermediate_size: int = 3072
  41. hidden_act: str = "gelu"
  42. hidden_dropout_prob: float | int = 0.1
  43. attention_probs_dropout_prob: float | int = 0.1
  44. max_position_embeddings: int = 512
  45. type_vocab_size: int = 2
  46. initializer_range: float = 0.02
  47. layer_norm_eps: float = 1e-12
  48. pad_token_id: int | None = 1
  49. bos_token_id: int | None = 0
  50. eos_token_id: int | list[int] | None = 2
  51. quant_mode: bool = False
  52. force_dequant: str = "none"
  53. __all__ = ["IBertConfig"]