continuousintelligence 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- continuousintelligence/__init__.py +9 -0
- continuousintelligence/_data/NOTICE +16 -0
- continuousintelligence/_data/bike_sharing.csv +145 -0
- continuousintelligence/_example.py +20 -0
- continuousintelligence/_loader.py +140 -0
- continuousintelligence/_plot.py +158 -0
- continuousintelligence/_vendor/__init__.py +1 -0
- continuousintelligence/_vendor/mamba3/LICENSE +201 -0
- continuousintelligence/_vendor/mamba3/__init__.py +6 -0
- continuousintelligence/_vendor/mamba3/angle_dt.py +213 -0
- continuousintelligence/_vendor/mamba3/layernorm_gated.py +115 -0
- continuousintelligence/_vendor/mamba3/mamba3_mimo_fwd.py +483 -0
- continuousintelligence/_vendor/mamba3/mamba3_mimo_utils.py +112 -0
- continuousintelligence/_vendor/mamba3/utils.py +25 -0
- continuousintelligence/ci_proto/__init__.py +5 -0
- continuousintelligence/ci_proto/_calendar.py +153 -0
- continuousintelligence/ci_proto/_checkpoint.py +106 -0
- continuousintelligence/ci_proto/_cuda.py +135 -0
- continuousintelligence/ci_proto/_forecast.py +708 -0
- continuousintelligence/ci_proto/_groups.py +198 -0
- continuousintelligence/ci_proto/_mamba.py +190 -0
- continuousintelligence/ci_proto/_model.py +489 -0
- continuousintelligence-0.1.0.dist-info/METADATA +29 -0
- continuousintelligence-0.1.0.dist-info/RECORD +30 -0
- continuousintelligence-0.1.0.dist-info/WHEEL +5 -0
- continuousintelligence-0.1.0.dist-info/licenses/LICENCE +95 -0
- continuousintelligence-0.1.0.dist-info/licenses/NOTICE +33 -0
- continuousintelligence-0.1.0.dist-info/licenses/src/continuousintelligence/_data/NOTICE +16 -0
- continuousintelligence-0.1.0.dist-info/licenses/src/continuousintelligence/_vendor/mamba3/LICENSE +201 -0
- continuousintelligence-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
"""Continuous Intelligence's patch model and multivariate attention.
|
|
2
|
+
|
|
3
|
+
Includes model components adapted by Continuous Intelligence from TiRex-2:
|
|
4
|
+
https://github.com/NX-AI/tirex-2/tree/bb5427f4a97379a17756e67bc846c4f4b569eb48/src/tirex2/model
|
|
5
|
+
|
|
6
|
+
The gated feed-forward and RMS normalisation components also derive from xLSTM:
|
|
7
|
+
https://github.com/NX-AI/xlstm/tree/ab22eadbd245f293dd8dec38ed29963d73758a12/xlstm/xlstm_large
|
|
8
|
+
|
|
9
|
+
Copyright (c) NXAI GmbH.
|
|
10
|
+
Copyright 2024 NXAI GmbH and its affiliates 2024
|
|
11
|
+
Upstream portions are licensed under Apache-2.0; see NOTICE.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import math
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from functools import lru_cache
|
|
19
|
+
from types import SimpleNamespace
|
|
20
|
+
from typing import Any
|
|
21
|
+
|
|
22
|
+
import torch
|
|
23
|
+
from torch import Tensor, nn
|
|
24
|
+
from torch.nn import functional as F
|
|
25
|
+
|
|
26
|
+
from ._mamba import Mamba3, RMSNorm
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ResidualBlock(nn.Module):
|
|
30
|
+
"""Patch embedding and quantile projection with a linear residual."""
|
|
31
|
+
|
|
32
|
+
def __init__(self, in_dim: int, h_dim: int, out_dim: int, act: nn.Module) -> None:
|
|
33
|
+
super().__init__()
|
|
34
|
+
self.hidden_layer = nn.Linear(in_dim, h_dim)
|
|
35
|
+
self.output_layer = nn.Linear(h_dim, out_dim)
|
|
36
|
+
self.residual_layer = nn.Linear(in_dim, out_dim)
|
|
37
|
+
self.act = act
|
|
38
|
+
|
|
39
|
+
def forward(self, x: Tensor) -> Tensor:
|
|
40
|
+
return self.output_layer(self.act(self.hidden_layer(x))) + self.residual_layer(x)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class RMSLayerNorm(nn.Module):
|
|
44
|
+
"""Final norm preserving float32 normalisation for reduced-precision activations."""
|
|
45
|
+
|
|
46
|
+
def __init__(self, dim: int, eps: float) -> None:
|
|
47
|
+
super().__init__()
|
|
48
|
+
self.weight = nn.Parameter(torch.ones(dim))
|
|
49
|
+
self.eps = eps
|
|
50
|
+
|
|
51
|
+
def forward(self, x: Tensor) -> Tensor:
|
|
52
|
+
variance = x.float().pow(2).mean(-1, keepdim=True)
|
|
53
|
+
return self.weight * (x * torch.rsqrt(variance + self.eps))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class GatedFFN(nn.Module):
|
|
57
|
+
"""The time mixer's gated feed-forward projection."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, dim: int, constants: dict[str, Any]) -> None:
|
|
60
|
+
super().__init__()
|
|
61
|
+
multiple = constants.get("ffn_round_up_to_multiple_of", 64)
|
|
62
|
+
factor = constants.get("ffn_proj_factor", 2.6667)
|
|
63
|
+
if type(multiple) is not int or multiple < 1:
|
|
64
|
+
raise ValueError("ffn_round_up_to_multiple_of must be a positive integer")
|
|
65
|
+
if not math.isfinite(factor) or factor <= 0:
|
|
66
|
+
raise ValueError("ffn_proj_factor must be positive and finite")
|
|
67
|
+
width = math.ceil(dim * factor / multiple) * multiple
|
|
68
|
+
bias = constants.get("use_bias", False)
|
|
69
|
+
self.proj_up_gate = nn.Linear(dim, width, bias=bias)
|
|
70
|
+
self.proj_up = nn.Linear(dim, width, bias=bias)
|
|
71
|
+
self.proj_down = nn.Linear(width, dim, bias=bias)
|
|
72
|
+
|
|
73
|
+
def forward(self, x: Tensor) -> Tensor:
|
|
74
|
+
return self.proj_down(F.silu(self.proj_up_gate(x)) * self.proj_up(x))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class MambaCell(nn.Module):
|
|
78
|
+
"""Keep the checkpoint's cell prefix around the selected Mamba recurrence."""
|
|
79
|
+
|
|
80
|
+
def __init__(self, dim: int, cfg: dict[str, Any]) -> None:
|
|
81
|
+
super().__init__()
|
|
82
|
+
expand, heads = cfg.get("mamba_expand", 2), cfg.get("num_heads", 4)
|
|
83
|
+
if any(type(value) is not int or value < 1 for value in (expand, heads)):
|
|
84
|
+
raise ValueError("mamba_expand and time num_heads must be positive integers")
|
|
85
|
+
if expand * dim % heads:
|
|
86
|
+
raise ValueError("expanded embedding dimension must be divisible by time heads")
|
|
87
|
+
if cfg.get("model_type") != "bi-mamba3" or cfg.get("mamba_conv_width") is not None:
|
|
88
|
+
raise ValueError("checkpoint must use the convolution-free Mamba-3 cell")
|
|
89
|
+
rank = cfg.get("mamba_rank")
|
|
90
|
+
if rank is not None and (type(rank) is not int or rank < 1):
|
|
91
|
+
raise ValueError("mamba_rank must be a positive integer")
|
|
92
|
+
self.mamba = Mamba3(
|
|
93
|
+
d_model=dim,
|
|
94
|
+
d_state=cfg.get("mamba_state_dim", 128),
|
|
95
|
+
expand=expand,
|
|
96
|
+
headdim=expand * dim // heads,
|
|
97
|
+
is_mimo=rank is not None,
|
|
98
|
+
mimo_rank=rank if rank is not None else 1,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def forward(self, x: Tensor) -> Tensor:
|
|
102
|
+
return self.mamba(x)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class TimeMixer(nn.Module):
|
|
106
|
+
"""Causal target mixing and tied bidirectional mixing for known covariates."""
|
|
107
|
+
|
|
108
|
+
def __init__(self, dim: int, cfg: dict[str, Any], constants: dict[str, Any]) -> None:
|
|
109
|
+
super().__init__()
|
|
110
|
+
norm = dict(
|
|
111
|
+
eps=constants.get("norm_eps", 1e-6),
|
|
112
|
+
force_float32_reductions=constants.get("norm_reduction_force_float32", True),
|
|
113
|
+
use_bias=constants.get("use_bias", False),
|
|
114
|
+
)
|
|
115
|
+
self.norm_lstm = RMSNorm(dim, **norm)
|
|
116
|
+
self.fwd_cell = MambaCell(dim, cfg)
|
|
117
|
+
self.rev_cell = self.fwd_cell
|
|
118
|
+
self.combination = nn.Linear(2 * dim, dim, bias=False)
|
|
119
|
+
self.norm_ffn = RMSNorm(dim, **norm)
|
|
120
|
+
self.ffn = GatedFFN(dim, constants)
|
|
121
|
+
|
|
122
|
+
def forward(
|
|
123
|
+
self, x: Tensor, future_mask: Tensor, reverse_indices: Tensor | None = None
|
|
124
|
+
) -> Tensor:
|
|
125
|
+
normalised = self.norm_lstm(x)
|
|
126
|
+
indices = torch.where(future_mask)[0] if reverse_indices is None else reverse_indices
|
|
127
|
+
if indices.numel() and not self.training:
|
|
128
|
+
joined = torch.cat([normalised, normalised[indices].flip(1)])
|
|
129
|
+
mixed = self.fwd_cell(joined)
|
|
130
|
+
out, reverse = mixed[: len(x)], mixed[len(x) :].flip(1)
|
|
131
|
+
else:
|
|
132
|
+
out = self.fwd_cell(normalised)
|
|
133
|
+
if indices.numel():
|
|
134
|
+
reverse = self.rev_cell(normalised[indices].flip(1).contiguous()).flip(1)
|
|
135
|
+
if indices.numel():
|
|
136
|
+
mixed = self.combination(torch.cat([out[indices], reverse], dim=-1))
|
|
137
|
+
out = out.clone()
|
|
138
|
+
out[indices] = mixed.to(out.dtype)
|
|
139
|
+
out = x + out
|
|
140
|
+
return out + self.ffn(self.norm_ffn(out))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _pack_groups(groups: Tensor, targets: Tensor) -> SimpleNamespace | None:
|
|
144
|
+
groups = groups.squeeze(-1) if groups.ndim == 2 else groups
|
|
145
|
+
if groups.shape != targets.shape:
|
|
146
|
+
raise ValueError("group_vector and target_mask must have the same shape")
|
|
147
|
+
_, inverse, counts = torch.unique(groups, return_inverse=True, return_counts=True)
|
|
148
|
+
keep = counts[inverse] > 1
|
|
149
|
+
if not bool(keep.any()):
|
|
150
|
+
return None
|
|
151
|
+
_, group_index, sizes = torch.unique(inverse[keep], return_inverse=True, return_counts=True)
|
|
152
|
+
count, n_groups, width = group_index.numel(), sizes.numel(), int(sizes.max())
|
|
153
|
+
order = torch.argsort(group_index, stable=True)
|
|
154
|
+
first = torch.cumsum(sizes, dim=0) - sizes
|
|
155
|
+
slot = torch.empty_like(group_index)
|
|
156
|
+
slot[order] = torch.arange(count, device=groups.device) - first[group_index[order]]
|
|
157
|
+
flat_idx = group_index * width + slot
|
|
158
|
+
take = torch.full((n_groups * width,), count, device=groups.device)
|
|
159
|
+
take[flat_idx] = torch.arange(count, device=groups.device)
|
|
160
|
+
valid = torch.zeros(n_groups, width, dtype=torch.bool, device=groups.device)
|
|
161
|
+
valid[group_index, slot] = True
|
|
162
|
+
target = torch.zeros_like(valid)
|
|
163
|
+
target[group_index, slot] = targets[keep]
|
|
164
|
+
allowed = valid[:, :, None] & valid[:, None, :]
|
|
165
|
+
allowed &= ~(~target[:, :, None] & target[:, None, :])
|
|
166
|
+
allowed |= ~valid[:, :, None] & torch.eye(width, dtype=torch.bool, device=groups.device)
|
|
167
|
+
return SimpleNamespace(
|
|
168
|
+
regular=False,
|
|
169
|
+
n_groups=n_groups,
|
|
170
|
+
keep=keep,
|
|
171
|
+
take=take,
|
|
172
|
+
flat_idx=flat_idx,
|
|
173
|
+
width=width,
|
|
174
|
+
bias=torch.where(allowed, 0.0, -torch.inf)[:, None],
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
@dataclass(frozen=True)
|
|
179
|
+
class ForecastLayout:
|
|
180
|
+
"""Cached row roles and attention geometry; contained tensors are read-only."""
|
|
181
|
+
|
|
182
|
+
groups: Tensor
|
|
183
|
+
targets: Tensor
|
|
184
|
+
future: Tensor
|
|
185
|
+
past: Tensor
|
|
186
|
+
reverse_indices: Tensor
|
|
187
|
+
packing: SimpleNamespace | None
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@lru_cache(maxsize=32)
|
|
191
|
+
def forecast_layout(
|
|
192
|
+
samples: int, channels: int, targets: int, known: int, device: torch.device
|
|
193
|
+
) -> ForecastLayout:
|
|
194
|
+
"""Reuse geometry for independent samples with equal target and covariate counts."""
|
|
195
|
+
if samples < 1 or not 0 < targets <= channels or not 0 <= known <= channels - targets:
|
|
196
|
+
raise ValueError("forecast layout needs samples and valid channel roles")
|
|
197
|
+
channel = torch.arange(channels, device=device)
|
|
198
|
+
target = channel < targets
|
|
199
|
+
future = (channel >= targets) & (channel < targets + known)
|
|
200
|
+
allowed = ~(~target[:, None] & target[None, :])
|
|
201
|
+
packing = (
|
|
202
|
+
None
|
|
203
|
+
if channels == 1
|
|
204
|
+
else SimpleNamespace(
|
|
205
|
+
regular=True,
|
|
206
|
+
n_groups=samples,
|
|
207
|
+
width=channels,
|
|
208
|
+
bias=torch.where(allowed, 0.0, -torch.inf)[None, None],
|
|
209
|
+
)
|
|
210
|
+
)
|
|
211
|
+
reverse = (
|
|
212
|
+
torch.arange(samples, device=device)[:, None] * channels
|
|
213
|
+
+ torch.arange(targets, targets + known, device=device)[None, :]
|
|
214
|
+
).flatten()
|
|
215
|
+
return ForecastLayout(
|
|
216
|
+
torch.arange(samples, device=device).repeat_interleave(channels),
|
|
217
|
+
target.repeat(samples),
|
|
218
|
+
future.repeat(samples),
|
|
219
|
+
(~(target | future)).repeat(samples),
|
|
220
|
+
reverse,
|
|
221
|
+
packing,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class GroupedAttention(nn.Module):
|
|
226
|
+
"""Attention within each multivariate sample, with asymmetric covariate masking."""
|
|
227
|
+
|
|
228
|
+
def __init__(self, dim: int, cfg: dict[str, Any]) -> None:
|
|
229
|
+
super().__init__()
|
|
230
|
+
self.heads = cfg.get("num_heads", 4)
|
|
231
|
+
if type(self.heads) is not int or self.heads < 1:
|
|
232
|
+
raise ValueError("variate num_heads must be a positive integer")
|
|
233
|
+
if dim % self.heads:
|
|
234
|
+
raise ValueError("embedding dimension must be divisible by variate heads")
|
|
235
|
+
self.head_dim = dim // self.heads
|
|
236
|
+
self.use_qk_norm = cfg.get("use_qk_norm", True)
|
|
237
|
+
self.WK = nn.Linear(dim, dim, bias=False)
|
|
238
|
+
self.WQ = nn.Linear(dim, dim, bias=False)
|
|
239
|
+
self.WV = nn.Linear(dim, dim, bias=False)
|
|
240
|
+
self.WO = nn.Linear(dim, dim, bias=False)
|
|
241
|
+
|
|
242
|
+
def forward(self, x: Tensor, packing: SimpleNamespace) -> Tensor:
|
|
243
|
+
length, rows, _ = x.shape
|
|
244
|
+
heads, hd, width = self.heads, self.head_dim, packing.width
|
|
245
|
+
n_groups = packing.n_groups
|
|
246
|
+
q = self.WQ(x).view(length, rows, heads, hd)
|
|
247
|
+
k = self.WK(x).view(length, rows, heads, hd)
|
|
248
|
+
v = self.WV(x).view(length, rows, heads, hd)
|
|
249
|
+
if self.use_qk_norm:
|
|
250
|
+
q = F.rms_norm(q, (hd,)).to(v.dtype)
|
|
251
|
+
k = F.rms_norm(k, (hd,)).to(v.dtype)
|
|
252
|
+
qkv = torch.cat((q, k, v), dim=2).flatten(2)
|
|
253
|
+
if not packing.regular:
|
|
254
|
+
qkv = F.pad(qkv, (0, 0, 0, 1)).index_select(1, packing.take)
|
|
255
|
+
packed = qkv.view(length, n_groups, width, 3, heads, hd)
|
|
256
|
+
q = packed[:, :, :, 0].permute(0, 1, 3, 2, 4)
|
|
257
|
+
k = packed[:, :, :, 1].permute(0, 1, 3, 2, 4)
|
|
258
|
+
v = packed[:, :, :, 2].permute(0, 1, 3, 2, 4)
|
|
259
|
+
scores = q @ k.transpose(-1, -2) * (1 / math.sqrt(hd)) + packing.bias.to(q.dtype)
|
|
260
|
+
out = (torch.softmax(scores, dim=-1) @ v).permute(0, 1, 3, 2, 4)
|
|
261
|
+
out = out.reshape(length, n_groups * width, heads * hd)
|
|
262
|
+
return self.WO(out if packing.regular else out.index_select(1, packing.flat_idx))
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class MLP(nn.Module):
|
|
266
|
+
"""The variate mixer's feed-forward projection."""
|
|
267
|
+
|
|
268
|
+
def __init__(self, dim: int, act: nn.Module) -> None:
|
|
269
|
+
super().__init__()
|
|
270
|
+
self.wi = nn.Linear(dim, 4 * dim, bias=False)
|
|
271
|
+
self.wo = nn.Linear(4 * dim, dim, bias=False)
|
|
272
|
+
self.act = act
|
|
273
|
+
|
|
274
|
+
def forward(self, x: Tensor) -> Tensor:
|
|
275
|
+
return self.wo(self.act(self.wi(x)))
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class VariateMixer(nn.Module):
|
|
279
|
+
"""Mix related rows; singleton groups pass through unchanged."""
|
|
280
|
+
|
|
281
|
+
def __init__(self, dim: int, cfg: dict[str, Any], act: nn.Module) -> None:
|
|
282
|
+
super().__init__()
|
|
283
|
+
self.norm_attn = nn.RMSNorm(dim, eps=1e-6)
|
|
284
|
+
self.attn = GroupedAttention(dim, cfg)
|
|
285
|
+
self.norm_ffn = nn.RMSNorm(dim, eps=1e-6)
|
|
286
|
+
self.ffn = MLP(dim, act)
|
|
287
|
+
|
|
288
|
+
def forward(self, x: Tensor, packing: SimpleNamespace | None) -> Tensor:
|
|
289
|
+
if packing is None:
|
|
290
|
+
return x
|
|
291
|
+
kept = x if packing.regular else x[:, packing.keep]
|
|
292
|
+
kept = kept + self.attn(self.norm_attn(kept), packing)
|
|
293
|
+
kept = kept + self.ffn(self.norm_ffn(kept))
|
|
294
|
+
if packing.regular:
|
|
295
|
+
return kept
|
|
296
|
+
out = x.clone()
|
|
297
|
+
out[:, packing.keep] = kept
|
|
298
|
+
return out
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class Block(nn.Module):
|
|
302
|
+
"""The time mixer followed by its variate mixer."""
|
|
303
|
+
|
|
304
|
+
def __init__(
|
|
305
|
+
self,
|
|
306
|
+
dim: int,
|
|
307
|
+
cfg: dict[str, Any],
|
|
308
|
+
constants: dict[str, Any],
|
|
309
|
+
act: nn.Module,
|
|
310
|
+
) -> None:
|
|
311
|
+
super().__init__()
|
|
312
|
+
if cfg.get("mixing_order", "time_first") != "time_first":
|
|
313
|
+
raise ValueError("checkpoint must use time_first mixing")
|
|
314
|
+
self.time_mixer = TimeMixer(dim, cfg["time_mixer"], constants)
|
|
315
|
+
self.variate_mixer = VariateMixer(dim, cfg["variate_mixer"], act)
|
|
316
|
+
|
|
317
|
+
def forward(
|
|
318
|
+
self,
|
|
319
|
+
x: Tensor,
|
|
320
|
+
packing: SimpleNamespace | None,
|
|
321
|
+
future_mask: Tensor,
|
|
322
|
+
reverse_indices: Tensor,
|
|
323
|
+
) -> Tensor:
|
|
324
|
+
x = self.time_mixer(x, future_mask, reverse_indices)
|
|
325
|
+
return self.variate_mixer(x.transpose(0, 1), packing).transpose(0, 1)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
class Model(nn.Module):
|
|
329
|
+
"""Inference-only model; dimensions come from the checkpoint configuration.
|
|
330
|
+
|
|
331
|
+
``forward`` maps flattened ``[variables, time]`` rows to
|
|
332
|
+
``[variables, quantiles, padded_time]``. Each output patch predicts the next input patch.
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
def __init__(self, raw: dict[str, Any]) -> None:
|
|
336
|
+
super().__init__()
|
|
337
|
+
self.config = SimpleNamespace(**raw)
|
|
338
|
+
cfg = self.config
|
|
339
|
+
if raw.get("input_embedding") is not None or raw.get("quantile_mlp", False):
|
|
340
|
+
raise ValueError("checkpoint must use the patch embeddings")
|
|
341
|
+
if any(raw["scaler_cfg"].get(key, False) for key in ("causal_patch", "known_whole_row")):
|
|
342
|
+
raise ValueError("checkpoint must use whole-row observed-value scaling")
|
|
343
|
+
for name in (
|
|
344
|
+
"embedding_dim",
|
|
345
|
+
"input_patch_size",
|
|
346
|
+
"output_patch_size",
|
|
347
|
+
"context_len",
|
|
348
|
+
"future_len",
|
|
349
|
+
"num_blocks",
|
|
350
|
+
"input_ff_dim",
|
|
351
|
+
):
|
|
352
|
+
if name == "context_len" and raw[name] is None:
|
|
353
|
+
continue
|
|
354
|
+
if type(raw[name]) is not int or raw[name] < 1:
|
|
355
|
+
raise ValueError(f"{name} must be a positive integer")
|
|
356
|
+
if not math.isfinite(cfg.h_expand) or cfg.h_expand <= 0:
|
|
357
|
+
raise ValueError("h_expand must be positive and finite")
|
|
358
|
+
if int(cfg.embedding_dim * cfg.h_expand) < 1:
|
|
359
|
+
raise ValueError("h_expand must produce at least one hidden feature")
|
|
360
|
+
if cfg.input_patch_size != cfg.output_patch_size:
|
|
361
|
+
raise ValueError("input and output patch sizes must match")
|
|
362
|
+
if (
|
|
363
|
+
not isinstance(cfg.quantiles, (list, tuple))
|
|
364
|
+
or not cfg.quantiles
|
|
365
|
+
or any(not 0 < q < 1 for q in cfg.quantiles)
|
|
366
|
+
):
|
|
367
|
+
raise ValueError("quantiles must be levels in (0, 1)")
|
|
368
|
+
if any(b <= a for a, b in zip(cfg.quantiles, cfg.quantiles[1:], strict=False)):
|
|
369
|
+
raise ValueError("quantiles must be strictly increasing")
|
|
370
|
+
recipe = cfg.stack_config["recipe"]
|
|
371
|
+
if len(recipe) != cfg.num_blocks:
|
|
372
|
+
raise ValueError("recipe length must equal num_blocks")
|
|
373
|
+
activation = raw.get("act_func", "SiLU").removeprefix("torch.nn.")
|
|
374
|
+
if activation not in ("SiLU", "GELU", "ReLU"):
|
|
375
|
+
raise ValueError(f"unsupported activation {activation!r}")
|
|
376
|
+
act = getattr(nn, activation)()
|
|
377
|
+
dim = cfg.embedding_dim
|
|
378
|
+
self.input_patch_embedding = ResidualBlock(
|
|
379
|
+
cfg.input_patch_size * 2, cfg.input_ff_dim, dim, act
|
|
380
|
+
)
|
|
381
|
+
self.stack = nn.ModuleList(
|
|
382
|
+
Block(dim, cfg.stack_config["templates"][name], raw.get("xlstm", {}), act)
|
|
383
|
+
for name in recipe
|
|
384
|
+
)
|
|
385
|
+
norm = raw.get("stack_out_norm_config")
|
|
386
|
+
self.stack_out_norm = (
|
|
387
|
+
nn.Identity()
|
|
388
|
+
if norm is None
|
|
389
|
+
else nn.RMSNorm(dim, eps=norm.get("eps", 1e-7))
|
|
390
|
+
if norm.get("use_rmsnorm", False)
|
|
391
|
+
else RMSLayerNorm(dim, norm.get("eps", 1e-7))
|
|
392
|
+
)
|
|
393
|
+
self.register_buffer("quantiles", torch.tensor(cfg.quantiles), persistent=False)
|
|
394
|
+
self.output_patch_embedding = ResidualBlock(
|
|
395
|
+
dim,
|
|
396
|
+
int(dim * cfg.h_expand),
|
|
397
|
+
len(cfg.quantiles) * cfg.output_patch_size,
|
|
398
|
+
act,
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
def forward(
|
|
402
|
+
self,
|
|
403
|
+
batch: dict[str, Tensor],
|
|
404
|
+
*,
|
|
405
|
+
future_len: int | None = None,
|
|
406
|
+
horizon: int | None = None,
|
|
407
|
+
layout: ForecastLayout | None = None,
|
|
408
|
+
) -> Tensor:
|
|
409
|
+
"""Run inference, projecting only forecast tokens when ``horizon`` is supplied."""
|
|
410
|
+
x = batch["x"]
|
|
411
|
+
future_len = self.config.future_len if future_len is None else future_len
|
|
412
|
+
groups, targets = batch.get("group_vector"), batch.get("target_mask")
|
|
413
|
+
future, past = batch.get("future_covariate_mask"), batch.get("past_covariate_mask")
|
|
414
|
+
if groups is None:
|
|
415
|
+
if targets is not None:
|
|
416
|
+
raise ValueError("target_mask requires group_vector")
|
|
417
|
+
groups = torch.arange(x.shape[0], device=x.device)
|
|
418
|
+
if targets is None:
|
|
419
|
+
if future is not None or past is not None:
|
|
420
|
+
raise ValueError("covariate masks require target_mask")
|
|
421
|
+
targets = torch.ones(x.shape[0], dtype=torch.bool, device=x.device)
|
|
422
|
+
declared = future is not None or past is not None
|
|
423
|
+
future = torch.zeros_like(targets) if future is None else future
|
|
424
|
+
past = ~(targets | future) if past is None else past
|
|
425
|
+
if layout is not None:
|
|
426
|
+
if (
|
|
427
|
+
groups is not layout.groups
|
|
428
|
+
or targets is not layout.targets
|
|
429
|
+
or future is not layout.future
|
|
430
|
+
or past is not layout.past
|
|
431
|
+
or groups.shape != (x.shape[0],)
|
|
432
|
+
or groups.device != x.device
|
|
433
|
+
):
|
|
434
|
+
raise ValueError("forecast layout must match the batch masks and rows")
|
|
435
|
+
else:
|
|
436
|
+
if bool((future & targets).any()) or bool((past & (targets | future)).any()):
|
|
437
|
+
raise ValueError("target and covariate masks must not overlap")
|
|
438
|
+
if not bool((targets | future | past).all()):
|
|
439
|
+
raise ValueError("target and covariate masks must cover every row")
|
|
440
|
+
if horizon is not None and (type(horizon) is not int or not 0 < horizon <= future_len):
|
|
441
|
+
raise ValueError("horizon must be a positive integer within the future window")
|
|
442
|
+
if declared:
|
|
443
|
+
if x.shape[-1] < future_len:
|
|
444
|
+
raise ValueError("inputs with covariate masks must include the full future window")
|
|
445
|
+
window = torch.zeros_like(x, dtype=torch.bool)
|
|
446
|
+
window[:, -future_len:] = (targets | past)[:, None]
|
|
447
|
+
x = torch.where(window, torch.nan, x)
|
|
448
|
+
|
|
449
|
+
scaler = self.config.scaler_cfg
|
|
450
|
+
wide = x.double()
|
|
451
|
+
loc = torch.nan_to_num(torch.nanmean(wide, dim=-1, keepdim=True), nan=0.0)
|
|
452
|
+
scale = torch.nan_to_num(
|
|
453
|
+
torch.nanmean((wide - loc) ** 2, dim=-1, keepdim=True).sqrt(), nan=1.0
|
|
454
|
+
)
|
|
455
|
+
scale = scale.clamp_min(scaler.get("eps", 1e-8))
|
|
456
|
+
binary = torch.zeros_like(loc, dtype=torch.bool)
|
|
457
|
+
if scaler.get("binaryaware", False):
|
|
458
|
+
binary = ((x == 0) | (x == 1) | torch.isnan(x)).all(dim=-1, keepdim=True)
|
|
459
|
+
loc = torch.where(binary, 0.0, loc)
|
|
460
|
+
scale = torch.where(binary, 1.0, scale)
|
|
461
|
+
values = ((wide - loc) / scale).to(x.dtype)
|
|
462
|
+
loc, scale = loc.to(x.dtype), scale.to(x.dtype)
|
|
463
|
+
if scaler.get("use_arcsinh", False):
|
|
464
|
+
values = torch.where(binary, values, values.asinh())
|
|
465
|
+
patch = self.config.input_patch_size
|
|
466
|
+
values = F.pad(values, ((-values.shape[-1]) % patch, 0), value=torch.nan)
|
|
467
|
+
values = values.unfold(-1, patch, patch)
|
|
468
|
+
present = (~torch.isnan(values)).to(values.dtype)
|
|
469
|
+
x = self.input_patch_embedding(
|
|
470
|
+
torch.cat((torch.nan_to_num(values, nan=0.0), present), dim=-1)
|
|
471
|
+
)
|
|
472
|
+
packing = _pack_groups(groups, targets) if layout is None else layout.packing
|
|
473
|
+
reverse_indices = torch.where(future)[0] if layout is None else layout.reverse_indices
|
|
474
|
+
for block in self.stack:
|
|
475
|
+
x = block(x, packing, future, reverse_indices)
|
|
476
|
+
if horizon is not None:
|
|
477
|
+
start = x.shape[1] * patch - future_len - patch
|
|
478
|
+
if start < 0:
|
|
479
|
+
raise ValueError("forecast projection needs a context patch before the future")
|
|
480
|
+
offset = start % patch
|
|
481
|
+
x = x[:, start // patch : -(-(start + horizon) // patch)]
|
|
482
|
+
x = self.output_patch_embedding(self.stack_out_norm(x))
|
|
483
|
+
x = x.unflatten(-1, (len(self.config.quantiles), self.config.output_patch_size))
|
|
484
|
+
x = x.transpose(1, 2).flatten(2)
|
|
485
|
+
if horizon is not None:
|
|
486
|
+
x = x[..., offset : offset + horizon]
|
|
487
|
+
if scaler.get("use_arcsinh", False):
|
|
488
|
+
x = torch.where(binary[:, None], x, torch.sinh(x.clamp(-20.0, 20.0)))
|
|
489
|
+
return x * scale[:, None] + loc[:, None]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: continuousintelligence
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Continuous Intelligence models
|
|
5
|
+
Author: Continuous Intelligence
|
|
6
|
+
License-Expression: LicenseRef-ci-proto AND Apache-2.0 AND CC-BY-4.0
|
|
7
|
+
Project-URL: Repository, https://github.com/continuousintelligence/ci
|
|
8
|
+
Project-URL: Issues, https://github.com/continuousintelligence/ci/issues
|
|
9
|
+
Keywords: time-series,forecasting,pytorch
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: <3.15,>=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENCE
|
|
15
|
+
License-File: NOTICE
|
|
16
|
+
License-File: src/continuousintelligence/_vendor/mamba3/LICENSE
|
|
17
|
+
License-File: src/continuousintelligence/_data/NOTICE
|
|
18
|
+
Requires-Dist: torch<3,>=2.7
|
|
19
|
+
Requires-Dist: einops<1,>=0.8
|
|
20
|
+
Requires-Dist: huggingface-hub<3,>=1
|
|
21
|
+
Requires-Dist: numpy<3,>=1.26
|
|
22
|
+
Requires-Dist: pandas<4,>=2.2
|
|
23
|
+
Requires-Dist: matplotlib<4,>=3.8
|
|
24
|
+
Requires-Dist: tilelang==0.1.8; sys_platform == "linux" and platform_machine == "x86_64"
|
|
25
|
+
Requires-Dist: apache-tvm-ffi==0.1.9; sys_platform == "linux" and platform_machine == "x86_64"
|
|
26
|
+
Requires-Dist: cuda-toolkit[cccl,nvcc]==13.0.3; sys_platform == "linux" and platform_machine == "x86_64"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
Continuous Intelligence models.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
continuousintelligence/__init__.py,sha256=mMINa3l_ONFkf73PggWlf6EnrNc1j7pJHvvL5olYriA,280
|
|
2
|
+
continuousintelligence/_example.py,sha256=2tQEiOIjHPnl9dgOhg9LwbXBi4LnFh7hxhyE4IrcDMQ,684
|
|
3
|
+
continuousintelligence/_loader.py,sha256=cwUnEZYG866AujRm7hAvYH4nX2xvJJ3S6XT-7fZyFFU,5674
|
|
4
|
+
continuousintelligence/_plot.py,sha256=WtPfsaqvT7TBObKBJy6aNPf_EQouJenNwjjfSeSg2bQ,7020
|
|
5
|
+
continuousintelligence/_data/NOTICE,sha256=nC81Qn6e29vQBuoDSIWpA6oeQHme6RMs76MqeTeIxxE,862
|
|
6
|
+
continuousintelligence/_data/bike_sharing.csv,sha256=dPkIrgTX9tmcgN7gbTbVfnsukGyRdBgp7aCz2T2hG40,4541
|
|
7
|
+
continuousintelligence/_vendor/__init__.py,sha256=osJhrkQ_bAFHe96lZSnQifsAgfxnBUGnbn2M3Hnomm0,45
|
|
8
|
+
continuousintelligence/_vendor/mamba3/LICENSE,sha256=dgk5sAAZTQRUjt5qhXu-c10WldhCLshZVcjivX9LlcU,11348
|
|
9
|
+
continuousintelligence/_vendor/mamba3/__init__.py,sha256=QQ6V4-KBk2eW5B3bROT6aQ7JWoYtGqCFJzdp2BO9AP8,288
|
|
10
|
+
continuousintelligence/_vendor/mamba3/angle_dt.py,sha256=lOmknsjhhN-MK9kCm7pUcATY0SSlLeLu0pohOgCEiTc,7853
|
|
11
|
+
continuousintelligence/_vendor/mamba3/layernorm_gated.py,sha256=wRpJ1_cbaGkJvarsSSZZSzBfAAGHq1OvSSG2TmXAnOU,4446
|
|
12
|
+
continuousintelligence/_vendor/mamba3/mamba3_mimo_fwd.py,sha256=0PKcUDH7z9bWL1glVHer1nbu4CAKg6uU4WW4lg3RCvc,25299
|
|
13
|
+
continuousintelligence/_vendor/mamba3/mamba3_mimo_utils.py,sha256=Ki8uHNkeHcRRNROOQ10v-EEin0cQ6iHPUjrEomBNKhs,4108
|
|
14
|
+
continuousintelligence/_vendor/mamba3/utils.py,sha256=-LxmlDD3fjGcz0gOhf882AysTHjOmgGjrHh2nni8lzQ,638
|
|
15
|
+
continuousintelligence/ci_proto/__init__.py,sha256=MzD0PvnJtzxmm9WU6DsxijRUbeqqMmc11U-MUygY8qE,123
|
|
16
|
+
continuousintelligence/ci_proto/_calendar.py,sha256=TBVXFUGor4vGo6evNHrADpwDETJQfFPhsC9BegBHpKY,6241
|
|
17
|
+
continuousintelligence/ci_proto/_checkpoint.py,sha256=2gQUni7cyT_Do29Mb9HvkSv7RKfwnoJOBvfby7BvbKQ,3915
|
|
18
|
+
continuousintelligence/ci_proto/_cuda.py,sha256=EAzUszvFiA_B-0pD1GdixTRQT0liq0QzEgsKfY0g0FI,4677
|
|
19
|
+
continuousintelligence/ci_proto/_forecast.py,sha256=R5loGodDtezezKIr0GpgvPrQjV_T7Jo2QITKkVVg2Pg,29229
|
|
20
|
+
continuousintelligence/ci_proto/_groups.py,sha256=_sYnnHN9t2nqdHPSie_fJp_5J4Lur-u3TE76UyTT6rw,8700
|
|
21
|
+
continuousintelligence/ci_proto/_mamba.py,sha256=kUQ20eXaQTkP-1C5SvYnkcnNPck-tF8YwWXtKE2fVYg,7831
|
|
22
|
+
continuousintelligence/ci_proto/_model.py,sha256=73hvFZcVOSYzPcf6_V82qJDYVo_pCg8XVIHYyvgBV0E,21086
|
|
23
|
+
continuousintelligence-0.1.0.dist-info/licenses/LICENCE,sha256=h3Xjtb2lkB5Yy7h95dGsAJ4iY7FiMzJpAIdmdtvJRX4,12209
|
|
24
|
+
continuousintelligence-0.1.0.dist-info/licenses/NOTICE,sha256=D_tj2WZNeW4Ei_032aVYEgO_lpa-ALPTjKFmWFlWFIg,950
|
|
25
|
+
continuousintelligence-0.1.0.dist-info/licenses/src/continuousintelligence/_data/NOTICE,sha256=nC81Qn6e29vQBuoDSIWpA6oeQHme6RMs76MqeTeIxxE,862
|
|
26
|
+
continuousintelligence-0.1.0.dist-info/licenses/src/continuousintelligence/_vendor/mamba3/LICENSE,sha256=dgk5sAAZTQRUjt5qhXu-c10WldhCLshZVcjivX9LlcU,11348
|
|
27
|
+
continuousintelligence-0.1.0.dist-info/METADATA,sha256=me-034_-QAr6nD8-A3p2VhIUMzaDAoxPKamoOLvrqJs,1284
|
|
28
|
+
continuousintelligence-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
29
|
+
continuousintelligence-0.1.0.dist-info/top_level.txt,sha256=R7024Pn46kFpRKtfXWCQhefsNaLNaYJwRmoyMTAAKXg,23
|
|
30
|
+
continuousintelligence-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# ci-proto Code and Model Licence
|
|
2
|
+
|
|
3
|
+
Version 1.0, 10 November 2026
|
|
4
|
+
|
|
5
|
+
Licensor: Continuous Intelligence Limited
|
|
6
|
+
Release: ci-proto
|
|
7
|
+
Copyright 2026 Continuous Intelligence Limited
|
|
8
|
+
|
|
9
|
+
This licence is based on the Apache License, Version 2.0, with additional attribution and notification requirements in Section 10. It is designed to cover both software source code and AI model weights, with Section 10 also addressing the use of model outputs to develop other AI models.
|
|
10
|
+
|
|
11
|
+
**In brief:** Free for research and commercial use, subject to the attribution and notification requirements in Section 10. Redistribution and use in externally available products or services require public attribution and a one-time notification to Continuous Intelligence. Purely internal use is exempt from these additional requirements.
|
|
12
|
+
|
|
13
|
+
This summary is provided for convenience. The terms below govern use of the code and model.
|
|
14
|
+
|
|
15
|
+
## Terms and conditions for use, reproduction, and distribution
|
|
16
|
+
|
|
17
|
+
### 1. Definitions.
|
|
18
|
+
|
|
19
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 10 of this document.
|
|
20
|
+
|
|
21
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
22
|
+
|
|
23
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
30
|
+
|
|
31
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
|
32
|
+
|
|
33
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
34
|
+
|
|
35
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
36
|
+
|
|
37
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
38
|
+
|
|
39
|
+
### 2. Grant of Copyright License.
|
|
40
|
+
|
|
41
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
42
|
+
|
|
43
|
+
### 3. Grant of Patent License.
|
|
44
|
+
|
|
45
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
46
|
+
|
|
47
|
+
### 4. Redistribution.
|
|
48
|
+
|
|
49
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
50
|
+
|
|
51
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
52
|
+
|
|
53
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
54
|
+
|
|
55
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
56
|
+
|
|
57
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
58
|
+
|
|
59
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
60
|
+
|
|
61
|
+
### 5. Submission of Contributions.
|
|
62
|
+
|
|
63
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
64
|
+
|
|
65
|
+
### 6. Trademarks.
|
|
66
|
+
|
|
67
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work, reproducing the content of the NOTICE file, and complying with Section 10.
|
|
68
|
+
|
|
69
|
+
### 7. Disclaimer of Warranty.
|
|
70
|
+
|
|
71
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
72
|
+
|
|
73
|
+
### 8. Limitation of Liability.
|
|
74
|
+
|
|
75
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
76
|
+
|
|
77
|
+
### 9. Accepting Warranty or Additional Liability.
|
|
78
|
+
|
|
79
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
80
|
+
|
|
81
|
+
### 10. Additional attribution and notification.
|
|
82
|
+
|
|
83
|
+
For the purposes of this Section 10, "model weights" means the trained numerical parameters of the ci-proto model as released by the Licensor, which together determine the behaviour of the model.
|
|
84
|
+
|
|
85
|
+
If You distribute or make available the Work or any Derivative Work thereof relating to any part of the source or model weights, or a product or service (including another AI model) that contains or uses any of the Work's source code or model weights, You shall (A) provide a copy of this License with any such materials You distribute; and (B) prominently display "Uses ci-proto, released by Continuous Intelligence. Continuous Intelligence does not endorse or approve this product or service." on each related website, user interface, blogpost, about page, or product documentation. The attribution must be publicly accessible.
|
|
86
|
+
|
|
87
|
+
If You use the Work's source code, model weights or model outputs to create, train, fine tune, distil, or otherwise improve an AI model, which is distributed or made available, the attribution and notification requirements of this Section 10 shall also apply to that AI model and any externally available product or service that contains or uses it.
|
|
88
|
+
|
|
89
|
+
For each model released by Continuous Intelligence Limited whose source code, model weights or model outputs You use, You shall notify contact@continuousintelligence.co.uk once, on or before Your first distribution or making available under this Section 10, identifying You, the relevant model, a brief description of Your use or distribution, and the location of Your public attribution; this notification covers resulting models described above and does not require approval by the Licensor.
|
|
90
|
+
|
|
91
|
+
The Licensor may, by written notice, require You to remove the public-facing attribution required by this Section 10 from materials under Your control within 30 days of receiving that notice. The corresponding attribution requirement is waived for those materials. Required copyright and legal notices must remain. This does not affect Your other rights or obligations under this License.
|
|
92
|
+
|
|
93
|
+
The requirements of this Section 10 do not apply to purely internal use.
|
|
94
|
+
|
|
95
|
+
END OF TERMS AND CONDITIONS
|