Skip to main content

A versatile kit for training and using linear probes on neural network activations.

Project description

Probes

A lightweight, modular library for training linear probes and steering vectors on neural network activations.

Core Design (V2)

This library separates Semantics (the probe model) from Fitting (how it's learned).

1. The Models: LinearProbe and ProbeCollection

  • LinearProbe (probekit.core.probe): A container for a single probe (+ normalization stats).
  • ProbeCollection (probekit.core.collection): A container for a batch of probes.
    • to_tensor(): Stacks weights into [B, D] and biases into [B].
    • best_layer(metric): Finds the probe with the best validation accuracy.

2. The Fitters

Functional solvers in probekit.fitters take training data and return a LinearProbe (or ProbeCollection).

  • fit_logistic: Standard L2-regularized Logistic Regression.
  • fit_elastic_net: ElasticNet (L1 + L2), useful for sparse features (SAEs, Neurons).
  • fit_dim: Difference-in-Means (Class 1 Mean - Class 0 Mean).

Batched GPU Fitters

Optimized PyTorch implementations in probekit.fitters.batch handle 3D inputs [B, N, D] efficiently on GPU:

  • fit_logistic_batch: Batched IRLS solver.
  • fit_dim_batch: Vectorized DiM with median thresholding.
  • fit_elastic_net_path: Efficiently fits a regularization path (multiple alphas) using warm-starting.

Quick Start

The high-level API automatically routes based on the input dimensions:

from probekit import sae_probe, dim_probe

# 1. Single Probe (X: [N, D], y: [N])
probe = sae_probe(X_2d, y_1d)

# 2. Batched Probes (X: [B, N, D], y: [B, N] or [N])
# Automatically uses GPU fitters and returns a ProbeCollection
probes = sae_probe(X_3d, y)
weights, biases = probes.to_tensor() # [B, D], [B]

Steering Vectors

You can build steering vectors for individual probes or entire collections:

from probekit import build_steering_vector, build_steering_vectors

# Single
vec = build_steering_vector(probe, sae_model, layer=10)

# Batched (Maps layers to probes)
vecs = build_steering_vectors(probe_collection, sae_model, layers=[8, 9, 10])

Structure

  • probekit/core/: LinearProbe and ProbeCollection definitions.
  • probekit/fitters/:
    • logistic.py, elastic.py, dim.py: Single-probe (CPU/sklearn) fitters.
    • batch/: Optimized GPU-batched fitters (IRLS, ISTA, DiM).
  • probekit/api.py: High-level aliases and dimension routing.
  • probekit/steering/: Tools for building steering vectors.

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

probekit-0.2.1.dev0.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

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

probekit-0.2.1.dev0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file probekit-0.2.1.dev0.tar.gz.

File metadata

  • Download URL: probekit-0.2.1.dev0.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for probekit-0.2.1.dev0.tar.gz
Algorithm Hash digest
SHA256 cb9401ab75b035596b4d5ada36e7cabda1d0923c8c675559dadb56ce5a4eceb0
MD5 872e749ffb3977bbad7c82edb2194910
BLAKE2b-256 de528f25ba71189edcb80ba7ab2d704143f379b34cd6ee2bd0ce693ad54bb96b

See more details on using hashes here.

Provenance

The following attestation bundles were made for probekit-0.2.1.dev0.tar.gz:

Publisher: publish.yml on ZuiderveldTimJ/probekit

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

File details

Details for the file probekit-0.2.1.dev0-py3-none-any.whl.

File metadata

  • Download URL: probekit-0.2.1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for probekit-0.2.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 08aa2c6fd2967897295c2ef40062136663f777d123d2160ddd663e025607d8a8
MD5 3c02a66661b5248d1d7965abf482bece
BLAKE2b-256 324d639e65347dde8300e3cd3f06739864d2169cf8a2f852f8a14af15f6d5cf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for probekit-0.2.1.dev0-py3-none-any.whl:

Publisher: publish.yml on ZuiderveldTimJ/probekit

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