configuration_xglm.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 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. """XGLM 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="facebook/xglm-564M")
  19. @strict
  20. class XGLMConfig(PreTrainedConfig):
  21. r"""
  22. Example:
  23. ```python
  24. >>> from transformers import XGLMModel, XGLMConfig
  25. >>> # Initializing a XGLM facebook/xglm-564M style configuration
  26. >>> configuration = XGLMConfig()
  27. >>> # Initializing a model from the facebook/xglm-564M style configuration
  28. >>> model = XGLMModel(configuration)
  29. >>> # Accessing the model configuration
  30. >>> configuration = model.config
  31. ```"""
  32. model_type = "xglm"
  33. keys_to_ignore_at_inference = ["past_key_values"]
  34. attribute_map = {
  35. "num_attention_heads": "attention_heads",
  36. "hidden_size": "d_model",
  37. "num_hidden_layers": "num_layers",
  38. }
  39. vocab_size: int = 256008
  40. max_position_embeddings: int = 2048
  41. d_model: int = 1024
  42. ffn_dim: int = 4096
  43. num_layers: int = 24
  44. attention_heads: int = 16
  45. activation_function: str = "gelu"
  46. dropout: float | int = 0.1
  47. attention_dropout: float | int = 0.1
  48. activation_dropout: float | int = 0.0
  49. layerdrop: float | int = 0.0
  50. init_std: float = 0.02
  51. scale_embedding: bool = True
  52. use_cache: bool = True
  53. decoder_start_token_id: int = 2
  54. pad_token_id: int | None = 1
  55. bos_token_id: int | None = 0
  56. eos_token_id: int | list[int] | None = 2
  57. add_cross_attention: bool = False
  58. tie_word_embeddings: bool = True
  59. __all__ = ["XGLMConfig"]