Skip to main content

TVC Distributed Learning

TVC (Ternary Vector Corpus) is Trinity's distributed continual learning system. It provides zero-forgetting knowledge storage using ternary vector embeddings, bundled into a persistent corpus for instant retrieval.

Commands

tvc-demo

Interactive demonstration of the TVC distributed learning system.

Aliases: tvc

tri tvc-demo

Shows:

  • Corpus architecture and configuration
  • Hit/miss semantics with cosine similarity
  • Bundling and retrieval demo
  • Distributed learning flow

Example output:

TVC DISTRIBUTED LEARNING — DEMO
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Architecture:
┌──────────────┐ ┌──────────────┐
│ Query │───→│ TVC Corpus │
│ (embed) │ │ 10K entries │
└──────────────┘ └──────┬───────┘

┌────────┴────────┐
│ Similarity ≥ φ⁻¹│
│ (0.618)? │
└────────┬────────┘
YES │ NO
┌───────┐ │ ┌───────┐
│ CACHE │ │ LLM │
│ HIT │ │ CALL │
└────────┘ └───────┘

Configuration:
Capacity: 10,000 entries (100x TextCorpus)
Dimensions: 1,000 trits per vector
Threshold: phi^-1 = 0.618
Encoding: Ternary {-1, 0, +1}
File format: .tvc (TVC1 magic header)
Memory: ~26 MB heap-allocated

tvc-stats

Display TVC corpus configuration and statistics.

tri tvc-stats

Example output:

TVC STATISTICS
═══════════════════════════════════════════════════════════════════
TVC Enabled: Ready
Max Entries: 10,000
Vector Dimension: 1,000 trits
Threshold: 0.618 (phi^-1)
File Format: .tvc (TVC1 magic)
═══════════════════════════════════════════════════════════════════

Architecture

How TVC Works

  1. Query embedding: User input is converted to a 1,000-trit ternary vector
  2. Similarity search: Cosine similarity is computed against all corpus entries
  3. Threshold check: If similarity ϕ1=0.618\geq \phi^{-1} = 0.618, it's a cache hit
  4. Hit: Return cached response instantly (no LLM call needed)
  5. Miss: Call LLM, then store the query-response pair in the corpus

Zero-Forgetting Bundling

TVC uses the VSA bundle operation (majority vote) to accumulate all learned patterns into a single memory_vector. This means:

  • No patterns are ever discarded
  • New knowledge is bundled with existing knowledge
  • Retrieval uses cosine similarity against the bundled vector
  • Capacity: 10,000 discrete entries + 1 bundled memory vector

Comparison with TextCorpus

FeatureTextCorpusTVC Corpus
Capacity100 entries10,000 entries
Vector typeFloat32Ternary 1
Memory~40 MB~26 MB
CompressionNone20x (vs float32)
ForgettingFIFO evictionZero-forgetting
BundlingNoYes (majority vote)
File formatJSON.tvc binary

File Format

TVC files use a binary format with a TVC1 magic header:

Offset  Size    Field
0x00 4 Magic: "TVC1"
0x04 4 Version
0x08 4 Entry count
0x0C 4 Vector dimension
0x10 48 Reserved
0x40 ... Entries (vector + metadata)

Save path: data/trinity_chat.tvc (auto-saved on REPL exit)

Sacred Mathematics

The TVC threshold is derived from the golden ratio:

threshold=ϕ1=1ϕ=ϕ1=0.6180339887...\text{threshold} = \phi^{-1} = \frac{1}{\phi} = \phi - 1 = 0.6180339887...

This is the Needle threshold (Koschei's Needle) — the minimum similarity required for a cache hit. The number ϕ1\phi^{-1} is the reciprocal of the golden ratio and appears throughout Trinity's architecture as the quality gate.

Integration with Chat

TVC is automatically loaded when starting the REPL or using tri chat:

# TVC is loaded automatically
tri chat "What is VSA?"

# First time: LLM call + stored in TVC
# Second time: instant cache hit
tri chat "What is VSA?"

The TVC corpus persists across sessions via the data/trinity_chat.tvc file.

See Also