configuration_timesfm.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright 2025 Google LLC and HuggingFace Inc. team.
  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. """TimesFM 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/timesfm-2.0-500m-pytorch")
  19. @strict
  20. class TimesFmConfig(PreTrainedConfig):
  21. r"""
  22. patch_length (`int`, *optional*, defaults to 32):
  23. The length of one patch in the input sequence.
  24. context_length (`int`, *optional*, defaults to 512):
  25. The length of the input context.
  26. horizon_length (`int`, *optional*, defaults to 128):
  27. The length of the prediction horizon.
  28. freq_size (`int`, *optional*, defaults to 3):
  29. The number of frequency embeddings.
  30. tolerance (`float`, *optional*, defaults to 1e-06):
  31. The tolerance for the quantile loss.
  32. quantiles (`list[float]`, *optional*, defaults to `[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]`):
  33. The quantiles to predict.
  34. pad_val (`float`, *optional*, defaults to 1123581321.0):
  35. The value used to pad the predictions.
  36. attention_dropout (`float`, *optional*, defaults to 0.0):
  37. The dropout probability for the attention scores.
  38. use_positional_embedding (`bool`, *optional*, defaults to `False`):
  39. Whether to add positional embeddings.
  40. min_timescale (`int`, *optional*, defaults to 1):
  41. The start of the geometric positional index. Determines the periodicity of
  42. the added signal.
  43. max_timescale (`int`, *optional*, defaults to 10000):
  44. The end of the geometric positional index. Determines the frequency of the
  45. added signal.
  46. """
  47. model_type = "timesfm"
  48. keys_to_ignore_at_inference = []
  49. is_encoder_decoder = False
  50. patch_length: int = 32
  51. context_length: int = 512
  52. horizon_length: int = 128
  53. freq_size: int = 3
  54. num_hidden_layers: int = 50
  55. hidden_size: int = 1280
  56. intermediate_size: int = 1280
  57. head_dim: int = 80
  58. num_attention_heads: int = 16
  59. tolerance: float = 1e-6
  60. rms_norm_eps: float = 1e-6
  61. quantiles: list[float] | tuple[float, ...] = (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
  62. pad_val: float = 1123581321.0
  63. attention_dropout: float | int = 0.0
  64. use_positional_embedding: bool = False
  65. initializer_range: float = 0.02
  66. min_timescale: int = 1
  67. max_timescale: int = 10_000
  68. __all__ = ["TimesFmConfig"]