configuration_blenderbot.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright 2021 The Facebook, Inc. 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. """Blenderbot 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/blenderbot-3B")
  19. @strict
  20. class BlenderbotConfig(PreTrainedConfig):
  21. r"""
  22. encoder_no_repeat_ngram_size (`int`, *optional*, defaults to 3):
  23. Number of ngrams to not be repeated in the encoder.
  24. Example:
  25. ```python
  26. >>> from transformers import BlenderbotConfig, BlenderbotModel
  27. >>> # Initializing a Blenderbot facebook/blenderbot-3B style configuration
  28. >>> configuration = BlenderbotConfig()
  29. >>> # Initializing a model (with random weights) from the facebook/blenderbot-3B style configuration
  30. >>> model = BlenderbotModel(configuration)
  31. >>> # Accessing the model configuration
  32. >>> configuration = model.config
  33. ```"""
  34. model_type = "blenderbot"
  35. keys_to_ignore_at_inference = ["past_key_values"]
  36. attribute_map = {
  37. "num_attention_heads": "encoder_attention_heads",
  38. "hidden_size": "d_model",
  39. "num_hidden_layers": "encoder_layers",
  40. }
  41. vocab_size: int = 8008
  42. max_position_embeddings: int = 128
  43. encoder_layers: int = 2
  44. encoder_ffn_dim: int = 10240
  45. encoder_attention_heads: int = 32
  46. decoder_layers: int = 24
  47. decoder_ffn_dim: int = 10240
  48. decoder_attention_heads: int = 32
  49. encoder_layerdrop: float | int = 0.0
  50. decoder_layerdrop: float | int = 0.0
  51. use_cache: bool = True
  52. is_encoder_decoder: bool = True
  53. activation_function: str = "gelu"
  54. d_model: int = 2560
  55. dropout: float | int = 0.1
  56. attention_dropout: float | int = 0.0
  57. activation_dropout: float | int = 0.0
  58. init_std: float = 0.02
  59. decoder_start_token_id: int = 1
  60. scale_embedding: bool = False
  61. pad_token_id: int | None = 0
  62. bos_token_id: int | None = 1
  63. eos_token_id: int | list[int] | None = 2
  64. encoder_no_repeat_ngram_size: int = 3
  65. forced_eos_token_id: int | list[int] | None = 2
  66. is_decoder: bool = False
  67. tie_word_embeddings: bool = True
  68. __all__ = ["BlenderbotConfig"]