configuration_gptj.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 2021 The EleutherAI and HuggingFace Teams. 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. """GPT-J 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="EleutherAI/gpt-j-6B")
  19. @strict
  20. class GPTJConfig(PreTrainedConfig):
  21. r"""
  22. rotary_dim (`int`, *optional*, defaults to 64):
  23. Number of dimensions in the embedding that Rotary Position Embedding is applied to.
  24. Example:
  25. ```python
  26. >>> from transformers import GPTJModel, GPTJConfig
  27. >>> # Initializing a GPT-J 6B configuration
  28. >>> configuration = GPTJConfig()
  29. >>> # Initializing a model from the configuration
  30. >>> model = GPTJModel(configuration)
  31. >>> # Accessing the model configuration
  32. >>> configuration = model.config
  33. ```"""
  34. model_type = "gptj"
  35. attribute_map = {
  36. "max_position_embeddings": "n_positions",
  37. "hidden_size": "n_embd",
  38. "num_attention_heads": "n_head",
  39. "num_hidden_layers": "n_layer",
  40. }
  41. vocab_size: int = 50400
  42. n_positions: int = 2048
  43. n_embd: int = 4096
  44. n_layer: int = 28
  45. n_head: int = 16
  46. rotary_dim: int = 64
  47. n_inner: int | None = None
  48. activation_function: str = "gelu_new"
  49. resid_pdrop: float | int = 0.0
  50. embd_pdrop: float | int = 0.0
  51. attn_pdrop: float | int = 0.0
  52. layer_norm_epsilon: float = 1e-5
  53. initializer_range: float = 0.02
  54. use_cache: bool = True
  55. bos_token_id: int | None = 50256
  56. eos_token_id: int | list[int] | None = 50256
  57. pad_token_id: int | None = None
  58. tie_word_embeddings: bool = False
  59. __all__ = ["GPTJConfig"]