|
Download README.md from Grizzlykw/ternlight-multilingual-e5: direct link, hf CLI and curl.
- Browser
- Download file 3.39 kB
-
https://huggingface.co/Grizzlykw/ternlight-multilingual-e5/resolve/main/README.md
- Command line
-
hf download hf://Grizzlykw/ternlight-multilingual-e5/README.md
-
curl -L -o README.md https://huggingface.co/Grizzlykw/ternlight-multilingual-e5/resolve/main/README.md
3.39 kB
| # training | |
| > For contributors retraining or modifying the distillation pipeline. If you're *using* ternlight in an app, see [`packages/ternlight/`](../packages/ternlight). For shipped model artifacts, see [`models/`](../models). | |
| Python pipeline that produces the `.bin` model file consumed by the Wasm engine. Two stages: | |
| ``` | |
| training/ | |
| βββ distill/ Stage 1 β distillation training (Python, GPU) | |
| β βββ prep/ Phase 1 β data preparation (one-time setup) | |
| β β βββ prepare.py entry point: read config, build cache | |
| β β βββ ingest.py helpers: loaders, dedup, tokenize, encode, split, manifest, stats | |
| β βββ train.py Phase 2/3 entry point | |
| β βββ trainer.py the training loop | |
| β βββ model.py StudentEncoder + attention + FFN + transformer block | |
| β βββ quantization.py BitLinear swap, embedding ternarization, zero-frac monitor | |
| β βββ loss.py distillation + contrastive | |
| β βββ evaluate.py Phase 4 entry point: go/no-go scorecard (Task 1, 2, 3) | |
| β βββ data.py cross-phase: TernDataset, collate_fn, save_cache, load_cache | |
| β βββ config.py cross-phase: pydantic schemas + YAML loader | |
| β βββ configs/ per-tier configs (micro.yaml, micro-fp32.yaml, small.yaml, smoke.yaml) | |
| β βββ corpora/ local eval data (general.jsonl, tech.jsonl) | |
| βββ pack/ Stage 2 β bit-pack .pt β .bin (Python, CPU) | |
| βββ pack.py read .pt, ternarize embedding, pack 2 bits/weight, write .bin | |
| βββ verify.py round-trip a packed .bin and compare against the .pt | |
| ``` | |
| ## When to touch what | |
| - **New training run** β edit `distill/configs/*.yaml`, run `distill/train.py` | |
| - **New data source / dedup / sampling logic** β `distill/prep/ingest.py` | |
| - **New loss function** β `distill/loss.py` | |
| - **Architecture change** β `distill/model.py`, then update `distill/configs/*.yaml` | |
| - **Quantization change (training-time or post-train)** β `distill/quantization.py` (must stay in sync with `pack/pack.py` β they apply the same math at different stages) | |
| - **Bit-packing / .bin format change** β `pack/pack.py` | |
| - **Eval methodology change** β `distill/evaluate.py` for go/no-go; `eval/regression/` (at repo root) for ongoing quality regression | |
| ## Outputs | |
| ``` | |
| distill/runs/<run-name>/ | |
| βββ checkpoint_ep<N>.pt float32 shadow weights + config + optimizer state | |
| (NOT committed β see .gitignore) | |
| β pack.py | |
| pack/out/model.bin packed ternary + projection (the shipped artifact) | |
| (also NOT committed β attached to GitHub Release) | |
| β scripts/release-model.sh | |
| github.com/.../releases/v0.1.0 per-version model binary download | |
| β at npm publish time | |
| packages/semantic/model.bin bundled into the published package | |
| ``` | |
| ## Math reference | |
| What the model actually computes β forward pass, backprop, distillation dynamics β is documented in [../docs/model-internals.md](../docs/model-internals.md). Read that before changing the training code. | |
| ## Status | |
| Pre-alpha. Source code migration from `tern-distill-prototype/poc/` (β `distill/`) and `tern-distill-prototype/export/` (β `pack/`) pending. | |