configuration_mra.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright 2023 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. """MRA 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/mra-base-512-4")
  19. @strict
  20. class MraConfig(PreTrainedConfig):
  21. r"""
  22. block_per_row (`int`, *optional*, defaults to 4):
  23. Used to set the budget for the high resolution scale.
  24. approx_mode (`str`, *optional*, defaults to `"full"`):
  25. Controls whether both low and high resolution approximations are used. Set to `"full"` for both low and
  26. high resolution and `"sparse"` for only low resolution.
  27. initial_prior_first_n_blocks (`int`, *optional*, defaults to 0):
  28. The initial number of blocks for which high resolution is used.
  29. initial_prior_diagonal_n_blocks (`int`, *optional*, defaults to 0):
  30. The number of diagonal blocks for which high resolution is used.
  31. Example:
  32. ```python
  33. >>> from transformers import MraConfig, MraModel
  34. >>> # Initializing a Mra uw-madison/mra-base-512-4 style configuration
  35. >>> configuration = MraConfig()
  36. >>> # Initializing a model (with random weights) from the uw-madison/mra-base-512-4 style configuration
  37. >>> model = MraModel(configuration)
  38. >>> # Accessing the model configuration
  39. >>> configuration = model.config
  40. ```"""
  41. model_type = "mra"
  42. vocab_size: int = 50265
  43. hidden_size: int = 768
  44. num_hidden_layers: int = 12
  45. num_attention_heads: int = 12
  46. intermediate_size: int = 3072
  47. hidden_act: str = "gelu"
  48. hidden_dropout_prob: float | int = 0.1
  49. attention_probs_dropout_prob: float | int = 0.1
  50. max_position_embeddings: int = 512
  51. type_vocab_size: int = 1
  52. initializer_range: float = 0.02
  53. layer_norm_eps: float = 1e-5
  54. block_per_row: int = 4
  55. approx_mode: str = "full"
  56. initial_prior_first_n_blocks: int = 0
  57. initial_prior_diagonal_n_blocks: int = 0
  58. pad_token_id: int | None = 1
  59. bos_token_id: int | None = 0
  60. eos_token_id: int | list[int] | None = 2
  61. add_cross_attention: bool = False
  62. tie_word_embeddings: bool = True
  63. __all__ = ["MraConfig"]