configuration_pixtral.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright 2024 HuggingFace Inc. team. All rights reserved.
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS,
  10. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. # See the License for the specific language governing permissions and
  12. # limitations under the License.
  13. """Pixtral model configuration"""
  14. from huggingface_hub.dataclasses import strict
  15. from ...configuration_utils import PreTrainedConfig
  16. from ...modeling_rope_utils import RopeParameters
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="mistral-labs/pixtral-12b")
  19. @strict
  20. class PixtralVisionConfig(PreTrainedConfig):
  21. r"""
  22. Example:
  23. ```python
  24. >>> from transformers import PixtralVisionModel, PixtralVisionConfig
  25. >>> # Initializing a Pixtral-12B style configuration
  26. >>> config = PixtralVisionConfig()
  27. >>> # Initializing a model (with randomly initialized weights) from the configuration
  28. >>> model = PixtralVisionModel(configuration)
  29. >>> # Accessing the model configuration
  30. >>> configuration = model.config
  31. ```"""
  32. model_type = "pixtral"
  33. hidden_size: int = 1024
  34. intermediate_size: int = 4096
  35. num_hidden_layers: int = 24
  36. num_attention_heads: int = 16
  37. num_channels: int = 3
  38. image_size: int | list[int] | tuple[int, int] = 1024
  39. patch_size: int | list[int] | tuple[int, int] = 16
  40. hidden_act: str = "gelu"
  41. attention_dropout: float | int = 0.0
  42. rope_parameters: RopeParameters | dict | None = None
  43. initializer_range: float = 0.02
  44. def __post_init__(self, **kwargs):
  45. self.head_dim = self.hidden_size // self.num_attention_heads
  46. super().__post_init__(**kwargs)
  47. __all__ = ["PixtralVisionConfig"]