configuration_persimmon.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright 2023 Adept AI 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. """Persimmon model configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...modeling_rope_utils import RopeParameters
  18. from ...utils import auto_docstring
  19. @auto_docstring(checkpoint="adept/persimmon-8b-base")
  20. @strict
  21. class PersimmonConfig(PreTrainedConfig):
  22. r"""
  23. qk_layernorm (`bool`, *optional*, default to `True`):
  24. Whether or not to normalize the Queries and Keys after projecting the hidden states
  25. Example:
  26. ```python
  27. >>> from transformers import PersimmonModel, PersimmonConfig
  28. >>> # Initializing a Persimmon persimmon-7b style configuration
  29. >>> configuration = PersimmonConfig()
  30. ```"""
  31. model_type = "persimmon"
  32. keys_to_ignore_at_inference = ["past_key_values"]
  33. vocab_size: int = 262144
  34. hidden_size: int = 4096
  35. intermediate_size: int = 16384
  36. num_hidden_layers: int = 36
  37. num_attention_heads: int = 64
  38. hidden_act: str = "relu2"
  39. max_position_embeddings: int = 16384
  40. initializer_range: float = 0.02
  41. layer_norm_eps: float = 1e-5
  42. use_cache: bool = True
  43. tie_word_embeddings: bool = False
  44. rope_parameters: RopeParameters | dict | None = None
  45. qk_layernorm: bool = True
  46. hidden_dropout: float | int = 0.0
  47. attention_dropout: float | int = 0.0
  48. pad_token_id: int | None = None
  49. bos_token_id: int | None = 1
  50. eos_token_id: int | list[int] | None = 2
  51. def __post_init__(self, **kwargs):
  52. kwargs.setdefault("partial_rotary_factor", 0.5) # assign default for BC
  53. super().__post_init__(**kwargs)
  54. __all__ = ["PersimmonConfig"]