configuration_yoso.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright 2022 The HuggingFace Inc. 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. """YOSO 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="uw-madison/yoso-4096")
  19. @strict
  20. class YosoConfig(PreTrainedConfig):
  21. r"""
  22. use_expectation (`bool`, *optional*, defaults to `True`):
  23. Whether or not to use YOSO Expectation. Overrides any effect of num_hash.
  24. hash_code_len (`int`, *optional*, defaults to 9):
  25. The length of hashes generated by the hash functions.
  26. num_hash (`int`, *optional*, defaults to 64):
  27. Number of hash functions used in [`YosoSelfAttention`].
  28. conv_window (`int`, *optional*):
  29. Kernel size of depth-wise convolution.
  30. use_fast_hash (`bool`, *optional*, defaults to `False`):
  31. Whether or not to use custom cuda kernels which perform fast random projection via hadamard transform.
  32. lsh_backward (`bool`, *optional*, defaults to `True`):
  33. Whether or not to perform backpropagation using Locality Sensitive Hashing.
  34. Example:
  35. ```python
  36. >>> from transformers import YosoConfig, YosoModel
  37. >>> # Initializing a YOSO uw-madison/yoso-4096 style configuration
  38. >>> configuration = YosoConfig()
  39. >>> # Initializing a model (with random weights) from the uw-madison/yoso-4096 style configuration
  40. >>> model = YosoModel(configuration)
  41. >>> # Accessing the model configuration
  42. >>> configuration = model.config
  43. ```"""
  44. model_type = "yoso"
  45. vocab_size: int = 50265
  46. hidden_size: int = 768
  47. num_hidden_layers: int = 12
  48. num_attention_heads: int = 12
  49. intermediate_size: int = 3072
  50. hidden_act: str = "gelu"
  51. hidden_dropout_prob: float | int = 0.1
  52. attention_probs_dropout_prob: float | int = 0.1
  53. max_position_embeddings: int = 4096
  54. type_vocab_size: int = 1
  55. initializer_range: float = 0.02
  56. layer_norm_eps: float = 1e-12
  57. use_expectation: bool = True
  58. hash_code_len: int = 9
  59. num_hash: int = 64
  60. conv_window: int | None = None
  61. use_fast_hash: bool = True
  62. lsh_backward: bool = True
  63. pad_token_id: int | None = 1
  64. bos_token_id: int | None = 0
  65. eos_token_id: int | list[int] | None = 2
  66. add_cross_attention: bool = False
  67. tie_word_embeddings: bool = True
  68. __all__ = ["YosoConfig"]