🧠the-brain

Identity Anchor

Stable self-vector preventing catastrophic forgetting

The Identity Anchor plugin maintains a stable representation of your core coding identity across multiple training runs.

Why It Matters

Without an anchor, repeated LoRA training can cause catastrophic forgetting — the model drifts away from your fundamental preferences and coding style.

How It Works

  1. Capture: Watches SELECTION_PROMOTE for short, high-surprise declarative statements
    • Language-agnostic structural detection: 20-200 char fragments with surpriseScore ≥ threshold
    • No English keywords needed — works for Polish, Japanese, Chinese, any language
  2. Vectorize: Builds a self-vector from fragments with embeddings (requires ≥3 for stability)
  3. Detect Drift: Before each training run, computes cosine similarity between current and baseline
  4. Boost: If drift exceeds threshold, repeats anchor fragments N times in training data

Configuration

{
  "plugins": [
    {
      "name": "@the-brain/plugin-identity-anchor",
      "enabled": true,
      "config": {
        "driftThreshold": 0.3,
        "boostFactor": 5,
        "maxAnchorFragments": 20
      }
    }
  ]
}

How It Integrates

During overnight training, the Identity Anchor injects boosted fragments before MLX training:

DEEP_CONSOLIDATE hook fires

Identity Anchor: computeDrift()
  ↓ drift > 0.3?
Identity Anchor: getBoostedFragments()

MLX Trainer: [boostedFragments, ...trainingData]

On this page