configuration_ctrl.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright 2018 Salesforce and HuggingFace Inc. team.
  2. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
  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. """Salesforce CTRL configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="Salesforce/ctrl")
  19. @strict
  20. class CTRLConfig(PreTrainedConfig):
  21. r"""
  22. dff (`int`, *optional*, defaults to 8192):
  23. Dimensionality of the inner dimension of the feed forward networks (FFN).
  24. Examples:
  25. ```python
  26. >>> from transformers import CTRLConfig, CTRLModel
  27. >>> # Initializing a CTRL configuration
  28. >>> configuration = CTRLConfig()
  29. >>> # Initializing a model (with random weights) from the configuration
  30. >>> model = CTRLModel(configuration)
  31. >>> # Accessing the model configuration
  32. >>> configuration = model.config
  33. ```"""
  34. model_type = "ctrl"
  35. keys_to_ignore_at_inference = ["past_key_values"]
  36. attribute_map = {
  37. "max_position_embeddings": "n_positions",
  38. "hidden_size": "n_embd",
  39. "num_attention_heads": "n_head",
  40. "num_hidden_layers": "n_layer",
  41. }
  42. vocab_size: int = 246534
  43. n_positions: int = 256
  44. n_embd: int = 1280
  45. dff: int = 8192
  46. n_layer: int = 48
  47. n_head: int = 16
  48. resid_pdrop: float | int = 0.1
  49. embd_pdrop: float | int = 0.1
  50. layer_norm_epsilon: float = 1e-6
  51. initializer_range: float = 0.02
  52. use_cache: bool = True
  53. pad_token_id: int | None = None
  54. bos_token_id: int | None = None
  55. eos_token_id: int | list[int] | None = None
  56. tie_word_embeddings: bool = True
  57. __all__ = ["CTRLConfig"]