Skip to main content

Activation Topology — reproducible persistent-homology measurement of LLM activation manifolds

Project description

actopo — Activation Topology

Reproducible persistent-homology measurement of LLM activation manifolds.

actopo provides one measurement protocol, one activation-extraction function, and one topology implementation, so β₁ / survival / PHI numbers stay consistent across every experiment. It is the tooling behind the Mathematical Life paper, packaged so the experiments can be reproduced.

Why

Re-implementing "compute β₁" in each analysis script lets the measurement silently diverge (different ε thresholds, wrong last-token extraction, etc.). actopo centralises the protocol in a single ProtocolConfig and stamps every result with the exact config + version + git revision that produced it.

Install

pip install actopo                 # topology layer (CPU only)
pip install "actopo[extract]"      # + activation extraction (torch/transformers)
pip install "actopo[all]"          # everything incl. dev/test

Quickstart

The package ships a tiny real example: reasoning activations from Qwen2.5-0.5B (base) vs Qwen2.5-0.5B-Instruct — the paper's core base-vs-instruct comparison.

from actopo import FROZEN_V5, measure
from actopo.metrics import union_test, center_distance
from actopo.data import load_example_cloud

base = load_example_cloud("base")        # (600, 896) reasoning activations
inst = load_example_cloud("instruct")

print(measure(base, FROZEN_V5).beta1)    # 12
print(measure(inst, FROZEN_V5).beta1)    # 50  → alignment EXPANDS β₁ here

# base and instruct occupy the SAME topological region (β₁ changes within it):
u = union_test(base, inst, FROZEN_V5, independent_eps=True)
print(u["verdict"])                      # SHARED
print(center_distance(base, inst))       # 0.62

Extract your own activations (needs actopo[extract])

from actopo import FROZEN_V5, measure
from actopo.models import load_model
from actopo.extract import extract_activations

model, tok = load_model("Qwen/Qwen2.5-0.5B", FROZEN_V5)
acts = extract_activations(model, tok, my_prompts, FROZEN_V5)   # correct last-token
print(measure(acts, FROZEN_V5).beta1)

Every result can be stamped + verified against the frozen protocol:

from actopo import save_result, verify, load_result, FROZEN_V5
save_result("out.json", {"beta1": 12}, FROZEN_V5)
assert verify(load_result("out.json"), FROZEN_V5) == []   # produced on-protocol

The frozen protocol (FROZEN_V5)

Parameter Value
β₁ threshold lifetime > 0.03 × ε_max
survival/PHI threshold lifetime > 0.01 × ε_max
layer L/2
token last (attention-mask based)
point cloud 1319 prompts
PH backend ripser, maxdim=1, euclidean

See actopo.protocol.ProtocolConfig for the full, documented field set.

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

actopo-0.1.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

actopo-0.1.0-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for actopo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fc8f487c4104fbb85d9fbe77881d7ed3cc2c2ef8410c2fd74e6261b30752824f
MD5 3840b8a054795a354c0b6fd9aab6c0aa
BLAKE2b-256 d930a5bc31ea1f9790e2e9af0550d8c8db718052761c4f6a012d14d256f5d797

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for actopo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b20abba249e7be8957e823d66651b33a115ed500fa0efc80981f2fba663c091d
MD5 ccdd9e4d5be5e6bd4902e453300b54e4
BLAKE2b-256 65d4a41b4f5f66fcf2c8d63c2d67d2a530dd70052adc82e5fd6fafa204776c75

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