Skip to main content

A library for training activation monitors on language model activations.

Project description

probelab

probelab trains probes and activation monitors on language model activations. It is collector-agnostic: use activations from Transformers, TransformerLens, NNsight, nnterp, vLLM-Lens, mirin, PyTorch hooks, or saved tensors.

Installation

pip install probelab
# or
uv add probelab

probelab does not choose a CUDA, ROCm, XPU, or CPU PyTorch build for you. Use your environment or lockfile to select the torch backend.

Quick Start

This example trains a probe on synthetic activations. Replace dataset with activations from any collector and the probing code stays the same.

import torch
import probelab as pl

n_train, n_test = 96, 32
seq_len, hidden_size = 24, 128
n = n_train + n_test

dataset = torch.randn(n, seq_len, hidden_size)
# shape: [(B)atch_size, (S)eq_len, (H)idden_size]
labels = torch.tensor([0, 1] * (n // 2))

train_acts = pl.Activations(dataset[:n_train], dims="bsh")
test_acts = pl.Activations(dataset[n_train:], dims="bsh")

# Simple probes train on one feature vector per sample.
train_features = train_acts.mean("s")  # [B, H]
test_features = test_acts.mean("s")  # [B, H]

probe = pl.probes.Logistic().fit(train_features, labels[:n_train])

scores = probe.predict(test_features)
print("AUROC:", pl.metrics.auroc(labels[n_train:], scores))
print("Recall@1%FPR:", pl.metrics.recall_at_fpr(labels[n_train:], scores, fpr=0.01))

Development

make test
make test-cov
make test-integration
make test-gpu
make test-e2e

Citation

@software{probelab2026,
  title = {probelab: A library for training probes on LLM activations},
  author = {Alex Serrano},
  url = {https://github.com/serteal/probelab},
  version = {0.1.0},
  year = {2026},
}

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

probelab-0.1.0.tar.gz (132.1 kB view details)

Uploaded Source

Built Distribution

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

probelab-0.1.0-py3-none-any.whl (130.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: probelab-0.1.0.tar.gz
  • Upload date:
  • Size: 132.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for probelab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef4fc0deeed2cd047d0fa28d2d788e4fd69d6fdb70e87e363b3c27ef8df8e04b
MD5 fcf841030d77ef6ed2a19fd09691d0c3
BLAKE2b-256 a919da67850c584a4f4f90a99662b678213d4038cef8637024e7f12c00784c54

See more details on using hashes here.

Provenance

The following attestation bundles were made for probelab-0.1.0.tar.gz:

Publisher: publish.yml on serteal/probelab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: probelab-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 130.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for probelab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 706a9086a9b0873b97ff20703aa21033e35979f86701b50d783bf5883e94e517
MD5 d26a6d4aa9288e7f66b76426ec146ff2
BLAKE2b-256 1de2e6cc6699198f5f17900686a9650fd4055450c72cf9a96ddb1b339f3777ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for probelab-0.1.0-py3-none-any.whl:

Publisher: publish.yml on serteal/probelab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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