configuration_plbart.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2022, UCLA NLP, The Facebook AI Research Team and 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. """PLBART 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="uclanlp/plbart-base")
  19. @strict
  20. class PLBartConfig(PreTrainedConfig):
  21. r"""
  22. Example:
  23. ```python
  24. >>> from transformers import PLBartConfig, PLBartModel
  25. >>> # Initializing a PLBART uclanlp/plbart-base style configuration
  26. >>> configuration = PLBartConfig()
  27. >>> # Initializing a model (with random weights) from the uclanlp/plbart-base style configuration
  28. >>> model = PLBartModel(configuration)
  29. >>> # Accessing the model configuration
  30. >>> configuration = model.config
  31. ```"""
  32. model_type = "plbart"
  33. keys_to_ignore_at_inference = ["past_key_values"]
  34. attribute_map = {
  35. "num_attention_heads": "encoder_attention_heads",
  36. "hidden_size": "d_model",
  37. "initializer_range": "init_std",
  38. "num_hidden_layers": "encoder_layers",
  39. }
  40. vocab_size: int = 50005
  41. max_position_embeddings: int = 1024
  42. encoder_layers: int = 6
  43. encoder_ffn_dim: int = 3072
  44. encoder_attention_heads: int = 12
  45. decoder_layers: int = 6
  46. decoder_ffn_dim: int = 3072
  47. decoder_attention_heads: int = 12
  48. encoder_layerdrop: float | int = 0.0
  49. decoder_layerdrop: float | int = 0.0
  50. use_cache: bool = True
  51. is_encoder_decoder: bool = True
  52. activation_function: str = "gelu"
  53. d_model: int = 768
  54. dropout: float | int = 0.1
  55. attention_dropout: float | int = 0.1
  56. activation_dropout: float | int = 0.0
  57. init_std: float = 0.02
  58. classifier_dropout: float | int = 0.0
  59. scale_embedding: bool = True
  60. pad_token_id: int | None = 1
  61. bos_token_id: int | None = 0
  62. eos_token_id: int | list[int] | None = 2
  63. forced_eos_token_id: int | list[int] | None = 2
  64. is_decoder: bool = False
  65. tie_word_embeddings: bool = True
  66. __all__ = ["PLBartConfig"]