configuration_fnet.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright 2021 Google 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. """FNet 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="google/fnet-base")
  19. @strict
  20. class FNetConfig(PreTrainedConfig):
  21. r"""
  22. use_tpu_fourier_optimizations (`bool`, *optional*, defaults to `False`):
  23. Determines whether to use TPU optimized FFTs. If `True`, the model will favor axis-wise FFTs transforms.
  24. Set to `False` for GPU/CPU hardware, in which case n-dimensional FFTs are used.
  25. tpu_short_seq_length (`int`, *optional*, defaults to 512):
  26. The sequence length that is expected by the model when using TPUs. This will be used to initialize the DFT
  27. matrix only when *use_tpu_fourier_optimizations* is set to `True` and the input sequence is shorter than or
  28. equal to 4096 tokens.
  29. Example:
  30. ```python
  31. >>> from transformers import FNetConfig, FNetModel
  32. >>> # Initializing a FNet fnet-base style configuration
  33. >>> configuration = FNetConfig()
  34. >>> # Initializing a model (with random weights) from the fnet-base style configuration
  35. >>> model = FNetModel(configuration)
  36. >>> # Accessing the model configuration
  37. >>> configuration = model.config
  38. ```"""
  39. model_type = "fnet"
  40. vocab_size: int = 32000
  41. hidden_size: int = 768
  42. num_hidden_layers: int = 12
  43. intermediate_size: int = 3072
  44. hidden_act: str = "gelu_new"
  45. hidden_dropout_prob: float | int = 0.1
  46. max_position_embeddings: int = 512
  47. type_vocab_size: int = 4
  48. initializer_range: float = 0.02
  49. layer_norm_eps: float = 1e-12
  50. use_tpu_fourier_optimizations: bool = False
  51. tpu_short_seq_length: int = 512
  52. pad_token_id: int | None = 3
  53. bos_token_id: int | None = 1
  54. eos_token_id: int | list[int] | None = 2
  55. tie_word_embeddings: bool = True
  56. __all__ = ["FNetConfig"]