API Reference¶
Complete reference for the reptimeline Python package.
Core Data Structures¶
Foundational dataclasses: ConceptSnapshot, CodeEvent, ConnectionEvent, PhaseTransition, Timeline.
reptimeline.core
¶
Core data structures for representation timeline tracking.
These dataclasses are backend-agnostic — they work with any discrete representation system (triadic bits, VQ-VAE, FSQ, sparse autoencoders).
ConceptSnapshot
dataclass
¶
What a model "thinks" about a set of concepts at a given training step.
This is the universal exchange format between extractors and the tracker. Every backend (triadic, VQ-VAE, FSQ) produces these.
Source code in triadic-microgpt-src/reptimeline/core.py
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 44 45 46 47 48 | |
hamming(concept_a: str, concept_b: str) -> int
¶
Hamming distance between two concept codes.
Source code in triadic-microgpt-src/reptimeline/core.py
36 37 38 39 40 41 | |
active_indices(concept: str) -> List[int]
¶
Indices where code == 1 for a concept.
Source code in triadic-microgpt-src/reptimeline/core.py
43 44 45 46 47 48 | |
CodeEvent
dataclass
¶
A discrete event in a code element's lifecycle.
Source code in triadic-microgpt-src/reptimeline/core.py
51 52 53 54 55 56 57 58 | |
ConnectionEvent
dataclass
¶
When two concepts first share (or lose) a discrete feature.
Source code in triadic-microgpt-src/reptimeline/core.py
61 62 63 64 65 66 67 68 | |
PhaseTransition
dataclass
¶
A detected discontinuity in a training metric.
Source code in triadic-microgpt-src/reptimeline/core.py
71 72 73 74 75 76 77 | |
Timeline
dataclass
¶
Complete analysis result from TimelineTracker.
Source code in triadic-microgpt-src/reptimeline/core.py
80 81 82 83 84 85 86 87 88 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
print_summary()
¶
Print a concise console summary.
Source code in triadic-microgpt-src/reptimeline/core.py
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
Timeline Tracker¶
Analyzes representation evolution across training snapshots. Detects births, deaths, connections, and phase transitions.
reptimeline.tracker
¶
TimelineTracker — Backend-agnostic analysis of representation evolution.
Consumes a sequence of ConceptSnapshot objects and computes lifecycle events: births, deaths, connections, phase transitions, churn, stability.
TimelineTracker
¶
Analyzes how discrete representations evolve across training snapshots.
Source code in triadic-microgpt-src/reptimeline/tracker.py
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 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 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 119 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
analyze(snapshots: List[ConceptSnapshot], concept_pairs: Optional[List[Tuple[str, str]]] = None) -> Timeline
¶
Run full timeline analysis on a sequence of snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshots
|
List[ConceptSnapshot]
|
List of ConceptSnapshot sorted by step. |
required |
concept_pairs
|
Optional[List[Tuple[str, str]]]
|
Optional pairs to track connections for. If None, tracks all pairs (can be slow for many concepts). |
None
|
Returns:
| Type | Description |
|---|---|
Timeline
|
Timeline with all lifecycle events and curves. |
Source code in triadic-microgpt-src/reptimeline/tracker.py
32 33 34 35 36 37 38 39 40 41 42 43 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 | |
Discovery¶
Bottom-up ontology discovery without prior knowledge. Finds duals, dependencies, triadic interactions, and hierarchy.
reptimeline.discovery
¶
BitDiscovery — Discover what each bit "means" from unsupervised training.
Instead of pre-defining primitives and supervising, this module: 1. Takes a trained model (no anchor supervision needed) 2. Runs a large concept vocabulary through it 3. Analyzes which concepts activate which bits 4. Discovers: bit semantics, hierarchy, duals, dependencies
This enables bottom-up primitive discovery: the model invents its own ontology and reptimeline discovers what it is.
BitSemantics
dataclass
¶
What a single bit "means" based on what concepts activate it.
Source code in triadic-microgpt-src/reptimeline/discovery.py
23 24 25 26 27 28 29 30 | |
DiscoveredDual
dataclass
¶
A pair of bits that behave as opposites (anti-correlated).
Source code in triadic-microgpt-src/reptimeline/discovery.py
33 34 35 36 37 38 39 40 | |
DiscoveredDependency
dataclass
¶
Bit B almost never activates without bit A being active first.
Source code in triadic-microgpt-src/reptimeline/discovery.py
43 44 45 46 47 48 49 | |
DiscoveredTriadicDep
dataclass
¶
A 3-way interaction: bit r activates only when bits i AND j are both active.
This is an AND-gate in semantic space: neither i alone nor j alone predicts r, but their conjunction does. Analogous to epistasis in genetics.
Source code in triadic-microgpt-src/reptimeline/discovery.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
DiscoveredHierarchy
dataclass
¶
Bits ordered by when they first stabilize during training.
Source code in triadic-microgpt-src/reptimeline/discovery.py
69 70 71 72 73 74 75 | |
DiscoveryReport
dataclass
¶
Complete bottom-up discovery of what a model learned.
Source code in triadic-microgpt-src/reptimeline/discovery.py
78 79 80 81 82 83 84 85 86 87 88 | |
BitDiscovery
¶
Discovers what each bit encodes without prior knowledge of primitives.
This is the inverse of PrimitiveOverlay: instead of mapping known primitives onto bits, it discovers what the bits mean by analyzing activation patterns across a large concept vocabulary.
Source code in triadic-microgpt-src/reptimeline/discovery.py
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 119 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
discover(snapshot: ConceptSnapshot, timeline: Optional[Timeline] = None, top_k: int = 10) -> DiscoveryReport
¶
Discover bit semantics from a single snapshot (or a full timeline).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
ConceptSnapshot
|
A ConceptSnapshot with codes for many concepts. Use the LAST snapshot from training for best results. |
required |
timeline
|
Optional[Timeline]
|
Optional full timeline for hierarchy discovery. |
None
|
top_k
|
int
|
Number of top/anti concepts per bit. |
10
|
Source code in triadic-microgpt-src/reptimeline/discovery.py
119 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 | |
print_report(report: DiscoveryReport)
¶
Print discovery results.
Source code in triadic-microgpt-src/reptimeline/discovery.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
AutoLabeler¶
Translates discovered bit semantics to human-readable labels using three strategies: embedding, contrastive, and LLM.
reptimeline.autolabel
¶
AutoLabeler — Automatically name discovered bits using semantic analysis.
Three strategies
- Embedding-based: find the word closest to the centroid of active concepts
- Contrastive: find the word that best separates active vs inactive concepts
- LLM-based: ask an LLM "what do these concepts have in common?"
Strategy 1 and 2 work offline (no API needed). Strategy 3 is most accurate but requires an LLM API call.
BitLabel
dataclass
¶
A discovered label for a bit.
Source code in triadic-microgpt-src/reptimeline/autolabel.py
23 24 25 26 27 28 29 30 31 | |
AutoLabeler
¶
Assigns human-readable labels to discovered bits.
Source code in triadic-microgpt-src/reptimeline/autolabel.py
34 35 36 37 38 39 40 41 42 43 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 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 119 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
label_by_embedding(report: DiscoveryReport, embeddings: Dict[str, np.ndarray], candidate_labels: Optional[List[str]] = None) -> List[BitLabel]
¶
Name each bit by finding the word closest to the centroid of its active concepts in embedding space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
DiscoveryReport
|
DiscoveryReport from BitDiscovery. |
required |
embeddings
|
Dict[str, ndarray]
|
Dict mapping concept -> embedding vector. |
required |
candidate_labels
|
Optional[List[str]]
|
Optional restricted vocabulary for labels. If None, uses all keys in embeddings. |
None
|
Source code in triadic-microgpt-src/reptimeline/autolabel.py
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 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 | |
label_by_contrast(report: DiscoveryReport, embeddings: Dict[str, np.ndarray], candidate_labels: Optional[List[str]] = None) -> List[BitLabel]
¶
Name each bit by finding the word that best separates active concepts from inactive concepts.
The label is the word whose embedding is most similar to (centroid_active - centroid_inactive).
Source code in triadic-microgpt-src/reptimeline/autolabel.py
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 | |
label_by_llm(report: DiscoveryReport, llm_fn: Callable[[str], str]) -> List[BitLabel]
¶
Name each bit by asking an LLM what the active concepts have in common.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
DiscoveryReport
|
DiscoveryReport. |
required |
llm_fn
|
Callable[[str], str]
|
Function that takes a prompt string and returns the LLM's response string. User provides their own API wrapper. |
required |
Example llm_fn
def my_llm(prompt): response = openai.chat.completions.create( model="gpt-4", messages=[{"role":"user","content":prompt}]) return response.choices[0].message.content
Source code in triadic-microgpt-src/reptimeline/autolabel.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
print_labels(labels: List[BitLabel])
¶
Print discovered labels.
Source code in triadic-microgpt-src/reptimeline/autolabel.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
export_as_primitives(labels: List[BitLabel], output_path: str)
¶
Export discovered labels as a primitivos.json-compatible file.
This allows using discovered primitives as if they were manually defined — closing the loop between discovery and supervision.
Source code in triadic-microgpt-src/reptimeline/autolabel.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
Reconciler¶
Compares discovered ontology against theoretical expectations. Suggests corrections in both directions.
reptimeline.reconcile
¶
Reconciler — Compare discovered ontology vs manual ontology, suggest corrections.
Closes the loop
- Train model (with or without supervision)
- BitDiscovery discovers what the model learned
- PrimitiveOverlay defines what the theory says
- Reconciler finds mismatches and suggests corrections
Corrections can go in BOTH directions
- Fix the model: generate corrected anchors for retraining
- Fix the theory: suggest changes to primitivos.json
BitMismatch
dataclass
¶
A discovered incongruence between model and theory.
Source code in triadic-microgpt-src/reptimeline/reconcile.py
26 27 28 29 30 31 32 33 34 35 36 37 | |
DualMismatch
dataclass
¶
A dual pair that doesn't match between discovery and theory.
Source code in triadic-microgpt-src/reptimeline/reconcile.py
40 41 42 43 44 45 46 47 48 49 | |
DepMismatch
dataclass
¶
A dependency that doesn't match between discovery and theory.
Source code in triadic-microgpt-src/reptimeline/reconcile.py
52 53 54 55 56 57 58 59 60 61 | |
ReconciliationReport
dataclass
¶
Full comparison between discovered and theoretical ontology.
Source code in triadic-microgpt-src/reptimeline/reconcile.py
64 65 66 67 68 69 70 71 72 73 | |
Reconciler
¶
Compares discovered structure with theoretical primitives.
Finds mismatches and suggests corrections in both directions.
Source code in triadic-microgpt-src/reptimeline/reconcile.py
76 77 78 79 80 81 82 83 84 85 86 87 88 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 119 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
reconcile(discovery_report: DiscoveryReport, snapshot_codes: Dict[str, List[int]]) -> ReconciliationReport
¶
Compare discovered ontology with theoretical primitives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
discovery_report
|
DiscoveryReport
|
Output from BitDiscovery.discover(). |
required |
snapshot_codes
|
Dict[str, List[int]]
|
The codes dict from the snapshot used for discovery. |
required |
Source code in triadic-microgpt-src/reptimeline/reconcile.py
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
print_report(report: ReconciliationReport)
¶
Print reconciliation results.
Source code in triadic-microgpt-src/reptimeline/reconcile.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
Extractors¶
Base Extractor¶
Abstract interface for representation backends. Implement three methods to add a new backend.
reptimeline.extractors.base
¶
Abstract base class for representation extractors.
Each backend (triadic, VQ-VAE, FSQ, sparse autoencoder) implements this interface to produce standardized ConceptSnapshot objects.
RepresentationExtractor
¶
Bases: ABC
Extracts discrete concept representations from model checkpoints.
Source code in triadic-microgpt-src/reptimeline/extractors/base.py
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 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 89 90 91 92 93 94 95 96 97 98 | |
extract(checkpoint_path: str, concepts: List[str], device: str = 'cpu') -> ConceptSnapshot
abstractmethod
¶
Extract a snapshot from a single checkpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path
|
str
|
Path to the model checkpoint file. |
required |
concepts
|
List[str]
|
List of concept strings to extract. |
required |
device
|
str
|
Torch device string. |
'cpu'
|
Returns:
| Type | Description |
|---|---|
ConceptSnapshot
|
ConceptSnapshot with codes for each concept found. |
Source code in triadic-microgpt-src/reptimeline/extractors/base.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
similarity(code_a: List[int], code_b: List[int]) -> float
abstractmethod
¶
Compute similarity between two concept codes.
Returns a value in [0, 1] where 1 means identical.
Source code in triadic-microgpt-src/reptimeline/extractors/base.py
34 35 36 37 38 39 40 | |
shared_features(code_a: List[int], code_b: List[int]) -> List[int]
abstractmethod
¶
Return indices of features shared by both codes.
Source code in triadic-microgpt-src/reptimeline/extractors/base.py
42 43 44 45 | |
discover_checkpoints(directory: str) -> List[Tuple[int, str]]
¶
Find all step checkpoints in a directory, sorted by step.
Handles common naming patterns
- model_step5000.pt
- model_xl_step5000.pt
- model_best.pt (excluded — not a step checkpoint)
Returns:
| Type | Description |
|---|---|
List[Tuple[int, str]]
|
List of (step, path) tuples sorted ascending. |
Source code in triadic-microgpt-src/reptimeline/extractors/base.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
extract_sequence(directory: str, concepts: List[str], device: str = 'cpu', max_checkpoints: Optional[int] = None) -> List[ConceptSnapshot]
¶
Extract snapshots from all checkpoints in a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
Checkpoint directory. |
required |
concepts
|
List[str]
|
Concepts to track. |
required |
device
|
str
|
Torch device. |
'cpu'
|
max_checkpoints
|
Optional[int]
|
Limit number of checkpoints (evenly spaced). |
None
|
Returns:
| Type | Description |
|---|---|
List[ConceptSnapshot]
|
List of ConceptSnapshot sorted by step. |
Source code in triadic-microgpt-src/reptimeline/extractors/base.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
Triadic Extractor¶
TriadicGPT-specific extractor that loads model checkpoints and extracts 63-bit codes.
reptimeline.extractors.triadic
¶
Triadic extractor — loads TriadicGPT checkpoints and extracts 63-bit codes.
This is the concrete proof-of-concept backend. It wraps the existing src/evaluate.py, src/triadic.py infrastructure.
TriadicExtractor
¶
Bases: RepresentationExtractor
Extracts triadic bit representations from TriadicGPT checkpoints.
Uses PrimeMapper for bit->prime mapping and TriadicValidator for algebraic similarity (Jaccard on prime factors, GCD-based connections).
Source code in triadic-microgpt-src/reptimeline/extractors/triadic.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
extract(checkpoint_path: str, concepts: List[str], device: str = 'cpu') -> ConceptSnapshot
¶
Extract triadic snapshot from a TriadicGPT checkpoint.
Source code in triadic-microgpt-src/reptimeline/extractors/triadic.py
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
similarity(code_a: List[int], code_b: List[int]) -> float
¶
Jaccard similarity on active bits.
Source code in triadic-microgpt-src/reptimeline/extractors/triadic.py
105 106 107 108 109 110 111 112 113 114 | |
shared_features(code_a: List[int], code_b: List[int]) -> List[int]
¶
Indices where both codes are active (both == 1).
Source code in triadic-microgpt-src/reptimeline/extractors/triadic.py
116 117 118 119 | |
algebraic_similarity(composite_a: int, composite_b: int) -> float
¶
GCD-based similarity using prime factorization.
This is the triadic-specific similarity: Jaccard on prime factors. More meaningful than bit-level Jaccard because it respects the algebraic structure.
Source code in triadic-microgpt-src/reptimeline/extractors/triadic.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
are_connected(composite_a: int, composite_b: int) -> bool
¶
Two concepts are connected if they share at least one prime factor.
Source code in triadic-microgpt-src/reptimeline/extractors/triadic.py
136 137 138 | |
Overlays¶
Primitive Overlay¶
Triadic-specific analysis: layer emergence, dual coherence, dependency completions.
reptimeline.overlays.primitive_overlay
¶
PrimitiveOverlay — Maps generic timeline events onto the 63 triadic primitives.
This overlay adds triadic-specific semantics on top of the backend-agnostic Timeline produced by TimelineTracker:
- Primitive activation epochs: when each of the 63 primitives first activates
- Dependency chain completion: when all deps of a primitive are satisfied
- Layer emergence order: do layer-1 primitives stabilize before layer-4?
- Dual axis coherence: when dual pairs become anti-correlated
PrimitiveInfo
dataclass
¶
Parsed info for one of the 63 primitives.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
21 22 23 24 25 26 27 28 29 30 | |
ActivationEpoch
dataclass
¶
When a primitive first becomes active for a given concept.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
33 34 35 36 37 38 39 | |
DepsCompletion
dataclass
¶
When all dependencies of a primitive are simultaneously active.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
42 43 44 45 46 47 48 49 | |
LayerEmergence
dataclass
¶
Aggregate statistics for when a layer's primitives emerge.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
52 53 54 55 56 57 58 59 60 61 | |
DualCoherence
dataclass
¶
Tracks whether dual pairs show expected anti-correlation.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
64 65 66 67 68 69 70 71 | |
PrimitiveReport
dataclass
¶
Full overlay analysis output.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
74 75 76 77 78 79 80 81 | |
PrimitiveOverlay
¶
Interprets a Timeline through the lens of the 63 triadic primitives.
This is not an extractor or tracker — it takes an already-computed Timeline and overlays domain-specific analysis.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
84 85 86 87 88 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 119 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
analyze(timeline: Timeline, concepts: Optional[List[str]] = None) -> PrimitiveReport
¶
Run full primitive overlay analysis on a Timeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeline
|
Timeline
|
A Timeline from TimelineTracker.analyze(). |
required |
concepts
|
Optional[List[str]]
|
Subset of concepts to analyze. If None, uses all concepts from the last snapshot. |
None
|
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
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 | |
print_report(report: PrimitiveReport)
¶
Print a structured console summary.
Source code in triadic-microgpt-src/reptimeline/overlays/primitive_overlay.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |