basal-engine 3.0.3__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.
- basal/__init__.py +7 -0
- basal/adapter.py +420 -0
- basal/adapters.py +8 -0
- basal/agree.py +393 -0
- basal/attach.py +160 -0
- basal/attn512.py +132 -0
- basal/auth.py +194 -0
- basal/bench.py +367 -0
- basal/blockquant.py +227 -0
- basal/calibrate.py +2198 -0
- basal/chat.py +175 -0
- basal/cli.py +70 -0
- basal/client.py +8 -0
- basal/decision_log.py +189 -0
- basal/decision_rules.py +569 -0
- basal/decisions.py +158 -0
- basal/derive.py +98 -0
- basal/disconnect.py +85 -0
- basal/engine.py +6023 -0
- basal/evidence.py +133 -0
- basal/examples/choice.jsonl +8 -0
- basal/examples/complex.jsonl +5 -0
- basal/examples/labelled_tickets.jsonl +500 -0
- basal/examples/local_backend.py +34 -0
- basal/examples/noul.jsonl +8 -0
- basal/examples/questions.jsonl +20 -0
- basal/examples/score.jsonl +8 -0
- basal/examples/selfcheck_basal-omni-pico-Q8_0.json +1 -0
- basal/examples/selfcheck_basal-omni-pico.json +1 -0
- basal/examples/types_demo.py +74 -0
- basal/facts.py +497 -0
- basal/feedback.py +234 -0
- basal/file_identity.py +39 -0
- basal/finetune.py +321 -0
- basal/fit_decisions.py +944 -0
- basal/fla_configs.json +1822 -0
- basal/fold.py +206 -0
- basal/fonts/OFL-DMSans.txt +93 -0
- basal/fonts/OFL-SpaceGrotesk.txt +93 -0
- basal/fonts/dm-sans-latin-ext.woff2 +0 -0
- basal/fonts/dm-sans-latin.woff2 +0 -0
- basal/fonts/space-grotesk-latin-ext.woff2 +0 -0
- basal/fonts/space-grotesk-latin.woff2 +0 -0
- basal/fp8block.py +100 -0
- basal/gdn_graph.py +1792 -0
- basal/gemma4.py +726 -0
- basal/gemma4_graph.py +931 -0
- basal/gguf_export.py +497 -0
- basal/identity.py +217 -0
- basal/int8block.py +50 -0
- basal/interpolate.py +330 -0
- basal/jsonl.py +172 -0
- basal/lean.py +204 -0
- basal/llama_attn.py +252 -0
- basal/llama_attn_kernels.py +266 -0
- basal/llama_graph.py +587 -0
- basal/llama_kernels.py +593 -0
- basal/loadtest.py +189 -0
- basal/mcp_server.py +432 -0
- basal/media.py +138 -0
- basal/metrics.py +16 -0
- basal/mlx_attn_kernels.py +1057 -0
- basal/mlx_forward.py +326 -0
- basal/mlx_kernels.py +543 -0
- basal/mlx_metal.py +510 -0
- basal/navcut.py +283 -0
- basal/navigate.py +646 -0
- basal/navtree.py +397 -0
- basal/nvfp4.py +245 -0
- basal/ordercheck.py +165 -0
- basal/pdf.py +183 -0
- basal/prepared.py +355 -0
- basal/presets.py +8 -0
- basal/prompt.py +462 -0
- basal/rank.py +373 -0
- basal/readout.py +121 -0
- basal/request.py +327 -0
- basal/response_cache.py +105 -0
- basal/router.py +1551 -0
- basal/router_ui.html +902 -0
- basal/router_ui.py +277 -0
- basal/run.py +376 -0
- basal/selfcheck.py +215 -0
- basal/server.py +5279 -0
- basal/sets.py +214 -0
- basal/signals.py +28 -0
- basal/state_disk.py +942 -0
- basal/strix.py +505 -0
- basal/synth.py +92 -0
- basal/tasks.py +848 -0
- basal/textio.py +21 -0
- basal/think.py +390 -0
- basal/tools.py +171 -0
- basal/tpu.py +336 -0
- basal/tpu_kernels.py +129 -0
- basal/trace.py +125 -0
- basal/ui.html +861 -0
- basal/ui.py +526 -0
- basal/varloop.py +813 -0
- basal/varloop_graph.py +1377 -0
- basal/varloop_kernels.py +907 -0
- basal/viz.html +660 -0
- basal/viz.py +375 -0
- basal/vllm_unified.py +100 -0
- basal_engine-3.0.3.dist-info/METADATA +416 -0
- basal_engine-3.0.3.dist-info/RECORD +111 -0
- basal_engine-3.0.3.dist-info/WHEEL +5 -0
- basal_engine-3.0.3.dist-info/entry_points.txt +21 -0
- basal_engine-3.0.3.dist-info/licenses/LICENSE +202 -0
- basal_engine-3.0.3.dist-info/licenses/NOTICE +34 -0
- basal_engine-3.0.3.dist-info/top_level.txt +1 -0
basal/navcut.py
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"""A calibrated cut-off for how many pages basal-navigate opens (3.0): per level of the tree, the smallest score a branch
|
|
2
|
+
needs to be opened, fitted on your labelled queries so that the page that holds the answer survives every level with
|
|
3
|
+
probability at least `coverage` on queries like them (split conformal, a union bound over the levels).
|
|
4
|
+
|
|
5
|
+
basal-navigate calibrate tree.jsonl labels.jsonl --url http://127.0.0.1:8000 --coverage 0.9 -o cutoff.json
|
|
6
|
+
basal-navigate search tree.jsonl "How long does a visa take?" --levels @cutoff.json
|
|
7
|
+
|
|
8
|
+
Labels (JSONL): {"id"?, "query" | "turns", "pages": [page ids] | "passages": [passage ids]}: the pages that hold the
|
|
9
|
+
answer (a passage counts its page). The queries must be like those the search will get: the guarantee is over
|
|
10
|
+
queries drawn the same way (exchangeable), for this tree, this model and these settings.
|
|
11
|
+
|
|
12
|
+
Method. The labelled queries are split at random into FIT and CERT (--cert-share). Level by level from the top, every
|
|
13
|
+
FIT query whose answer pages are still reachable is searched down to that level, with the levels above it already
|
|
14
|
+
cut, as the search will be, and the score of its best answer branch there (the page itself, or the topic or section
|
|
15
|
+
above it) is kept. With n such scores and alpha_d = (1 - coverage) / L for the L levels down to the deepest answer
|
|
16
|
+
page, the level's cut-off is the k-th smallest, k = floor((n + 1) * alpha_d): a new query's answer branch scores at
|
|
17
|
+
least that with probability at least 1 - alpha_d, so all L levels keep it with probability at least `coverage`. When
|
|
18
|
+
n < 1 / alpha_d - 1 there is no such quantile: the calibration stops and says how many queries the level needs. Each
|
|
19
|
+
level keeps the branches at or above its cut-off ("min_p"), at least one, at most --max-keep ("keep"; the cap can only
|
|
20
|
+
cost coverage, and CERT measures it with the cap). Deeper levels (inside a page) keep the given --levels.
|
|
21
|
+
|
|
22
|
+
The file holds the levels for `--levels @cutoff.json`, the model it was fitted with (GET /v1/models), the tree's
|
|
23
|
+
sha256, the settings, and a report on CERT: coverage, pages opened, and the same for the given --levels. A search with
|
|
24
|
+
it on another model stops unless --force (the scores are that model's); another tree or other settings warn.
|
|
25
|
+
"""
|
|
26
|
+
import datetime
|
|
27
|
+
import hashlib
|
|
28
|
+
import json
|
|
29
|
+
import math
|
|
30
|
+
import random
|
|
31
|
+
import statistics
|
|
32
|
+
from fractions import Fraction
|
|
33
|
+
|
|
34
|
+
from .jsonl import JSONLError, records
|
|
35
|
+
from .navigate import Navigator, select
|
|
36
|
+
from .textio import open_text
|
|
37
|
+
|
|
38
|
+
FORMAT = 1
|
|
39
|
+
SETTINGS = ("style", "lang", "chunk", "order", "turns", "wording")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class CutoffError(ValueError):
|
|
43
|
+
"""Labels or a calibration that cannot give a cut-off: what is wrong and what to change."""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def page_of(tree, i):
|
|
47
|
+
"""The page a node is on: itself or its nearest ancestor of kind "page" (a tree without pages: the node's parent,
|
|
48
|
+
or the node at the top)."""
|
|
49
|
+
j = i
|
|
50
|
+
while j is not None:
|
|
51
|
+
if tree.nodes[j].get("kind") == "page":
|
|
52
|
+
return j
|
|
53
|
+
j = tree.nodes[j].get("parent")
|
|
54
|
+
return tree.nodes[i].get("parent") if tree.leaf(i) and tree.nodes[i].get("parent") is not None else i
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def path_of(tree, i):
|
|
58
|
+
"""The ids from the top of the tree down to node i."""
|
|
59
|
+
out = []
|
|
60
|
+
while i is not None:
|
|
61
|
+
out.append(i)
|
|
62
|
+
i = tree.nodes[i].get("parent")
|
|
63
|
+
return out[::-1]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def read_labels(path, tree):
|
|
67
|
+
"""[{"line", "id", "query", "gold": {page ids}}] of a labels file; CutoffError naming the line of a bad one."""
|
|
68
|
+
out = []
|
|
69
|
+
try:
|
|
70
|
+
for n, rec in records(path, objects=True):
|
|
71
|
+
query = rec.get("turns") or rec.get("query")
|
|
72
|
+
if not query or not isinstance(query, (str, list)):
|
|
73
|
+
raise CutoffError(f"{path}:{n}: a label needs a \"query\" (or \"turns\")")
|
|
74
|
+
given = [("pages", x) for x in rec.get("pages") or ()] + [("passages", x) for x in rec.get("passages") or ()]
|
|
75
|
+
if not given:
|
|
76
|
+
raise CutoffError(f"{path}:{n}: a label needs \"pages\" or \"passages\" (the pages with the answer)")
|
|
77
|
+
gold = set()
|
|
78
|
+
for field, x in given:
|
|
79
|
+
if x not in tree.nodes:
|
|
80
|
+
raise CutoffError(f"{path}:{n}: {field}: {x!r} is not a node of the tree")
|
|
81
|
+
if field == "passages" and not tree.leaf(x):
|
|
82
|
+
raise CutoffError(f"{path}:{n}: passages: {x!r} is not a passage (it has children)")
|
|
83
|
+
gold.add(page_of(tree, x))
|
|
84
|
+
if any(tree.leaf(g) for g in gold):
|
|
85
|
+
raise CutoffError(f"{path}:{n}: an answer page must have passages under it, as the tree's pages do")
|
|
86
|
+
out.append({"line": n, "id": rec.get("id", n), "query": query, "gold": gold})
|
|
87
|
+
except JSONLError as e:
|
|
88
|
+
raise CutoffError(str(e)) from None
|
|
89
|
+
if not out:
|
|
90
|
+
raise CutoffError(f"{path}: no labelled queries")
|
|
91
|
+
return out
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def needed(alpha):
|
|
95
|
+
"""The fewest scores whose floor((n + 1) * alpha)-th smallest exists: n >= 1 / alpha - 1."""
|
|
96
|
+
return math.ceil(1 / alpha - 1)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def cutoff(scores, alpha):
|
|
100
|
+
"""The split-conformal cut-off of answer-branch scores at miscoverage alpha (a Fraction): the
|
|
101
|
+
floor((n + 1) * alpha)-th smallest; CutoffError when n is too small for it to exist."""
|
|
102
|
+
n = len(scores)
|
|
103
|
+
k = math.floor((n + 1) * alpha)
|
|
104
|
+
if k < 1:
|
|
105
|
+
raise CutoffError(f"{n} queries, fewer than the {needed(alpha)} that miscoverage {float(alpha):.4g} needs")
|
|
106
|
+
return sorted(scores)[k - 1]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def tree_sha(path):
|
|
110
|
+
h = hashlib.sha256()
|
|
111
|
+
with open(path, "rb") as f:
|
|
112
|
+
for chunk in iter(lambda: f.read(1 << 20), b""):
|
|
113
|
+
h.update(chunk)
|
|
114
|
+
return h.hexdigest()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _base(levels, depth):
|
|
118
|
+
return dict(levels[min(depth, len(levels) - 1)])
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def reached(tree, trace, gold):
|
|
122
|
+
"""The answer pages a traced search opened (kept at their own level)."""
|
|
123
|
+
kept = {i for t in trace for i in t["kept"]}
|
|
124
|
+
return {g for g in gold if g in kept}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def calibrate(client, tree, labels, coverage=0.9, max_keep=50, levels=None, settings=None, cert_share=0.5, seed=0):
|
|
128
|
+
"""The cut-off levels and the report (module docstring) -> {"levels", "fitted", "report"}; CutoffError when the
|
|
129
|
+
labels are too few for `coverage` at a level."""
|
|
130
|
+
if not 0 < coverage < 1:
|
|
131
|
+
raise CutoffError(f"--coverage must be between 0 and 1, not {coverage}")
|
|
132
|
+
if not 0 <= cert_share < 1:
|
|
133
|
+
raise CutoffError(f"--cert-share must be at least 0 and below 1, not {cert_share}")
|
|
134
|
+
if max_keep < 1:
|
|
135
|
+
raise CutoffError(f"--max-keep must be at least 1, not {max_keep}")
|
|
136
|
+
base = [dict(b) for b in (levels or [{"keep": 10}])]
|
|
137
|
+
settings = {k: v for k, v in (settings or {}).items() if v is not None} # (unset: Navigator's defaults)
|
|
138
|
+
order = list(range(len(labels)))
|
|
139
|
+
random.Random(seed).shuffle(order)
|
|
140
|
+
n_cert = round(len(labels) * cert_share)
|
|
141
|
+
cert, fit = [labels[i] for i in sorted(order[:n_cert])], [labels[i] for i in sorted(order[n_cert:])]
|
|
142
|
+
paths = {g: path_of(tree, g) for q in labels for g in q["gold"]}
|
|
143
|
+
depth = max(len(paths[g]) for q in labels for g in q["gold"]) # levels down to the deepest answer page
|
|
144
|
+
alpha = (1 - Fraction(str(coverage))) / depth
|
|
145
|
+
cut, fitted, alive, requests = [], [], {q["line"]: set(q["gold"]) for q in fit}, 0
|
|
146
|
+
for d in range(depth):
|
|
147
|
+
nav = Navigator(client, tree, levels=cut + [{"keep": max_keep, "min_p": 0.0}], **settings)
|
|
148
|
+
scores, rankings, lost = [], {}, 0
|
|
149
|
+
for q in fit:
|
|
150
|
+
pages = {g for g in alive[q["line"]] if len(paths[g]) > d} # (an answer page above this level is reached)
|
|
151
|
+
if not pages:
|
|
152
|
+
continue
|
|
153
|
+
trace = []
|
|
154
|
+
r = nav.search(q["query"], trace=trace, depth_limit=d)
|
|
155
|
+
requests += sum(s["requests"] for s in r["stages"])
|
|
156
|
+
level = trace[-1] if trace and trace[-1]["depth"] == d else None
|
|
157
|
+
ranking = dict(level["ranking"] or []) if level else {}
|
|
158
|
+
branches = {paths[g][d] for g in pages}
|
|
159
|
+
score = max((ranking[b] for b in branches if b in ranking), default=None)
|
|
160
|
+
if score is None: # the levels above pruned its answer pages in this pass, though they kept them in the
|
|
161
|
+
# last: the server's scores moved between the passes (a warm state cache, other queries in between).
|
|
162
|
+
# Lost at a level above, as for a new query; this level is fitted on the others.
|
|
163
|
+
alive[q["line"]] = {g for g in alive[q["line"]] if len(paths[g]) <= d}
|
|
164
|
+
lost += 1
|
|
165
|
+
continue
|
|
166
|
+
scores.append(score)
|
|
167
|
+
rankings[q["line"]] = (level["ranking"], pages)
|
|
168
|
+
try:
|
|
169
|
+
t = cutoff(scores, alpha)
|
|
170
|
+
except CutoffError as e:
|
|
171
|
+
raise CutoffError(f"depth {d} (level {d + 1} of {depth}): {e}: coverage {coverage} over {depth} levels "
|
|
172
|
+
f"needs at least {needed(alpha)} FIT queries whose answer is at or below this level; give "
|
|
173
|
+
"more labelled queries, a lower --coverage, or a lower --cert-share") from None
|
|
174
|
+
level = {"min_p": float(t), "keep": max_keep}
|
|
175
|
+
cut.append(level)
|
|
176
|
+
fitted.append({"depth": d, "n": len(scores), "alpha": float(alpha), "k": math.floor((len(scores) + 1) * alpha),
|
|
177
|
+
"threshold": float(t), "lost": lost})
|
|
178
|
+
for line, (ranking, pages) in rankings.items(): # the answer pages still reachable below the cut
|
|
179
|
+
kept = {i for i, _ in select(ranking, level)}
|
|
180
|
+
alive[line] = {g for g in alive[line] if len(paths[g]) <= d or paths[g][d] in kept}
|
|
181
|
+
out_levels = cut + [_base(base, d) for d in range(depth, max(depth + 1, len(base)))]
|
|
182
|
+
report = {"fit": len(fit), "cert": len(cert), "calibration_requests": requests}
|
|
183
|
+
if cert:
|
|
184
|
+
report["cert_cutoff"] = evaluate(client, tree, cert, out_levels, depth, settings)
|
|
185
|
+
report["cert_given_levels"] = evaluate(client, tree, cert, base, depth, settings)
|
|
186
|
+
return {"levels": out_levels, "fitted": fitted, "report": report}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def evaluate(client, tree, queries, levels, depth, settings):
|
|
190
|
+
"""A search of each query with `levels`, down to the answer pages' level: the share that opens an answer page,
|
|
191
|
+
and the pages opened per query."""
|
|
192
|
+
nav = Navigator(client, tree, levels=levels, **settings)
|
|
193
|
+
hits, opened, requests = 0, [], 0
|
|
194
|
+
for q in queries:
|
|
195
|
+
trace = []
|
|
196
|
+
r = nav.search(q["query"], trace=trace, depth_limit=depth - 1)
|
|
197
|
+
requests += sum(s["requests"] for s in r["stages"])
|
|
198
|
+
hits += bool(reached(tree, trace, q["gold"]))
|
|
199
|
+
opened.append(sum(tree.nodes[i].get("kind") == "page" for t in trace for i in t["kept"]))
|
|
200
|
+
q90 = sorted(opened)[min(len(opened) - 1, math.ceil(0.9 * len(opened)) - 1)]
|
|
201
|
+
return {"coverage": round(hits / len(queries), 4), "queries": len(queries), "pages_mean": round(
|
|
202
|
+
statistics.fmean(opened), 2), "pages_p90": q90, "pages_max": max(opened), "requests": requests}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def model_entry(client):
|
|
206
|
+
"""The served model's identity (GET /v1/models): name, revision, mode and its noul temperature."""
|
|
207
|
+
try:
|
|
208
|
+
m = (client.models() or [{}])[0]
|
|
209
|
+
except Exception: # noqa: BLE001 (another server, an old one)
|
|
210
|
+
return None
|
|
211
|
+
return {"name": m.get("name"), "revision": m.get("revision"), "mode": m.get("mode"),
|
|
212
|
+
"noul_temperature": (m.get("temperature_per_prim") or {}).get("noul")}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def write_file(path, result, coverage, labels_path, tree_path, model, settings, seed, cert_share):
|
|
216
|
+
from .jsonl import write_json
|
|
217
|
+
write_json(path, {"basal_navigate_cutoff": FORMAT, "coverage": coverage, "levels": result["levels"],
|
|
218
|
+
"model": model, "tree": {"file": str(tree_path), "sha256": tree_sha(tree_path)},
|
|
219
|
+
"settings": {k: settings.get(k) for k in SETTINGS},
|
|
220
|
+
"fitted_on": {"labels": str(labels_path), "seed": seed, "cert_share": cert_share,
|
|
221
|
+
"date": datetime.date.today().isoformat(), "levels": result["fitted"]},
|
|
222
|
+
"report": result["report"]}, indent=1)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
LEVEL_KEYS = {"keep": 1, "chunk": 0, "min_p": None, "sure": None} # a level's budget: whole numbers from 1 / 0, numbers
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def check_levels(levels, where):
|
|
229
|
+
"""Levels given to --levels -> themselves, or CutoffError naming what is wrong: a list of objects whose keep and
|
|
230
|
+
chunk are whole numbers (keep at least 1) and min_p and sure numbers."""
|
|
231
|
+
if not isinstance(levels, list) or not all(isinstance(b, dict) for b in levels):
|
|
232
|
+
raise CutoffError(f'{where}: the levels must be a list of objects, one per depth ([{{"keep": 10}}, ...])')
|
|
233
|
+
for i, b in enumerate(levels):
|
|
234
|
+
for k, low in LEVEL_KEYS.items():
|
|
235
|
+
v = b.get(k)
|
|
236
|
+
if v is None:
|
|
237
|
+
continue
|
|
238
|
+
if isinstance(v, bool) or not isinstance(v, int if low is not None else (int, float)) or \
|
|
239
|
+
low is not None and v < low:
|
|
240
|
+
want = f"a whole number of at least {low}" if low is not None else "a number"
|
|
241
|
+
raise CutoffError(f"{where}: level {i + 1}: {k} must be {want}, not {json.dumps(v)}")
|
|
242
|
+
return levels
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def load_levels(spec, client=None, tree_path=None, settings=None, force=False, warn=print):
|
|
246
|
+
"""--levels: JSON, or "@file": a list of levels or a cutoff file (checked against the served model, the tree and
|
|
247
|
+
the settings: another model stops unless force; another tree or other settings warn)."""
|
|
248
|
+
if not spec.startswith("@"):
|
|
249
|
+
try:
|
|
250
|
+
return check_levels(json.loads(spec), "--levels")
|
|
251
|
+
except json.JSONDecodeError as e:
|
|
252
|
+
raise CutoffError(f"--levels: not JSON: {e}") from None
|
|
253
|
+
path = spec[1:]
|
|
254
|
+
try: # (saved on Windows too: Notepad's BOM, PowerShell 5's UTF-16)
|
|
255
|
+
with open_text(path) as f:
|
|
256
|
+
data = json.load(f)
|
|
257
|
+
except (OSError, ValueError) as e:
|
|
258
|
+
raise CutoffError(f"--levels {spec}: {e}") from None
|
|
259
|
+
if isinstance(data, list):
|
|
260
|
+
return check_levels(data, f"--levels {spec}")
|
|
261
|
+
if not isinstance(data, dict) or data.get("basal_navigate_cutoff") != FORMAT:
|
|
262
|
+
raise CutoffError(f"--levels {spec}: not a list of levels or a basal-navigate calibrate file")
|
|
263
|
+
if "levels" not in data: # (a cut-off file edited by hand)
|
|
264
|
+
raise CutoffError(f"--levels {spec}: a basal-navigate calibrate file without its \"levels\"")
|
|
265
|
+
check_levels(data["levels"], f"--levels {spec}")
|
|
266
|
+
want, have = data.get("model") or {}, model_entry(client) if client is not None else None
|
|
267
|
+
if have is not None and want and (have["name"], have["revision"]) != (want.get("name"), want.get("revision")):
|
|
268
|
+
msg = (f"--levels {spec} was fitted on {want.get('name')} (revision {want.get('revision')}), the server "
|
|
269
|
+
f"serves {have['name']} (revision {have['revision']}): its cut-offs are scores of that model")
|
|
270
|
+
if not force:
|
|
271
|
+
raise CutoffError(msg + "; refit it, or --force")
|
|
272
|
+
warn(f"warning: {msg} (--force)")
|
|
273
|
+
elif have is not None and want and (have["mode"], have["noul_temperature"]) != (want.get("mode"),
|
|
274
|
+
want.get("noul_temperature")):
|
|
275
|
+
warn(f"warning: --levels {spec}: fitted with mode {want.get('mode')} and noul temperature "
|
|
276
|
+
f"{want.get('noul_temperature')}, the server has {have['mode']} and {have['noul_temperature']}: its "
|
|
277
|
+
"scores may differ")
|
|
278
|
+
if tree_path is not None and (data.get("tree") or {}).get("sha256") not in (None, tree_sha(tree_path)):
|
|
279
|
+
warn(f"warning: --levels {spec} was fitted on another tree ({data['tree'].get('file')}); refit it for this one")
|
|
280
|
+
other = [k for k in SETTINGS if (data.get("settings") or {}).get(k) != (settings or {}).get(k)]
|
|
281
|
+
if other:
|
|
282
|
+
warn(f"warning: --levels {spec} was fitted with other settings: {', '.join(other)}")
|
|
283
|
+
return data["levels"]
|