@tuned-tensor/cli 0.13.1-beta.5 → 0.13.1-beta.7
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.
- package/README.md +24 -6
- package/dist/{chunk-AVMRHDFY.js → chunk-AKJ5WZ2S.js} +75 -52
- package/dist/chunk-AKJ5WZ2S.js.map +1 -0
- package/dist/index.js +142 -22
- package/dist/index.js.map +1 -1
- package/dist/local-runtime.js +71 -6
- package/dist/local-runtime.js.map +1 -1
- package/docs/local-runtime/architecture.md +24 -6
- package/docs/local-runtime/foundation-long-runs.md +108 -0
- package/package.json +1 -1
- package/training/foundation/src/checkpoint.py +235 -0
- package/training/foundation/src/common.py +30 -2
- package/training/foundation/src/data.py +154 -6
- package/training/foundation/src/evaluate.py +43 -9
- package/training/foundation/src/pretrain.py +439 -27
- package/training/foundation/src/rl.py +11 -3
- package/training/foundation/src/train_tokenizer.py +38 -5
- package/dist/chunk-AVMRHDFY.js.map +0 -1
|
@@ -1,23 +1,56 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from common import ensure_private_directory, load_config, make_private_file, write_json
|
|
4
|
-
from data import
|
|
4
|
+
from data import (
|
|
5
|
+
corpus_documents_hash,
|
|
6
|
+
corpus_hash,
|
|
7
|
+
corpus_manifest,
|
|
8
|
+
example_pairs,
|
|
9
|
+
instruction_corpus_documents,
|
|
10
|
+
iter_corpus_documents,
|
|
11
|
+
smoke_corpus,
|
|
12
|
+
train_tokenizer,
|
|
13
|
+
)
|
|
5
14
|
|
|
6
15
|
|
|
7
16
|
def main(argv: list[str] | None = None) -> None:
|
|
8
17
|
config = load_config(argv)
|
|
9
18
|
output_dir = ensure_private_directory(config["output_dir"])
|
|
10
19
|
examples = example_pairs(config.get("examples") or [])
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
max_chars = int(config.get("max_chars") or 20_000)
|
|
21
|
+
corpus_path = config.get("corpus_path")
|
|
22
|
+
if corpus_path:
|
|
23
|
+
manifest_before = corpus_manifest(corpus_path)
|
|
24
|
+
system_prompt = str(config.get("system_prompt") or "")
|
|
25
|
+
|
|
26
|
+
def documents():
|
|
27
|
+
return instruction_corpus_documents(
|
|
28
|
+
system_prompt,
|
|
29
|
+
iter_corpus_documents(corpus_path, max_chars),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
corpus_sha256, corpus_chars = corpus_documents_hash(documents())
|
|
33
|
+
tokenizer = train_tokenizer(
|
|
34
|
+
documents(),
|
|
35
|
+
int(config.get("vocab_size") or 256),
|
|
36
|
+
)
|
|
37
|
+
if corpus_manifest(corpus_path) != manifest_before:
|
|
38
|
+
raise RuntimeError("Foundation corpus changed while the tokenizer was being trained.")
|
|
39
|
+
else:
|
|
40
|
+
corpus = smoke_corpus(examples, max_chars, extra=str(config.get("system_prompt") or ""))
|
|
41
|
+
corpus_sha256 = corpus_hash(corpus)
|
|
42
|
+
corpus_chars = len(corpus)
|
|
43
|
+
tokenizer = train_tokenizer(corpus, int(config.get("vocab_size") or 256))
|
|
13
44
|
tokenizer_path = output_dir / "tokenizer.json"
|
|
14
45
|
tokenizer.save(str(tokenizer_path))
|
|
15
46
|
make_private_file(tokenizer_path)
|
|
16
47
|
write_json(output_dir / "metrics.json", {
|
|
17
48
|
"ok": True,
|
|
18
49
|
"vocab_size": tokenizer.get_vocab_size(),
|
|
19
|
-
"corpus_chars":
|
|
20
|
-
"corpus_sha256":
|
|
50
|
+
"corpus_chars": corpus_chars,
|
|
51
|
+
"corpus_sha256": corpus_sha256,
|
|
52
|
+
"corpus_path": str(corpus_path) if corpus_path else None,
|
|
53
|
+
"corpus_manifest": manifest_before if corpus_path else None,
|
|
21
54
|
"tokenizer_path": str(tokenizer_path),
|
|
22
55
|
})
|
|
23
56
|
|