yujiepan commited on
Commit
db3ab53
·
0 Parent(s):

Duplicate from tiny-random/timestral

Browse files
Files changed (7) hide show
  1. .gitattributes +35 -0
  2. .meta.json +19 -0
  3. LICENSE +10 -0
  4. README.md +214 -0
  5. config.json +55 -0
  6. model.safetensors +3 -0
  7. timestral-hourglass.png +0 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.meta.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source_model": {
3
+ "name": "mistralai/Timestral-209M",
4
+ "commit_id": "9874d252ab0aae16f7f7c999f98f98d6ad7d8365"
5
+ },
6
+ "env": {
7
+ "python": "3.12.13",
8
+ "packages": {
9
+ "huggingface_hub": "1.27.0",
10
+ "numpy": "2.5.2",
11
+ "safetensors": "0.8.0",
12
+ "timestral": "1.0.0",
13
+ "tokenizers": "0.23.0rc0",
14
+ "torch": "2.13.0+cu126",
15
+ "transformers": "5.15.0.dev0"
16
+ },
17
+ "cuda": "12.6"
18
+ }
19
+ }
LICENSE ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ Modified MIT License
2
+
3
+ Attribution notice: 2026 - Mistral AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of the weights of this model and associated documentation files (the “Model”), to deal in the Model without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Model, and to permit persons to whom the Model is furnished to do so, subject to the following conditions:
6
+
7
+ 1. The above attribution notice and this permission notice shall be included in all copies or substantial portions of the Model.
8
+ 2. You are not authorized to exercise any rights under this license if the global consolidated monthly revenue of your company (or that of your employer) exceeds $20 million (or its equivalent in another currency) for the preceding month. This restriction in (b) applies to the Model and any derivatives, modifications, or combined works based on it, whether provided by Mistral AI or by a third party. You may contact Mistral AI (sales@mistral.ai) to request a commercial license, which Mistral AI may grant you at its sole discretion, or choose to use the Model on Mistral AI's hosted services available at https://mistral.ai/.
9
+
10
+ THE MODEL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL MISTRAL AI BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MODEL OR THE USE OR OTHER DEALINGS IN THE MODEL.
README.md ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: timestral
3
+ base_model:
4
+ - mistralai/Timestral-209M
5
+ ---
6
+
7
+ This tiny model is intended for debugging. It is randomly initialized using the configuration adapted from [mistralai/Timestral-209M](https://huggingface.co/mistralai/Timestral-209M).
8
+
9
+ Structural comparison with `mistralai/Timestral-209M`:
10
+
11
+ | Feature | Source | Tiny |
12
+ |---|---:|---:|
13
+ | Forecasting interface | univariate, multivariate, past/known covariates | same |
14
+ | Stored precision | F32 | F32 |
15
+ | Patch size / block size | 32 / 32 | same |
16
+ | Transformer layers | 24 | 8; two 3-time + 1-time/variate cycles |
17
+ | Width / attention heads / head dimension | 768 / 12 / 64 | 64 / 1 / 64 |
18
+ | SwiGLU intermediate width | 2,048 | 128 |
19
+ | Quantile knots | 21 | same |
20
+ | DHF two-stream decoder and monotone quantile head | present | same |
21
+
22
+ This checkpoint uses Mistral's public `timestral` inference package (release
23
+ commit `a534bdbd244d64f3d9d743f46c7bf6fc330ed4ff`): install it with
24
+ `pip install git+https://github.com/mistralai/timestral.git` before running the
25
+ example. It is a forecasting model, not a Transformers causal-LM or SGLang/vLLM
26
+ serving model.
27
+
28
+ | File path | Size |
29
+ |------|------|
30
+ | model.safetensors | 2.7MB |
31
+
32
+
33
+ ### Example usage:
34
+
35
+ - Transformers (✅ verified)
36
+
37
+ ```python
38
+ import torch
39
+ from timestral import TimestralForecaster
40
+
41
+ model_id = "tiny-random/timestral"
42
+ device = "cuda" if torch.cuda.is_available() else "cpu"
43
+ forecaster = TimestralForecaster.from_pretrained(model_id, device=device, per_shot_horizon_patches=32)
44
+ context = torch.sin(torch.arange(96, dtype=torch.float32) / 6).reshape(1, 1, -1)
45
+ past = torch.cos(torch.arange(96, dtype=torch.float32) / 5).reshape(1, 1, -1)
46
+ known = torch.linspace(0, 1, 128, dtype=torch.float32).reshape(1, 1, -1)
47
+ forecast = forecaster.forecast(context, prediction_length=32, past_covariates=past, known_covariates=known)
48
+ print(forecast.quantiles.shape)
49
+ ```
50
+
51
+ ### Codes to create this repo (✅ verified):
52
+
53
+ <details><summary>Click to expand</summary>
54
+
55
+ ```python
56
+ import json
57
+ from pathlib import Path
58
+ from shutil import copyfile
59
+
60
+ import torch
61
+ from huggingface_hub import hf_hub_download
62
+ from safetensors.torch import save_file
63
+ from timestral import TimestralConfig, TimestralModel
64
+
65
+ source_model_id = "mistralai/Timestral-209M"
66
+ save_folder = "/tmp/tiny-random/timestral"
67
+ source_revision = "9874d252ab0aae16f7f7c999f98f98d6ad7d8365"
68
+ torch.manual_seed(42)
69
+ folder = Path(save_folder)
70
+ folder.mkdir(parents=True, exist_ok=True)
71
+ raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
72
+ # Keep two source 3-time + 1-time/variate cycles. A 64-wide model with one
73
+ # head preserves Timestral's 64-wide attention head exactly.
74
+ raw.update(
75
+ d_model=64, num_heads=1, mlp_hidden_dim=128, context_length=1024,
76
+ block_schedule=["time", "time", "time", "time_variate"] * 2,
77
+ )
78
+ (folder / "config.json").write_text(json.dumps(raw, indent=2) + "\n", encoding="utf-8")
79
+ config = TimestralConfig.load(folder / "config.json")
80
+ model = TimestralModel(config).float()
81
+ with torch.no_grad():
82
+ for name, parameter in sorted(model.named_parameters()):
83
+ if name.endswith("scale"):
84
+ parameter.fill_(1)
85
+ else:
86
+ torch.nn.init.normal_(parameter, mean=0, std=0.02)
87
+ save_file(model.state_dict(), folder / "model.safetensors", metadata={"format": "pt"})
88
+ for filename in ("LICENSE", "timestral-hourglass.png"):
89
+ try:
90
+ copyfile(hf_hub_download(source_model_id, filename, revision=source_revision), folder / filename)
91
+ except Exception:
92
+ # The executable checkpoint consists solely of config.json and model.safetensors.
93
+ # Preserve optional presentation assets when their source revision supplies them.
94
+ pass
95
+ ```
96
+
97
+ </details>
98
+
99
+ ### Printing the model:
100
+
101
+ <details><summary>Click to expand</summary>
102
+
103
+ ```text
104
+ TimestralModel(
105
+ (representation): PatchRepresentation(
106
+ (patch_proj): ResidualBlock(
107
+ (hidden_layer): Linear(in_features=64, out_features=256, bias=True)
108
+ (output_layer): Linear(in_features=256, out_features=64, bias=True)
109
+ (residual_layer): Linear(in_features=64, out_features=64, bias=True)
110
+ (activation): SiLU()
111
+ )
112
+ )
113
+ (transformer): Transformer(
114
+ (layers): ModuleList(
115
+ (0-2): 3 x TransformerBlock(
116
+ (attn_norms): ModuleList(
117
+ (0): RMSNorm()
118
+ )
119
+ (attns): ModuleList(
120
+ (0): Attention(
121
+ (wQKV): Linear(in_features=64, out_features=192, bias=False)
122
+ (wO): Linear(in_features=64, out_features=64, bias=False)
123
+ (_gate): Linear(in_features=64, out_features=64, bias=False)
124
+ )
125
+ )
126
+ (mlp_norm): RMSNorm()
127
+ (mlp): FusedSwiGLU(
128
+ (w12): Linear(in_features=64, out_features=256, bias=False)
129
+ (w3): Linear(in_features=128, out_features=64, bias=False)
130
+ )
131
+ )
132
+ (3): TransformerBlock(
133
+ (attn_norms): ModuleList(
134
+ (0-1): 2 x RMSNorm()
135
+ )
136
+ (attns): ModuleList(
137
+ (0-1): 2 x Attention(
138
+ (wQKV): Linear(in_features=64, out_features=192, bias=False)
139
+ (wO): Linear(in_features=64, out_features=64, bias=False)
140
+ (_gate): Linear(in_features=64, out_features=64, bias=False)
141
+ )
142
+ )
143
+ (mlp_norm): RMSNorm()
144
+ (mlp): FusedSwiGLU(
145
+ (w12): Linear(in_features=64, out_features=256, bias=False)
146
+ (w3): Linear(in_features=128, out_features=64, bias=False)
147
+ )
148
+ )
149
+ (4-6): 3 x TransformerBlock(
150
+ (attn_norms): ModuleList(
151
+ (0): RMSNorm()
152
+ )
153
+ (attns): ModuleList(
154
+ (0): Attention(
155
+ (wQKV): Linear(in_features=64, out_features=192, bias=False)
156
+ (wO): Linear(in_features=64, out_features=64, bias=False)
157
+ (_gate): Linear(in_features=64, out_features=64, bias=False)
158
+ )
159
+ )
160
+ (mlp_norm): RMSNorm()
161
+ (mlp): FusedSwiGLU(
162
+ (w12): Linear(in_features=64, out_features=256, bias=False)
163
+ (w3): Linear(in_features=128, out_features=64, bias=False)
164
+ )
165
+ )
166
+ (7): TransformerBlock(
167
+ (attn_norms): ModuleList(
168
+ (0-1): 2 x RMSNorm()
169
+ )
170
+ (attns): ModuleList(
171
+ (0-1): 2 x Attention(
172
+ (wQKV): Linear(in_features=64, out_features=192, bias=False)
173
+ (wO): Linear(in_features=64, out_features=64, bias=False)
174
+ (_gate): Linear(in_features=64, out_features=64, bias=False)
175
+ )
176
+ )
177
+ (mlp_norm): RMSNorm()
178
+ (mlp): FusedSwiGLU(
179
+ (w12): Linear(in_features=64, out_features=256, bias=False)
180
+ (w3): Linear(in_features=128, out_features=64, bias=False)
181
+ )
182
+ )
183
+ )
184
+ (rope): SinCosRoPE()
185
+ (out_norm): RMSNorm()
186
+ )
187
+ (head): QuantileHead(
188
+ (projection): ResidualBlock(
189
+ (hidden_layer): Linear(in_features=64, out_features=256, bias=False)
190
+ (output_layer): Linear(in_features=256, out_features=672, bias=False)
191
+ (residual_layer): Linear(in_features=64, out_features=672, bias=False)
192
+ (activation): SiLU()
193
+ )
194
+ )
195
+ )
196
+ ```
197
+
198
+ </details>
199
+
200
+ ### Test environment:
201
+
202
+ - huggingface_hub: 1.27.0
203
+ - numpy: 2.5.2
204
+ - safetensors: 0.8.0
205
+ - timestral: 1.0.0
206
+ - tokenizers: 0.23.0rc0
207
+ - torch: 2.13.0+cu126
208
+ - transformers: 5.15.0.dev0
209
+
210
+ ### Change log:
211
+
212
+ - 2026-10-23: Initial version.
213
+
214
+ This repo is generated by GPT-6.1-Sol
config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "patch_size": 32,
3
+ "d_model": 64,
4
+ "num_heads": 1,
5
+ "mlp_hidden_dim": 128,
6
+ "block_schedule": [
7
+ "time",
8
+ "time",
9
+ "time",
10
+ "time_variate",
11
+ "time",
12
+ "time",
13
+ "time",
14
+ "time_variate"
15
+ ],
16
+ "quantile_knots": [
17
+ 0.01,
18
+ 0.05,
19
+ 0.1,
20
+ 0.15,
21
+ 0.2,
22
+ 0.25,
23
+ 0.3,
24
+ 0.35,
25
+ 0.4,
26
+ 0.45,
27
+ 0.5,
28
+ 0.55,
29
+ 0.6,
30
+ 0.65,
31
+ 0.7,
32
+ 0.75,
33
+ 0.8,
34
+ 0.85,
35
+ 0.9,
36
+ 0.95,
37
+ 0.99
38
+ ],
39
+ "block_size": 32,
40
+ "context_length": 1024,
41
+ "rope_theta": 10000.0,
42
+ "rope_partial_factor": 0.5,
43
+ "norm_eps": 1e-06,
44
+ "attn_bias": false,
45
+ "mlp_bias": false,
46
+ "time_attn_gate": "sdpa_sigmoid",
47
+ "variate_attn_gate": "sdpa_sigmoid",
48
+ "minimum_scale": 1e-06,
49
+ "use_asinh": true,
50
+ "stabilize_with_global": false,
51
+ "covariate_enabled": true,
52
+ "split_context_horizon_attn": true,
53
+ "attend_missing_patches": true,
54
+ "quantile_width_factor": 3.0
55
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:564921d8f9e096df7bfecce109f6bc2ae52b93ca55b4c67d344fde3d587db1fb
3
+ size 2693368
timestral-hourglass.png ADDED