Skip to main content

Rotation-Retention Law: threshold analysis, knowledge mapping, and gradient alignment diagnostics for fine-tuned neural networks.

Project description

EgoRA RRL — Rotation-Retention Law Analysis

PyPI version License: AGPL v3 Python 3.9+

Rotation-Retention Law: threshold analysis, knowledge mapping, and gradient alignment diagnostics for fine-tuned neural networks. Companion package to egora.

Installation

pip install egora-rrl

With plotting and dataset support:

pip install egora-rrl[all]

Modules

1. Threshold Analysis (Rotation-Retention Law)

Tests the empirical law $\Delta M \propto \bar{\theta}$:

  • Dimensionality-aware critical threshold: $\theta_{\text{crit}} = \arcsin(1/\sqrt{d_{\text{head}}})$
  • Golden ratio $k$-check
  • Phase transition detection
  • Cross-architecture validation
from egora import compute_head_geometry
from egora_rrl import run_threshold_analysis

geo = compute_head_geometry(base_model, tuned_model)
results = run_threshold_analysis(
    geo, model_name="llama_8b",
    mmlu_base=63.42, mmlu_after=62.86,
    output_dir="analysis/",
)

2. Knowledge Map

Logit lens, attention probing, and Knowledge Concentration Index (KCI) to locate where knowledge lives in the model.

from egora_rrl import run_knowledge_map

summary = run_knowledge_map(model, tokenizer, output_dir="analysis/")

3. Alignment Landscape

Per-head gradient alignment between fine-tuning and capability-preservation directions. Identifies critical heads.

from egora_rrl import run_alignment_landscape

landscape = run_alignment_landscape(
    model, tokenizer,
    finetune_data=ft_loader,
    capability_data=cap_loader,
)

Resources

Link
📦 PyPI pip install egora-rrl
💻 GitHub ArsSocratica/EgoRA
DOI 10.5281/zenodo.19410504

License

This software is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0), with an Additional Permission for Academic Use pursuant to AGPL Section 7.

  • Academic use: Free, no copyleft obligations, citation required. See LICENSE-ACADEMIC.
  • Commercial use: Requires both a software license and a patent license.

Patent Notice

The methods implemented in this software are covered by U.S. Provisional Patent Application No. 64/024,742, filed April 1, 2026, by Mark Dillerop.

Contact: mark@dillerop.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

egora_rrl-0.3.1.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

egora_rrl-0.3.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file egora_rrl-0.3.1.tar.gz.

File metadata

  • Download URL: egora_rrl-0.3.1.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for egora_rrl-0.3.1.tar.gz
Algorithm Hash digest
SHA256 96ffa5834475a6e4a01289c0948031115f85aa64ef7679d013fcb275851eec7a
MD5 ab2631402d8a9c833ca7ba9ded780931
BLAKE2b-256 07a28c228844da9bd43f5b85646ae39b3e14f0a676472ba2b51dc7b596292dea

See more details on using hashes here.

File details

Details for the file egora_rrl-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: egora_rrl-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for egora_rrl-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53f216d076a3b28e9fb6757cec67fe503c75084281e28e1e936896e541982b56
MD5 3c6fcb0704a6f2a743b88edb57a9a26f
BLAKE2b-256 17c3143a9c215020b893c672c4dddfd2026c87cd490ef9ead95f544577430cac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page