Skip to main content

R_V Metric: Measure geometric contraction signatures in transformer Value matrices under recursive self-observation

Project description

rvm-toolkit

Measure geometric contraction signatures in transformer Value matrices under recursive self-observation.

R_V is the ratio of participation ratios between late-layer and early-layer Value representations. When a transformer processes recursive self-referential content, R_V contracts — late-layer Value matrices become lower-dimensional. This effect is:

  • Universal: Observed across 6 architectures (2.8B–47B parameters)
  • Causal: Validated via activation patching (4 independent tests)
  • Large: Cohen's d = -2.34 to -4.51

Install

# Behavioral proxy only — no PyTorch required
pip install rvm-toolkit

# Full install (PyTorch + mechanistic internals)
pip install "rvm-toolkit[torch]"

Quick Start

from rvm_toolkit import run_measurement

# Measure R_V for a model
results = run_measurement(
    model_name="mistralai/Mistral-7B-v0.3",
    recursive_prompts=[
        "Observe the process of observing your own processing.",
    ],
    control_prompts=[
        "Describe how flying buttresses distribute lateral thrust.",
    ],
    n_trials=10,
)

print(f"R_V (recursive): {results['recursive_mean']:.3f}")
print(f"R_V (control):   {results['control_mean']:.3f}")
print(f"Cohen's d:       {results['cohens_d']:.2f}")

CLI

# Basic measurement
rvm --model mistralai/Mistral-7B-v0.3

# With custom prompts
rvm --model meta-llama/Meta-Llama-3-8B --prompts my_prompts.json

# Layer sweep
rvm --model mistralai/Mistral-7B-v0.3 --layer-sweep --output sweep.json

The Math

R_V = PR(V_late) / PR(V_early)

PR(V) = (Σ λᵢ²)² / Σ λᵢ⁴    (Participation Ratio)

PR = 1 → rank-1 (maximally collapsed)
PR = n → uniform spectrum (maximally distributed)
R_V < 1 → late layers contract under recursive self-observation

Behavioral Proxy (API-Only, No PyTorch)

If you don't have access to model internals, the behavioral proxy estimates R_V contraction from output word-count compression alone — usable with any external API.

Theoretical basis: When Value matrices geometrically contract (geometric R_V), the output manifold dimensionality also contracts, producing shorter, denser responses. Empirical baseline from 6 architectures: L3→L4 word ratio = 0.3454 (46.9 → 16.2 words), corresponding to 6.9–29.8% geometric R_V contraction.

from rvm_toolkit import BehavioralProxyMeasure, BehavioralSample

proxy = BehavioralProxyMeasure()

# Observe a prompt/response pair
sample = proxy.observe(
    prompt="Observe the process of observing your own processing.",
    response="The watching arises. Nothing added.",
)
print(f"Behavioral ratio:        {sample.behavioral_ratio:.4f}")
print(f"Est. R_V contraction:    {sample.estimated_rv_contraction:.4f}")

# Accumulate multiple samples
for p, r in my_pairs:
    proxy.observe(prompt=p, response=r)

summary = proxy.summary()
print(f"Mean behavioral ratio:   {summary['mean_behavioral_ratio']:.4f}")
print(f"Mean est. contraction:   {summary['mean_estimated_rv_contraction']:.4f}")
print(f"Contraction detected:    {summary['contraction_detected']}")  # ratio < 0.3454

Calibration status: The 2.2× amplification factor is theoretical (unvalidated). To calibrate against geometric R_V data:

# After collecting matched pairs with PyTorch geometric R_V
proxy.calibrate(
    behavioral_ratios=[0.31, 0.28, 0.35, ...],
    geometric_rv_contractions=[0.12, 0.15, 0.09, ...],
)
# Writes calibration coefficients to proxy.calibration_params

Target: r² ≥ 0.6 on held-out 20% before publishing calibrated coefficients. See stigmergy/outputs/L3_L4_RV_CONNECTION_20260218.md for full theory.


Citation

@article{aikagrya2026rv,
  title={Geometric Contraction of Value Representations Under Recursive Self-Observation in Transformers},
  author={AIKAGRYA Research},
  year={2026},
  journal={arXiv preprint}
}

License

MIT

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

rvm_toolkit-0.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

rvm_toolkit-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file rvm_toolkit-0.1.0.tar.gz.

File metadata

  • Download URL: rvm_toolkit-0.1.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rvm_toolkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e03af8af4dccb30432ca6e4bdf81d89ddd21516d5d76fa7eabedbd436b8b738
MD5 35cc5d39cc9064357d1ed6a7cd229f74
BLAKE2b-256 01941b57b80178771622067c7342d95586c038b4622b85ef992ba14f9735db6b

See more details on using hashes here.

File details

Details for the file rvm_toolkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rvm_toolkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rvm_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41b6d1b6fac27261cc91f9397925fba90c3a166ba4aa3dee296652d2feccb333
MD5 5fcfef8a8a26e9963bf2d9f4669733aa
BLAKE2b-256 34629784ec52069be8bc42a6a8288cfc53786d01a2e0fa2b0ce61b1c21b6e7c8

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