trainproof 0.4.0__tar.gz → 0.5.0__tar.gz
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.
- {trainproof-0.4.0/src/trainproof.egg-info → trainproof-0.5.0}/PKG-INFO +31 -3
- trainproof-0.4.0/PKG-INFO → trainproof-0.5.0/README.md +230 -214
- {trainproof-0.4.0 → trainproof-0.5.0}/pyproject.toml +1 -1
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/cli.py +24 -1
- trainproof-0.5.0/src/trainproof/preflight.py +149 -0
- trainproof-0.4.0/README.md → trainproof-0.5.0/src/trainproof.egg-info/PKG-INFO +242 -202
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof.egg-info/SOURCES.txt +2 -0
- trainproof-0.5.0/tests/test_preflight.py +102 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/setup.cfg +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/__init__.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/adapters.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/compare.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/epoch.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/integrations/__init__.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/integrations/hf.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/report.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/rules.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/speech/__init__.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/speech/data.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/speech/tokenizer.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof/watch.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof.egg-info/dependency_links.txt +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof.egg-info/entry_points.txt +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof.egg-info/requires.txt +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/src/trainproof.egg-info/top_level.txt +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/tests/test_adapters.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/tests/test_compare.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/tests/test_data.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/tests/test_epoch.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/tests/test_hf_callback.py +0 -0
- {trainproof-0.4.0 → trainproof-0.5.0}/tests/test_watch.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trainproof
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: A deterministic linter for ML training runs: dataset, tokenizer, and epoch logs.
|
|
5
5
|
Author-email: "Panagiotis (Panos) Gkilis" <bedvibe@bedvibe.studio>
|
|
6
6
|
License: MIT
|
|
@@ -24,6 +24,16 @@ No ML judging ML. No invented "confidence 97%". Every rule is a deterministic
|
|
|
24
24
|
threshold in [one auditable module](src/trainproof/rules.py), and every finding
|
|
25
25
|
cites the numbers that triggered it.
|
|
26
26
|
|
|
27
|
+
**What it is:** the reliability layer between your training code and the GPU
|
|
28
|
+
bill — checks that run *before* training (is this run safe to start?), *during*
|
|
29
|
+
training (should it keep going?), and *after* (is it reproducible; did it match
|
|
30
|
+
a known-good baseline?).
|
|
31
|
+
|
|
32
|
+
**The one rule it never breaks:** trainproof does not infer causes, does not
|
|
33
|
+
invent confidence scores, and does not guess. It reports deterministic findings
|
|
34
|
+
backed by evidence, or it stays silent. Every feature earns its place by
|
|
35
|
+
answering a single question — *if it were gone, would someone lose GPU hours?*
|
|
36
|
+
|
|
27
37
|
```bash
|
|
28
38
|
pip install trainproof
|
|
29
39
|
```
|
|
@@ -122,8 +132,6 @@ TRAINPROOF VERDICT
|
|
|
122
132
|
========================================
|
|
123
133
|
```
|
|
124
134
|
|
|
125
|
-
```
|
|
126
|
-
|
|
127
135
|
Each command prints the verdict, writes a self-contained HTML report, and sets
|
|
128
136
|
the process exit code — so it works as a CI gate out of the box.
|
|
129
137
|
|
|
@@ -180,6 +188,26 @@ for you unless you ask.
|
|
|
180
188
|
The guardian applies the same deterministic rules as `trainproof epoch`, so it
|
|
181
189
|
inherits their documented single-run limitations.
|
|
182
190
|
|
|
191
|
+
## Pre-flight (v0.5): stop a run before it starts
|
|
192
|
+
|
|
193
|
+
The guardian saves most of a doomed run; preflight saves 100% because it never starts. Catch broken datasets and tokenizer misconfigurations instantly.
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
trainproof preflight data/dataset.jsonl --tokenizer mistralai/Mistral-7B-v0.1 --max-len 4096
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
========================================
|
|
201
|
+
TRAINPROOF VERDICT
|
|
202
|
+
========================================
|
|
203
|
+
[FAIL] Critical checks failed:
|
|
204
|
+
[FAIL] Empty or whitespace-only text found.
|
|
205
|
+
Evidence: 1 records (indices [1]...)
|
|
206
|
+
========================================
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
*Checks: malformed JSONL, empty text, exact duplicate text, tokenizer structural checks (EOS/PAD/BOS), and context length overflows.*
|
|
210
|
+
|
|
183
211
|
## Supported log formats
|
|
184
212
|
|
|
185
213
|
- HuggingFace Trainer (`trainer_state.json`)
|
|
@@ -1,214 +1,230 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
[
|
|
43
|
-
Evidence:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
|
65
|
-
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
zero-LR fatality rule
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
========================================
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
[FAIL] loss
|
|
119
|
-
Evidence: Run
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
##
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
1
|
+
# trainproof
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/trainproof/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**A deterministic linter for ML training runs.** Point it at your dataset, your
|
|
7
|
+
tokenizer, or your first-epoch logs — it returns a PASS / WARN / FAIL verdict
|
|
8
|
+
with named findings and cited evidence, before you burn days of GPU time on a
|
|
9
|
+
run that was doomed at step 50.
|
|
10
|
+
|
|
11
|
+
No ML judging ML. No invented "confidence 97%". Every rule is a deterministic
|
|
12
|
+
threshold in [one auditable module](src/trainproof/rules.py), and every finding
|
|
13
|
+
cites the numbers that triggered it.
|
|
14
|
+
|
|
15
|
+
**What it is:** the reliability layer between your training code and the GPU
|
|
16
|
+
bill — checks that run *before* training (is this run safe to start?), *during*
|
|
17
|
+
training (should it keep going?), and *after* (is it reproducible; did it match
|
|
18
|
+
a known-good baseline?).
|
|
19
|
+
|
|
20
|
+
**The one rule it never breaks:** trainproof does not infer causes, does not
|
|
21
|
+
invent confidence scores, and does not guess. It reports deterministic findings
|
|
22
|
+
backed by evidence, or it stays silent. Every feature earns its place by
|
|
23
|
+
answering a single question — *if it were gone, would someone lose GPU hours?*
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install trainproof
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## See a verdict in 60 seconds
|
|
30
|
+
|
|
31
|
+
This repo ships the real logs of five QLoRA fine-tuning runs (Qwen2.5-3B,
|
|
32
|
+
RTX 5080 — see the gallery below). Judge one right now:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
trainproof epoch examples/gallery/lr_hot/trainer_state.json --format hf
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
[FAIL] Critical checks failed:
|
|
40
|
+
[FAIL] Loss curve is diverging.
|
|
41
|
+
Evidence: End loss 7.492 vs Min loss 1.398
|
|
42
|
+
[WARN] Gradient norm spikes detected.
|
|
43
|
+
Evidence: Max gn 2649.75 > 10.0x median (0.55)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Why this exists
|
|
47
|
+
|
|
48
|
+
The author lost a real 11-hour fine-tune to a failure nothing warned about.
|
|
49
|
+
Pointed retroactively at that run's 1MB Coqui Trainer log (2,501 logged steps),
|
|
50
|
+
trainproof's verdict: **FAIL — diverging**. The loss reached its minimum at 82%
|
|
51
|
+
of the run and ended 1.9x above it. Translation: the final two hours of GPU
|
|
52
|
+
time made the model measurably worse, and the checkpoint worth keeping had
|
|
53
|
+
already existed for hours. No tool in the stack said a word.
|
|
54
|
+
|
|
55
|
+
## The fault-injection gallery
|
|
56
|
+
|
|
57
|
+
To validate the rules, the same QLoRA fine-tune (Qwen2.5-3B-Instruct, 4-bit,
|
|
58
|
+
LoRA r=16, 300 steps on Alpaca-cleaned) was run five times — once healthy, four
|
|
59
|
+
times with exactly one knob deliberately broken. Real runs, real logs, all
|
|
60
|
+
shipped in [`examples/gallery/`](examples/gallery/):
|
|
61
|
+
|
|
62
|
+
| Run | Sabotage | Verdict | Key evidence |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `healthy` | none | **PASS** | loss 1.52 → 0.94, stable gradients |
|
|
65
|
+
| `lr_hot` | LR x100 (2e-2) | **FAIL** | diverging: end 7.49 vs min 1.40; grad spike 2650 vs median 0.55 |
|
|
66
|
+
| `lr_zero` | LR = 0 | **FAIL** | dead run: first-5 median 1.52 vs last-5 1.49 (<5% improvement); lr=0 on 100% of steps |
|
|
67
|
+
| `fp16_nan` | fp16 + hot LR, no clipping | **FAIL** | diverging: end 7.21 vs min 1.09 (grad scaling absorbed the intended NaN — the run diverged instead; reported as observed) |
|
|
68
|
+
| `bad_labels` | labels shuffled per-sequence | **WARN only** (single-run) — caught by `trainproof compare` (v0.3) | grad spike 23.3 vs median 1.09 |
|
|
69
|
+
|
|
70
|
+
### The honest finding: loss curves cannot see corrupted data
|
|
71
|
+
|
|
72
|
+
The `bad_labels` run — whose shuffled labels make real learning impossible —
|
|
73
|
+
*reduced its loss by 62%* (18.9 → 5.75). The model was genuinely learning: not
|
|
74
|
+
the task, but the marginal token statistics of the garbage. From its own loss
|
|
75
|
+
curve, that is indistinguishable from healthy training (neural networks
|
|
76
|
+
famously fit random labels). **No single-run, loss-only rule can catch this
|
|
77
|
+
class of failure** — its real signature is *relative*: a loss floor ~6x higher
|
|
78
|
+
than a known-good run of the same task (5.59 vs 0.94).
|
|
79
|
+
|
|
80
|
+
That finding produced v0.3: `trainproof compare <run> <baseline>` —
|
|
81
|
+
deterministic ratio rules against the healthy baseline you already have —
|
|
82
|
+
which catches `bad_labels` at a 6x loss-floor ratio, in 3 seeds out of 3.
|
|
83
|
+
The full study was repeated with three random seeds (15 runs):
|
|
84
|
+
see [EVIDENCE_MATRIX.md](EVIDENCE_MATRIX.md) for every verdict, including the
|
|
85
|
+
honest miss (compare alone overlooks one lr_zero seed — the single-run
|
|
86
|
+
zero-LR fatality rule owns that case; the two commands cover each other's
|
|
87
|
+
blind spots). The gallery also improved the tool itself twice: the dead-run
|
|
88
|
+
rule and the total-zero-LR fatality rule both exist because runs escaped
|
|
89
|
+
earlier rule versions. See [ROADMAP.md](ROADMAP.md).
|
|
90
|
+
|
|
91
|
+
## The commands
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 1. Dataset preflight (speech/TTS pack): audio integrity, transcript quality,
|
|
95
|
+
# duplicates, text-vs-audio duration mismatches
|
|
96
|
+
trainproof data /path/to/dataset_or_manifest.jsonl
|
|
97
|
+
|
|
98
|
+
# 2. Tokenizer preflight: vocabulary coverage, OOV rate, sequence blowouts,
|
|
99
|
+
# suspicious splits on numbers/dates
|
|
100
|
+
trainproof tokenizer my_tokenizer.model transcripts.txt
|
|
101
|
+
|
|
102
|
+
# 3. Training-run verdict: NaN/divergence/dead-run detection, gradient spikes,
|
|
103
|
+
# LR sanity, throughput — from log files, any framework
|
|
104
|
+
trainproof epoch logs/run.jsonl # exit code 1 on FAIL: CI-ready
|
|
105
|
+
|
|
106
|
+
# 4. Compare against a baseline
|
|
107
|
+
# Catch relative pathologies like the `bad_labels` run that evade single-run rules.
|
|
108
|
+
trainproof compare examples/gallery/bad_labels/trainer_state.json examples/gallery/healthy/trainer_state.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
========================================
|
|
113
|
+
TRAINPROOF VERDICT
|
|
114
|
+
========================================
|
|
115
|
+
[FAIL] Critical checks failed:
|
|
116
|
+
[FAIL] loss floor ratio exceeded limit
|
|
117
|
+
Evidence: Run floor 5.592 vs Baseline floor 0.937 (ratio 6.0x > 2.0)
|
|
118
|
+
[FAIL] end loss ratio exceeded limit
|
|
119
|
+
Evidence: Run end 5.750 vs Baseline end 1.082 (ratio 5.3x > 2.0)
|
|
120
|
+
========================================
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Each command prints the verdict, writes a self-contained HTML report, and sets
|
|
124
|
+
the process exit code — so it works as a CI gate out of the box.
|
|
125
|
+
|
|
126
|
+
## Live guardian (v0.4)
|
|
127
|
+
|
|
128
|
+
Don't wait for the post-mortem — catch a doomed run *while it is still burning
|
|
129
|
+
GPU*. Add one line to a HuggingFace `Trainer`:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from transformers import Trainer
|
|
133
|
+
from trainproof.integrations.hf import TrainproofCallback
|
|
134
|
+
|
|
135
|
+
trainer = Trainer(
|
|
136
|
+
...,
|
|
137
|
+
callbacks=[TrainproofCallback(policy="stop_on_fail")], # or policy="warn"
|
|
138
|
+
)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Run against a real diverging QLoRA fine-tune (learning rate 100x too high), the
|
|
142
|
+
guardian aborts it 20 steps into a 300-step schedule — on its own:
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
{'loss': '1.784', 'grad_norm': '9.634', 'learning_rate': '0.007'}
|
|
146
|
+
{'loss': '4.282', 'grad_norm': '53.76', 'learning_rate': '0.009'}
|
|
147
|
+
{'loss': '10.6', 'grad_norm': '13.34', 'learning_rate': '0.011'}
|
|
148
|
+
{'loss': '31.67', 'grad_norm': '76.67', 'learning_rate': '0.013'}
|
|
149
|
+
...
|
|
150
|
+
TRAINPROOF ABORT - stopping training at step 20. Findings:
|
|
151
|
+
[FAIL] Loss curve is diverging.
|
|
152
|
+
Evidence: End loss 22.952 vs Min loss 1.358
|
|
153
|
+
[FAIL] Loss never improved over the run (dead run).
|
|
154
|
+
Evidence: median of first 5 losses 1.502 vs last 5 22.952
|
|
155
|
+
|
|
156
|
+
scheduled steps : 300
|
|
157
|
+
stopped at step : 20
|
|
158
|
+
run saved : 93% of the scheduled steps never ran
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
On a two-day pre-training run, that fraction is days of GPU time. Or watch a
|
|
162
|
+
growing log file from outside the process (CI-friendly, exits non-zero on FAIL):
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
trainproof watch logs/run.jsonl --interval 10 --until-fail
|
|
166
|
+
# [21:37:44] warming up (5 records)
|
|
167
|
+
# [21:37:44] n_records=15 verdict=PASS findings=1
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**The default is safe.** `policy="warn"` (the default) only observes and reports
|
|
171
|
+
— it never interrupts your run, so you can leave it on even for experiments you
|
|
172
|
+
expect to fail. Aborting is strictly opt-in via `policy="stop_on_fail"`, the one
|
|
173
|
+
mode that takes an irreversible action. trainproof does not make that decision
|
|
174
|
+
for you unless you ask.
|
|
175
|
+
|
|
176
|
+
The guardian applies the same deterministic rules as `trainproof epoch`, so it
|
|
177
|
+
inherits their documented single-run limitations.
|
|
178
|
+
|
|
179
|
+
## Pre-flight (v0.5): stop a run before it starts
|
|
180
|
+
|
|
181
|
+
The guardian saves most of a doomed run; preflight saves 100% because it never starts. Catch broken datasets and tokenizer misconfigurations instantly.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
trainproof preflight data/dataset.jsonl --tokenizer mistralai/Mistral-7B-v0.1 --max-len 4096
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
========================================
|
|
189
|
+
TRAINPROOF VERDICT
|
|
190
|
+
========================================
|
|
191
|
+
[FAIL] Critical checks failed:
|
|
192
|
+
[FAIL] Empty or whitespace-only text found.
|
|
193
|
+
Evidence: 1 records (indices [1]...)
|
|
194
|
+
========================================
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
*Checks: malformed JSONL, empty text, exact duplicate text, tokenizer structural checks (EOS/PAD/BOS), and context length overflows.*
|
|
198
|
+
|
|
199
|
+
## Supported log formats
|
|
200
|
+
|
|
201
|
+
- HuggingFace Trainer (`trainer_state.json`)
|
|
202
|
+
- Coqui Trainer text logs (ANSI-colored `trainer_0_log.txt`)
|
|
203
|
+
- Generic JSONL / CSV (columns: step, loss, lr, grad_norm, time — all optional)
|
|
204
|
+
|
|
205
|
+
Auto-detected; override with `--format hf|coqui|jsonl|csv`. TensorBoard event
|
|
206
|
+
files are planned (Lightning console captures are TTY dumps, not logs, and
|
|
207
|
+
will not be supported).
|
|
208
|
+
|
|
209
|
+
## Philosophy
|
|
210
|
+
|
|
211
|
+
1. **Deterministic.** A rule fires or it doesn't. Thresholds live in one
|
|
212
|
+
module, commented, tunable.
|
|
213
|
+
2. **Evidence-cited.** Every finding names the steps and values that triggered
|
|
214
|
+
it.
|
|
215
|
+
3. **Honest about limits.** What the tool cannot detect is documented in the
|
|
216
|
+
README, not discovered by the user in production.
|
|
217
|
+
|
|
218
|
+
## Family
|
|
219
|
+
|
|
220
|
+
trainproof judges training runs. Its sibling [ttsproof](https://github.com/Mormolykos/ttsproof)
|
|
221
|
+
judges TTS model *outputs* (structural audio checks, equivalence-aware WER/CER,
|
|
222
|
+
published method with DOI) — and trainproof builds on it for the speech
|
|
223
|
+
dataset checks.
|
|
224
|
+
|
|
225
|
+
## Author
|
|
226
|
+
|
|
227
|
+
Panagiotis (Panos) Gkilis — [portfolio](https://tts.bedvibe.studio/portfolio/) ·
|
|
228
|
+
[bedvibe.studio](https://bedvibe.studio/)
|
|
229
|
+
|
|
230
|
+
MIT license.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "trainproof"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
description = "A deterministic linter for ML training runs: dataset, tokenizer, and epoch logs."
|
|
5
5
|
authors = [{name = "Panagiotis (Panos) Gkilis", email = "bedvibe@bedvibe.studio"}]
|
|
6
6
|
readme = "README.md"
|
|
@@ -4,7 +4,6 @@ from pathlib import Path
|
|
|
4
4
|
from .speech.data import check_data
|
|
5
5
|
from .speech.tokenizer import check_tokenizer
|
|
6
6
|
from .epoch import check_epoch
|
|
7
|
-
from .epoch import check_epoch
|
|
8
7
|
from .compare import check_compare
|
|
9
8
|
from .watch import watch_loop
|
|
10
9
|
from .report import print_verdict_console, write_html_report
|
|
@@ -40,6 +39,13 @@ def main():
|
|
|
40
39
|
watch_parser.add_argument("--format", choices=["auto", "hf", "coqui", "jsonl", "csv"], default="auto", help="Log format override")
|
|
41
40
|
watch_parser.add_argument("--until-fail", action="store_true", help="Exit with code 1 as soon as verdict becomes FAIL")
|
|
42
41
|
|
|
42
|
+
# Preflight Command
|
|
43
|
+
preflight_parser = subparsers.add_parser("preflight", help="Pre-flight linter for LLM fine-tuning datasets.")
|
|
44
|
+
preflight_parser.add_argument("dataset", type=str, help="Path to JSONL dataset")
|
|
45
|
+
preflight_parser.add_argument("--tokenizer", type=str, help="Tokenizer name or path")
|
|
46
|
+
preflight_parser.add_argument("--max-len", type=int, help="Max context length")
|
|
47
|
+
preflight_parser.add_argument("--text-field", type=str, help="Text field to extract")
|
|
48
|
+
|
|
43
49
|
args = parser.parse_args()
|
|
44
50
|
|
|
45
51
|
report_dict = {}
|
|
@@ -63,6 +69,23 @@ def main():
|
|
|
63
69
|
elif args.command == "watch":
|
|
64
70
|
watch_loop(args.logfile, interval=args.interval, fmt=args.format, until_fail=args.until_fail)
|
|
65
71
|
sys.exit(0)
|
|
72
|
+
elif args.command == "preflight":
|
|
73
|
+
from .preflight import preflight
|
|
74
|
+
tokenizer = None
|
|
75
|
+
if args.tokenizer:
|
|
76
|
+
try:
|
|
77
|
+
from transformers import AutoTokenizer
|
|
78
|
+
tokenizer = AutoTokenizer.from_pretrained(args.tokenizer)
|
|
79
|
+
except ImportError:
|
|
80
|
+
report_dict = {
|
|
81
|
+
"verdict": "FAIL",
|
|
82
|
+
"findings": [{"id": "transformers_missing", "level": "FAIL", "message": "pip install transformers is required to load tokenizer", "evidence": ""}]
|
|
83
|
+
}
|
|
84
|
+
print_verdict_console(report_dict["verdict"], report_dict["findings"])
|
|
85
|
+
sys.exit(1)
|
|
86
|
+
|
|
87
|
+
result = preflight(args.dataset, tokenizer=tokenizer, max_len=args.max_len, text_field=args.text_field)
|
|
88
|
+
report_dict = {"verdict": result.verdict, "findings": result.findings}
|
|
66
89
|
|
|
67
90
|
print_verdict_console(report_dict.get("verdict", "FAIL"), report_dict.get("findings", []))
|
|
68
91
|
|