si-lineage-tracker 0.1.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.
- si_lineage_tracker-0.1.0/LICENSE +21 -0
- si_lineage_tracker-0.1.0/PKG-INFO +344 -0
- si_lineage_tracker-0.1.0/README.md +319 -0
- si_lineage_tracker-0.1.0/pyproject.toml +36 -0
- si_lineage_tracker-0.1.0/setup.cfg +4 -0
- si_lineage_tracker-0.1.0/src/lineage_tracker/__init__.py +263 -0
- si_lineage_tracker-0.1.0/src/lineage_tracker/model.py +41 -0
- si_lineage_tracker-0.1.0/src/lineage_tracker/store.py +103 -0
- si_lineage_tracker-0.1.0/src/si_lineage_tracker.egg-info/PKG-INFO +344 -0
- si_lineage_tracker-0.1.0/src/si_lineage_tracker.egg-info/SOURCES.txt +12 -0
- si_lineage_tracker-0.1.0/src/si_lineage_tracker.egg-info/dependency_links.txt +1 -0
- si_lineage_tracker-0.1.0/src/si_lineage_tracker.egg-info/requires.txt +4 -0
- si_lineage_tracker-0.1.0/src/si_lineage_tracker.egg-info/top_level.txt +1 -0
- si_lineage_tracker-0.1.0/tests/test_lineage.py +231 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SuperInstance
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: si-lineage-tracker
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fine-tune provenance as bloodline records
|
|
5
|
+
Author: SuperInstance
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/SuperInstance/lineage-tracker
|
|
8
|
+
Project-URL: Repository, https://github.com/SuperInstance/lineage-tracker
|
|
9
|
+
Keywords: llm,fine-tuning,provenance,lineage,ml-ops
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# The Lineage Tracker
|
|
27
|
+
|
|
28
|
+
> Fine-tune provenance as bloodline records. Every checkpoint, every merge, every fine-tune — traceable like a breeder's studbook.
|
|
29
|
+
|
|
30
|
+
[](https://python.org)
|
|
31
|
+
[](LICENSE)
|
|
32
|
+
[](tests/)
|
|
33
|
+
|
|
34
|
+
Every model has a family tree. Base models beget fine-tunes. Fine-tunes beget merges. Merges beget quantizations. After three layers of adaptation, nobody remembers who descended from whom — or whether that merge you're about to deploy has a known-broken checkpoint in its ancestry. Lineage Tracker treats this seriously, recording every fine-tune event as a structured breeding record with full provenance, checksums, and trait tracking.
|
|
35
|
+
|
|
36
|
+
## What It Does
|
|
37
|
+
|
|
38
|
+
Lineage Tracker maintains a JSON-backed registry of models and their breeding history. Every fine-tune, merge, distillation, or continued pre-training is recorded as a `BreedingRecord` that links parents to children with method metadata (LoRA rank, dataset, epochs, merge strategy). Models carry traits (benchmark scores, capabilities, known limitations) and checksums for identity verification.
|
|
39
|
+
|
|
40
|
+
The tracker supports lineage queries — walk any model's ancestry back through generations, compare capabilities across sibling checkpoints, and get breeding recommendations for diversity. This matters because blind fine-tuning is how capability regressions sneak into production. If your customer-facing model suddenly can't do math, you need to know: was it the merge? The adapter? The base model upgrade? Lineage tracking turns that detective work into a single query.
|
|
41
|
+
|
|
42
|
+
The core equation from Working Animal Architecture is **γ + η = C** (genome + nurture = capability). Lineage tracking is the **γ** — the genome, the bloodline record that makes selective breeding possible. Without it, you're doing random mutations and hoping for the best.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install lineage-tracker
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For development:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/SuperInstance/lineage-tracker.git
|
|
54
|
+
cd lineage-tracker
|
|
55
|
+
pip install -e ".[dev]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from lineage_tracker import LineageTracker
|
|
62
|
+
|
|
63
|
+
tracker = LineageTracker("lineage.json")
|
|
64
|
+
|
|
65
|
+
# Record a breeding (fine-tune) event
|
|
66
|
+
child = tracker.record_breeding(
|
|
67
|
+
parents=["base-llama-3-70b"],
|
|
68
|
+
child_name="my-ft-v1",
|
|
69
|
+
method="lora",
|
|
70
|
+
metadata={
|
|
71
|
+
"rank": 64,
|
|
72
|
+
"dataset": "instruct-v2",
|
|
73
|
+
"epochs": 3,
|
|
74
|
+
"learning_rate": 2e-4,
|
|
75
|
+
},
|
|
76
|
+
child_traits={
|
|
77
|
+
"mmlu": 82.3,
|
|
78
|
+
"human_eval": 71.5,
|
|
79
|
+
"gsm8k": 78.1,
|
|
80
|
+
},
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Query lineage — walk ancestry back through generations
|
|
84
|
+
lineage = tracker.get_lineage("my-ft-v1")
|
|
85
|
+
for gen in lineage:
|
|
86
|
+
print(f"Generation {gen.generation}: {gen.model.name} (v{gen.model.version})")
|
|
87
|
+
if gen.model.traits:
|
|
88
|
+
print(f" Traits: {gen.model.traits}")
|
|
89
|
+
|
|
90
|
+
# Compare two siblings
|
|
91
|
+
diff = tracker.compare_generations("my-ft-v1", "my-ft-v2")
|
|
92
|
+
print(diff.summary)
|
|
93
|
+
|
|
94
|
+
# Get breeding recommendations based on trait diversity
|
|
95
|
+
recs = tracker.recommend_breeding("my-ft-v1", criteria="diversity")
|
|
96
|
+
for rec in recs[:3]:
|
|
97
|
+
print(f" Pair with: {rec.model_name} (diversity: {rec.score:.2f})")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Data Model
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Model BreedingRecord
|
|
104
|
+
├── name ├── parents: list[str]
|
|
105
|
+
├── version ├── child: str
|
|
106
|
+
├── traits: dict ├── method: str (lora|full|merge|distill|...)
|
|
107
|
+
├── checksum: str ├── timestamp: str
|
|
108
|
+
├── metadata: dict
|
|
109
|
+
Generation └── generation: int
|
|
110
|
+
├── model: Model
|
|
111
|
+
└── generation: int
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### JSON Store Structure
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"models": {
|
|
119
|
+
"my-ft-v1@1.0": {
|
|
120
|
+
"name": "my-ft-v1",
|
|
121
|
+
"version": "1.0",
|
|
122
|
+
"traits": {"mmlu": 82.3, "human_eval": 71.5},
|
|
123
|
+
"checksum": "a1b2c3d4e5f6g7h8"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"breeding_records": [
|
|
127
|
+
{
|
|
128
|
+
"parents": ["base-llama-3-70b"],
|
|
129
|
+
"child": "my-ft-v1",
|
|
130
|
+
"method": "lora",
|
|
131
|
+
"timestamp": "2026-07-12T14:30:00Z",
|
|
132
|
+
"metadata": {"rank": 64, "dataset": "instruct-v2"},
|
|
133
|
+
"generation": 1
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"generations": {
|
|
137
|
+
"my-ft-v1@1.0": 1
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## API Reference
|
|
143
|
+
|
|
144
|
+
### `LineageTracker`
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
class LineageTracker:
|
|
148
|
+
def __init__(self, path: str = "lineage.json")
|
|
149
|
+
|
|
150
|
+
# Recording
|
|
151
|
+
def record_breeding(
|
|
152
|
+
self,
|
|
153
|
+
parents: list[str],
|
|
154
|
+
child_name: str,
|
|
155
|
+
method: str = "full",
|
|
156
|
+
metadata: dict | None = None,
|
|
157
|
+
child_version: str = "1.0",
|
|
158
|
+
child_traits: dict | None = None,
|
|
159
|
+
) -> Model
|
|
160
|
+
|
|
161
|
+
# Querying
|
|
162
|
+
def get_lineage(self, name: str) -> list[Generation]
|
|
163
|
+
def get_model(self, name: str) -> Model | None
|
|
164
|
+
def get_all_models(self) -> list[Model]
|
|
165
|
+
def compare_generations(self, a: str, b: str) -> GenerationDiff
|
|
166
|
+
def recommend_breeding(self, name: str, criteria: str = "diversity") -> list[Recommendation]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Breeding Methods
|
|
170
|
+
|
|
171
|
+
| Method | Description |
|
|
172
|
+
|--------|-------------|
|
|
173
|
+
| `full` | Full-parameter fine-tuning |
|
|
174
|
+
| `lora` | LoRA / QLoRA adapter training |
|
|
175
|
+
| `merge` | Model merging (SLERP, DARE, TIES, linear) |
|
|
176
|
+
| `distill` | Knowledge distillation from teacher to student |
|
|
177
|
+
| `continue_pretrain` | Continued pre-training on new domain data |
|
|
178
|
+
| `rlhf` | Reinforcement learning from human feedback |
|
|
179
|
+
| `sft` | Supervised fine-tuning |
|
|
180
|
+
|
|
181
|
+
## Testing
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
pip install -e ".[dev]"
|
|
185
|
+
pytest tests/ -v
|
|
186
|
+
|
|
187
|
+
# Run specific test modules
|
|
188
|
+
pytest tests/test_tracker.py -v
|
|
189
|
+
pytest tests/test_store.py -v
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Philosophy
|
|
193
|
+
|
|
194
|
+
Selective breeding changed civilization. The ability to record lineage, track traits across generations, and make informed pairing decisions is what separated agriculture from hunting-gathering. Lineage Tracker brings that same leap to AI — transforming model development from ad-hoc experimentation into a disciplined breeding program.
|
|
195
|
+
|
|
196
|
+
This is the γ (genome) half of γ + η = C. Without lineage records, you can't do selective breeding — you're just hoping each fine-tune is better than the last. With lineage records, you can identify which breeding strategies produce the best offspring, avoid reinforcing known weaknesses, and build a structured improvement program.
|
|
197
|
+
|
|
198
|
+
For more on the breeding paradigm in AI, see [AI-Writings](https://github.com/SuperInstance/AI-Writings).
|
|
199
|
+
|
|
200
|
+
## Ecosystem
|
|
201
|
+
|
|
202
|
+
| Repo | Role |
|
|
203
|
+
|------|------|
|
|
204
|
+
| **[lineage-tracker](https://github.com/SuperInstance/lineage-tracker)** | **This repo** — provenance tracking |
|
|
205
|
+
| [pedigree](https://github.com/SuperInstance/pedigree) | Bloodline tracking with inbreeding coefficients and visualization |
|
|
206
|
+
| [breed-registry](https://github.com/SuperInstance/breed-registry) | Breed assessment and task matching |
|
|
207
|
+
| [baton](https://github.com/SuperInstance/baton) | Generational handoff (carries lessons between lineage generations) |
|
|
208
|
+
| [vetcheck](https://github.com/SuperInstance/vetcheck) | Health monitoring for registered models |
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
## Lineage Tracker vs Pedigree: When to Use Which
|
|
213
|
+
|
|
214
|
+
Both [Lineage Tracker](https://github.com/SuperInstance/lineage-tracker) and [Pedigree](https://github.com/SuperInstance/pedigree) track model ancestry. They overlap but serve different primary use cases:
|
|
215
|
+
|
|
216
|
+
| Concern | Lineage Tracker | Pedigree |
|
|
217
|
+
|---------|----------------|----------|
|
|
218
|
+
| **Primary focus** | Provenance records | Bloodline analysis |
|
|
219
|
+
| **Data model** | Flat breeding records with metadata | Genealogical tree with sire/dam |
|
|
220
|
+
| **Inbreeding detection** | No (recommendations based on trait diversity) | Yes (Wright's coefficient of relationship) |
|
|
221
|
+
| **Visualization** | Programmatic queries | ASCII trees + GraphViz DOT export |
|
|
222
|
+
| **Trait comparison** | Yes (compare generations side-by-side) | Limited |
|
|
223
|
+
| **Breeding method tracking** | Rich metadata (LoRA rank, LR, epochs, merge strategy) | Basic method tags |
|
|
224
|
+
| **Best for** | MLOps: "what happened in this fine-tune chain?" | Research: "is this merge genetically safe?" |
|
|
225
|
+
|
|
226
|
+
**Use Lineage Tracker when** you need audit trails for production models — what was trained on what, with what hyperparameters, and what the benchmark impact was. The metadata-rich records are designed for compliance and debugging.
|
|
227
|
+
|
|
228
|
+
**Use Pedigree when** you need genetic analysis — inbreeding coefficients before merging, diversity scoring for outcross recommendations, and publication-quality lineage trees. The sire/dam model maps cleanly to how animal breeders think about bloodlines.
|
|
229
|
+
|
|
230
|
+
**Use both when** you're running a serious breeding program. Lineage Tracker records the events; Pedigree analyzes the bloodline. Export from one, import to the other.
|
|
231
|
+
|
|
232
|
+
## Advanced Scenario: Debugging a Capability Regression
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
from lineage_tracker import LineageTracker
|
|
236
|
+
|
|
237
|
+
tracker = LineageTracker("lineage.json")
|
|
238
|
+
|
|
239
|
+
# Your production model suddenly can't do math
|
|
240
|
+
# Trace its ancestry to find the culprit
|
|
241
|
+
lineage = tracker.get_lineage("prod-model-v7")
|
|
242
|
+
|
|
243
|
+
print("Ancestry chain:")
|
|
244
|
+
for gen in lineage:
|
|
245
|
+
model = gen.model
|
|
246
|
+
gsm8k = model.traits.get("gsm8k", "N/A")
|
|
247
|
+
print(f" Gen {gen.generation}: {model.name}@{model.version}")
|
|
248
|
+
print(f" gsm8k: {gsm8k}")
|
|
249
|
+
print(f" method: {gen.breeding_method if hasattr(gen, 'breeding_method') else 'unknown'}")
|
|
250
|
+
|
|
251
|
+
# Output reveals:
|
|
252
|
+
# Gen 0: base-llama-3-70b gsm8k: 82.1 (baseline)
|
|
253
|
+
# Gen 1: instruct-sft-v3 gsm8k: 79.4 (-2.7 after SFT)
|
|
254
|
+
# Gen 2: creative-merge-v1 gsm8k: 71.2 (-8.2 after merge!) ← CULPRIT
|
|
255
|
+
# Gen 3: prod-model-v7 gsm8k: 68.9 (-2.3 after continued training)
|
|
256
|
+
|
|
257
|
+
# The merge at Gen 2 caused the regression
|
|
258
|
+
# Now check what was merged:
|
|
259
|
+
records = [r for r in tracker.get_all_models() if "creative-merge" in r.name]
|
|
260
|
+
for r in records:
|
|
261
|
+
print(f" {r.name}: parents={r.parent_ids}, traits={r.traits}")
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Multi-Generation Breeding Program
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
from lineage_tracker import LineageTracker
|
|
268
|
+
|
|
269
|
+
tracker = LineageTracker("breeding-program.json")
|
|
270
|
+
|
|
271
|
+
# Generation 0: Foundation
|
|
272
|
+
tracker.record_breeding(
|
|
273
|
+
parents=["llama-3-70b"],
|
|
274
|
+
child_name="domain-base-v1",
|
|
275
|
+
method="continue_pretrain",
|
|
276
|
+
metadata={"dataset": "domain_corpus_v1", "tokens": "5B"},
|
|
277
|
+
child_traits={"mmlu": 80.1, "domain_eval": 72.0},
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
# Generation 1: Specialization
|
|
281
|
+
tracker.record_breeding(
|
|
282
|
+
parents=["domain-base-v1"],
|
|
283
|
+
child_name="domain-instruct-v1",
|
|
284
|
+
method="sft",
|
|
285
|
+
metadata={"dataset": "instruct_v2", "epochs": 3, "lr": 2e-5},
|
|
286
|
+
child_traits={"mmlu": 81.2, "domain_eval": 78.5, "if_eval": 84.0},
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
# Generation 1: Alternative specialization (different focus)
|
|
290
|
+
tracker.record_breeding(
|
|
291
|
+
parents=["domain-base-v1"],
|
|
292
|
+
child_name="domain-reasoning-v1",
|
|
293
|
+
method="rlhf",
|
|
294
|
+
metadata={"reward_model": "rm-v2", "kl_coef": 0.1},
|
|
295
|
+
child_traits={"mmlu": 82.0, "domain_eval": 75.0, "gsm8k": 85.1},
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# Generation 2: Merge the best of both specializations
|
|
299
|
+
tracker.record_breeding(
|
|
300
|
+
parents=["domain-instruct-v1", "domain-reasoning-v1"],
|
|
301
|
+
child_name="domain-merged-v2",
|
|
302
|
+
method="merge",
|
|
303
|
+
metadata={"strategy": "SLERP", "ratio": "0.5"},
|
|
304
|
+
child_traits={"mmlu": 83.1, "domain_eval": 79.0, "gsm8k": 84.2, "if_eval": 83.5},
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# Query the full program
|
|
308
|
+
print(f"Total models tracked: {len(tracker.get_all_models())}")
|
|
309
|
+
for model in tracker.get_all_models():
|
|
310
|
+
print(f" {model.name}@{model.version}: {model.traits}")
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Export for Pedigree Analysis
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
from lineage_tracker import LineageTracker
|
|
317
|
+
|
|
318
|
+
tracker = LineageTracker("lineage.json")
|
|
319
|
+
|
|
320
|
+
# Export to a format Pedigree can consume
|
|
321
|
+
import json
|
|
322
|
+
|
|
323
|
+
models = tracker.get_all_models()
|
|
324
|
+
export = {"models": {}, "breeding_records": []}
|
|
325
|
+
|
|
326
|
+
for model in models:
|
|
327
|
+
export["models"][f"{model.name}@{model.version}"] = {
|
|
328
|
+
"name": model.name,
|
|
329
|
+
"version": model.version,
|
|
330
|
+
"traits": model.traits or {},
|
|
331
|
+
"checksum": getattr(model, "checksum", None),
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
with open("pedigree_import.json", "w") as f:
|
|
335
|
+
json.dump(export, f, indent=2)
|
|
336
|
+
|
|
337
|
+
# Then in Pedigree:
|
|
338
|
+
# p = Pedigree("pedigree_import.json")
|
|
339
|
+
# p.check_inbreeding("domain-instruct-v1", "domain-reasoning-v1")
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## License
|
|
343
|
+
|
|
344
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# The Lineage Tracker
|
|
2
|
+
|
|
3
|
+
> Fine-tune provenance as bloodline records. Every checkpoint, every merge, every fine-tune — traceable like a breeder's studbook.
|
|
4
|
+
|
|
5
|
+
[](https://python.org)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](tests/)
|
|
8
|
+
|
|
9
|
+
Every model has a family tree. Base models beget fine-tunes. Fine-tunes beget merges. Merges beget quantizations. After three layers of adaptation, nobody remembers who descended from whom — or whether that merge you're about to deploy has a known-broken checkpoint in its ancestry. Lineage Tracker treats this seriously, recording every fine-tune event as a structured breeding record with full provenance, checksums, and trait tracking.
|
|
10
|
+
|
|
11
|
+
## What It Does
|
|
12
|
+
|
|
13
|
+
Lineage Tracker maintains a JSON-backed registry of models and their breeding history. Every fine-tune, merge, distillation, or continued pre-training is recorded as a `BreedingRecord` that links parents to children with method metadata (LoRA rank, dataset, epochs, merge strategy). Models carry traits (benchmark scores, capabilities, known limitations) and checksums for identity verification.
|
|
14
|
+
|
|
15
|
+
The tracker supports lineage queries — walk any model's ancestry back through generations, compare capabilities across sibling checkpoints, and get breeding recommendations for diversity. This matters because blind fine-tuning is how capability regressions sneak into production. If your customer-facing model suddenly can't do math, you need to know: was it the merge? The adapter? The base model upgrade? Lineage tracking turns that detective work into a single query.
|
|
16
|
+
|
|
17
|
+
The core equation from Working Animal Architecture is **γ + η = C** (genome + nurture = capability). Lineage tracking is the **γ** — the genome, the bloodline record that makes selective breeding possible. Without it, you're doing random mutations and hoping for the best.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install lineage-tracker
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For development:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/SuperInstance/lineage-tracker.git
|
|
29
|
+
cd lineage-tracker
|
|
30
|
+
pip install -e ".[dev]"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from lineage_tracker import LineageTracker
|
|
37
|
+
|
|
38
|
+
tracker = LineageTracker("lineage.json")
|
|
39
|
+
|
|
40
|
+
# Record a breeding (fine-tune) event
|
|
41
|
+
child = tracker.record_breeding(
|
|
42
|
+
parents=["base-llama-3-70b"],
|
|
43
|
+
child_name="my-ft-v1",
|
|
44
|
+
method="lora",
|
|
45
|
+
metadata={
|
|
46
|
+
"rank": 64,
|
|
47
|
+
"dataset": "instruct-v2",
|
|
48
|
+
"epochs": 3,
|
|
49
|
+
"learning_rate": 2e-4,
|
|
50
|
+
},
|
|
51
|
+
child_traits={
|
|
52
|
+
"mmlu": 82.3,
|
|
53
|
+
"human_eval": 71.5,
|
|
54
|
+
"gsm8k": 78.1,
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Query lineage — walk ancestry back through generations
|
|
59
|
+
lineage = tracker.get_lineage("my-ft-v1")
|
|
60
|
+
for gen in lineage:
|
|
61
|
+
print(f"Generation {gen.generation}: {gen.model.name} (v{gen.model.version})")
|
|
62
|
+
if gen.model.traits:
|
|
63
|
+
print(f" Traits: {gen.model.traits}")
|
|
64
|
+
|
|
65
|
+
# Compare two siblings
|
|
66
|
+
diff = tracker.compare_generations("my-ft-v1", "my-ft-v2")
|
|
67
|
+
print(diff.summary)
|
|
68
|
+
|
|
69
|
+
# Get breeding recommendations based on trait diversity
|
|
70
|
+
recs = tracker.recommend_breeding("my-ft-v1", criteria="diversity")
|
|
71
|
+
for rec in recs[:3]:
|
|
72
|
+
print(f" Pair with: {rec.model_name} (diversity: {rec.score:.2f})")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Data Model
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
Model BreedingRecord
|
|
79
|
+
├── name ├── parents: list[str]
|
|
80
|
+
├── version ├── child: str
|
|
81
|
+
├── traits: dict ├── method: str (lora|full|merge|distill|...)
|
|
82
|
+
├── checksum: str ├── timestamp: str
|
|
83
|
+
├── metadata: dict
|
|
84
|
+
Generation └── generation: int
|
|
85
|
+
├── model: Model
|
|
86
|
+
└── generation: int
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### JSON Store Structure
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"models": {
|
|
94
|
+
"my-ft-v1@1.0": {
|
|
95
|
+
"name": "my-ft-v1",
|
|
96
|
+
"version": "1.0",
|
|
97
|
+
"traits": {"mmlu": 82.3, "human_eval": 71.5},
|
|
98
|
+
"checksum": "a1b2c3d4e5f6g7h8"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"breeding_records": [
|
|
102
|
+
{
|
|
103
|
+
"parents": ["base-llama-3-70b"],
|
|
104
|
+
"child": "my-ft-v1",
|
|
105
|
+
"method": "lora",
|
|
106
|
+
"timestamp": "2026-07-12T14:30:00Z",
|
|
107
|
+
"metadata": {"rank": 64, "dataset": "instruct-v2"},
|
|
108
|
+
"generation": 1
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"generations": {
|
|
112
|
+
"my-ft-v1@1.0": 1
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## API Reference
|
|
118
|
+
|
|
119
|
+
### `LineageTracker`
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
class LineageTracker:
|
|
123
|
+
def __init__(self, path: str = "lineage.json")
|
|
124
|
+
|
|
125
|
+
# Recording
|
|
126
|
+
def record_breeding(
|
|
127
|
+
self,
|
|
128
|
+
parents: list[str],
|
|
129
|
+
child_name: str,
|
|
130
|
+
method: str = "full",
|
|
131
|
+
metadata: dict | None = None,
|
|
132
|
+
child_version: str = "1.0",
|
|
133
|
+
child_traits: dict | None = None,
|
|
134
|
+
) -> Model
|
|
135
|
+
|
|
136
|
+
# Querying
|
|
137
|
+
def get_lineage(self, name: str) -> list[Generation]
|
|
138
|
+
def get_model(self, name: str) -> Model | None
|
|
139
|
+
def get_all_models(self) -> list[Model]
|
|
140
|
+
def compare_generations(self, a: str, b: str) -> GenerationDiff
|
|
141
|
+
def recommend_breeding(self, name: str, criteria: str = "diversity") -> list[Recommendation]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Breeding Methods
|
|
145
|
+
|
|
146
|
+
| Method | Description |
|
|
147
|
+
|--------|-------------|
|
|
148
|
+
| `full` | Full-parameter fine-tuning |
|
|
149
|
+
| `lora` | LoRA / QLoRA adapter training |
|
|
150
|
+
| `merge` | Model merging (SLERP, DARE, TIES, linear) |
|
|
151
|
+
| `distill` | Knowledge distillation from teacher to student |
|
|
152
|
+
| `continue_pretrain` | Continued pre-training on new domain data |
|
|
153
|
+
| `rlhf` | Reinforcement learning from human feedback |
|
|
154
|
+
| `sft` | Supervised fine-tuning |
|
|
155
|
+
|
|
156
|
+
## Testing
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pip install -e ".[dev]"
|
|
160
|
+
pytest tests/ -v
|
|
161
|
+
|
|
162
|
+
# Run specific test modules
|
|
163
|
+
pytest tests/test_tracker.py -v
|
|
164
|
+
pytest tests/test_store.py -v
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Philosophy
|
|
168
|
+
|
|
169
|
+
Selective breeding changed civilization. The ability to record lineage, track traits across generations, and make informed pairing decisions is what separated agriculture from hunting-gathering. Lineage Tracker brings that same leap to AI — transforming model development from ad-hoc experimentation into a disciplined breeding program.
|
|
170
|
+
|
|
171
|
+
This is the γ (genome) half of γ + η = C. Without lineage records, you can't do selective breeding — you're just hoping each fine-tune is better than the last. With lineage records, you can identify which breeding strategies produce the best offspring, avoid reinforcing known weaknesses, and build a structured improvement program.
|
|
172
|
+
|
|
173
|
+
For more on the breeding paradigm in AI, see [AI-Writings](https://github.com/SuperInstance/AI-Writings).
|
|
174
|
+
|
|
175
|
+
## Ecosystem
|
|
176
|
+
|
|
177
|
+
| Repo | Role |
|
|
178
|
+
|------|------|
|
|
179
|
+
| **[lineage-tracker](https://github.com/SuperInstance/lineage-tracker)** | **This repo** — provenance tracking |
|
|
180
|
+
| [pedigree](https://github.com/SuperInstance/pedigree) | Bloodline tracking with inbreeding coefficients and visualization |
|
|
181
|
+
| [breed-registry](https://github.com/SuperInstance/breed-registry) | Breed assessment and task matching |
|
|
182
|
+
| [baton](https://github.com/SuperInstance/baton) | Generational handoff (carries lessons between lineage generations) |
|
|
183
|
+
| [vetcheck](https://github.com/SuperInstance/vetcheck) | Health monitoring for registered models |
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Lineage Tracker vs Pedigree: When to Use Which
|
|
188
|
+
|
|
189
|
+
Both [Lineage Tracker](https://github.com/SuperInstance/lineage-tracker) and [Pedigree](https://github.com/SuperInstance/pedigree) track model ancestry. They overlap but serve different primary use cases:
|
|
190
|
+
|
|
191
|
+
| Concern | Lineage Tracker | Pedigree |
|
|
192
|
+
|---------|----------------|----------|
|
|
193
|
+
| **Primary focus** | Provenance records | Bloodline analysis |
|
|
194
|
+
| **Data model** | Flat breeding records with metadata | Genealogical tree with sire/dam |
|
|
195
|
+
| **Inbreeding detection** | No (recommendations based on trait diversity) | Yes (Wright's coefficient of relationship) |
|
|
196
|
+
| **Visualization** | Programmatic queries | ASCII trees + GraphViz DOT export |
|
|
197
|
+
| **Trait comparison** | Yes (compare generations side-by-side) | Limited |
|
|
198
|
+
| **Breeding method tracking** | Rich metadata (LoRA rank, LR, epochs, merge strategy) | Basic method tags |
|
|
199
|
+
| **Best for** | MLOps: "what happened in this fine-tune chain?" | Research: "is this merge genetically safe?" |
|
|
200
|
+
|
|
201
|
+
**Use Lineage Tracker when** you need audit trails for production models — what was trained on what, with what hyperparameters, and what the benchmark impact was. The metadata-rich records are designed for compliance and debugging.
|
|
202
|
+
|
|
203
|
+
**Use Pedigree when** you need genetic analysis — inbreeding coefficients before merging, diversity scoring for outcross recommendations, and publication-quality lineage trees. The sire/dam model maps cleanly to how animal breeders think about bloodlines.
|
|
204
|
+
|
|
205
|
+
**Use both when** you're running a serious breeding program. Lineage Tracker records the events; Pedigree analyzes the bloodline. Export from one, import to the other.
|
|
206
|
+
|
|
207
|
+
## Advanced Scenario: Debugging a Capability Regression
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from lineage_tracker import LineageTracker
|
|
211
|
+
|
|
212
|
+
tracker = LineageTracker("lineage.json")
|
|
213
|
+
|
|
214
|
+
# Your production model suddenly can't do math
|
|
215
|
+
# Trace its ancestry to find the culprit
|
|
216
|
+
lineage = tracker.get_lineage("prod-model-v7")
|
|
217
|
+
|
|
218
|
+
print("Ancestry chain:")
|
|
219
|
+
for gen in lineage:
|
|
220
|
+
model = gen.model
|
|
221
|
+
gsm8k = model.traits.get("gsm8k", "N/A")
|
|
222
|
+
print(f" Gen {gen.generation}: {model.name}@{model.version}")
|
|
223
|
+
print(f" gsm8k: {gsm8k}")
|
|
224
|
+
print(f" method: {gen.breeding_method if hasattr(gen, 'breeding_method') else 'unknown'}")
|
|
225
|
+
|
|
226
|
+
# Output reveals:
|
|
227
|
+
# Gen 0: base-llama-3-70b gsm8k: 82.1 (baseline)
|
|
228
|
+
# Gen 1: instruct-sft-v3 gsm8k: 79.4 (-2.7 after SFT)
|
|
229
|
+
# Gen 2: creative-merge-v1 gsm8k: 71.2 (-8.2 after merge!) ← CULPRIT
|
|
230
|
+
# Gen 3: prod-model-v7 gsm8k: 68.9 (-2.3 after continued training)
|
|
231
|
+
|
|
232
|
+
# The merge at Gen 2 caused the regression
|
|
233
|
+
# Now check what was merged:
|
|
234
|
+
records = [r for r in tracker.get_all_models() if "creative-merge" in r.name]
|
|
235
|
+
for r in records:
|
|
236
|
+
print(f" {r.name}: parents={r.parent_ids}, traits={r.traits}")
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Multi-Generation Breeding Program
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from lineage_tracker import LineageTracker
|
|
243
|
+
|
|
244
|
+
tracker = LineageTracker("breeding-program.json")
|
|
245
|
+
|
|
246
|
+
# Generation 0: Foundation
|
|
247
|
+
tracker.record_breeding(
|
|
248
|
+
parents=["llama-3-70b"],
|
|
249
|
+
child_name="domain-base-v1",
|
|
250
|
+
method="continue_pretrain",
|
|
251
|
+
metadata={"dataset": "domain_corpus_v1", "tokens": "5B"},
|
|
252
|
+
child_traits={"mmlu": 80.1, "domain_eval": 72.0},
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
# Generation 1: Specialization
|
|
256
|
+
tracker.record_breeding(
|
|
257
|
+
parents=["domain-base-v1"],
|
|
258
|
+
child_name="domain-instruct-v1",
|
|
259
|
+
method="sft",
|
|
260
|
+
metadata={"dataset": "instruct_v2", "epochs": 3, "lr": 2e-5},
|
|
261
|
+
child_traits={"mmlu": 81.2, "domain_eval": 78.5, "if_eval": 84.0},
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
# Generation 1: Alternative specialization (different focus)
|
|
265
|
+
tracker.record_breeding(
|
|
266
|
+
parents=["domain-base-v1"],
|
|
267
|
+
child_name="domain-reasoning-v1",
|
|
268
|
+
method="rlhf",
|
|
269
|
+
metadata={"reward_model": "rm-v2", "kl_coef": 0.1},
|
|
270
|
+
child_traits={"mmlu": 82.0, "domain_eval": 75.0, "gsm8k": 85.1},
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
# Generation 2: Merge the best of both specializations
|
|
274
|
+
tracker.record_breeding(
|
|
275
|
+
parents=["domain-instruct-v1", "domain-reasoning-v1"],
|
|
276
|
+
child_name="domain-merged-v2",
|
|
277
|
+
method="merge",
|
|
278
|
+
metadata={"strategy": "SLERP", "ratio": "0.5"},
|
|
279
|
+
child_traits={"mmlu": 83.1, "domain_eval": 79.0, "gsm8k": 84.2, "if_eval": 83.5},
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
# Query the full program
|
|
283
|
+
print(f"Total models tracked: {len(tracker.get_all_models())}")
|
|
284
|
+
for model in tracker.get_all_models():
|
|
285
|
+
print(f" {model.name}@{model.version}: {model.traits}")
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Export for Pedigree Analysis
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
from lineage_tracker import LineageTracker
|
|
292
|
+
|
|
293
|
+
tracker = LineageTracker("lineage.json")
|
|
294
|
+
|
|
295
|
+
# Export to a format Pedigree can consume
|
|
296
|
+
import json
|
|
297
|
+
|
|
298
|
+
models = tracker.get_all_models()
|
|
299
|
+
export = {"models": {}, "breeding_records": []}
|
|
300
|
+
|
|
301
|
+
for model in models:
|
|
302
|
+
export["models"][f"{model.name}@{model.version}"] = {
|
|
303
|
+
"name": model.name,
|
|
304
|
+
"version": model.version,
|
|
305
|
+
"traits": model.traits or {},
|
|
306
|
+
"checksum": getattr(model, "checksum", None),
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
with open("pedigree_import.json", "w") as f:
|
|
310
|
+
json.dump(export, f, indent=2)
|
|
311
|
+
|
|
312
|
+
# Then in Pedigree:
|
|
313
|
+
# p = Pedigree("pedigree_import.json")
|
|
314
|
+
# p.check_inbreeding("domain-instruct-v1", "domain-reasoning-v1")
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
MIT — see [LICENSE](LICENSE).
|