configuration_mvp.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Copyright 2022 The Fairseq Authors 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. """MVP 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="RUCAIBox/mvp")
  19. @strict
  20. class MvpConfig(PreTrainedConfig):
  21. r"""
  22. use_prompt (`bool`, *optional*, defaults to `False`):
  23. Whether or not to use prompt.
  24. prompt_length (`int`, *optional*, defaults to 100):
  25. The length of prompt.
  26. prompt_mid_dim (`int`, *optional*, defaults to 800):
  27. Dimensionality of the "intermediate" layer in prompt.
  28. Example:
  29. ```python
  30. >>> from transformers import MvpConfig, MvpModel
  31. >>> # Initializing a MVP RUCAIBox/mvp style configuration
  32. >>> configuration = MvpConfig()
  33. >>> # Initializing a model (with random weights) from the RUCAIBox/mvp style configuration
  34. >>> model = MvpModel(configuration)
  35. >>> # Accessing the model configuration
  36. >>> configuration = model.config
  37. ```"""
  38. model_type = "mvp"
  39. keys_to_ignore_at_inference = ["past_key_values"]
  40. attribute_map = {
  41. "num_attention_heads": "encoder_attention_heads",
  42. "hidden_size": "d_model",
  43. "num_hidden_layers": "encoder_layers",
  44. }
  45. vocab_size: int = 50267
  46. max_position_embeddings: int = 1024
  47. encoder_layers: int = 12
  48. encoder_ffn_dim: int = 4096
  49. encoder_attention_heads: int = 16
  50. decoder_layers: int = 12
  51. decoder_ffn_dim: int = 4096
  52. decoder_attention_heads: int = 16
  53. encoder_layerdrop: float | int = 0.0
  54. decoder_layerdrop: float | int = 0.0
  55. activation_function: str = "gelu"
  56. d_model: int = 1024
  57. dropout: float | int = 0.1
  58. attention_dropout: float | int = 0.0
  59. activation_dropout: float | int = 0.0
  60. init_std: float = 0.02
  61. classifier_dropout: float | int = 0.0
  62. scale_embedding: bool = False
  63. use_cache: bool = True
  64. pad_token_id: int | None = 1
  65. bos_token_id: int | None = 0
  66. eos_token_id: int | list[int] | None = 2
  67. is_encoder_decoder: bool = True
  68. decoder_start_token_id: int | None = 2
  69. use_prompt: bool = False
  70. prompt_length: int = 100
  71. prompt_mid_dim: int = 800
  72. is_decoder: bool = False
  73. tie_word_embeddings: bool = True
  74. __all__ = ["MvpConfig"]