Skip to main content

Python SDK for the Gutenberg SAE Activation API

Project description

gutenberg-sdk

Python SDK for the Gutenberg SAE activation API — interpretability-based observability for language models. Upload text, read it through a sparse autoencoder (SAE) feature dictionary, and find the features that separate any two classes of documents.

Install

uv add gutenberg-sdk          # or: pip install gutenberg-sdk

The distribution is gutenberg-sdk; the import is gutenberg:

from gutenberg import Gutenberg

Optional pandas extra (for load_activations_df and parquet helpers):

uv add "gutenberg-sdk[pandas]"

Quickstart

from gutenberg import Gutenberg

client = Gutenberg(api_key="gtn_...")   # or set GUTENBERG_API_KEY

# 1. upload a parquet dataset (text + a binary target column)
dataset = client.datasets.upload("examples/simple_binary_features_extraction_100.parquet")

# 2. launch hosted SAE feature extraction
job = client.jobs.create(
    dataset_id=dataset.dataset_id,
    model_id="google/gemma-3-27b-it",
    sae_id="layer_31_width_262k_l0_medium",
)
job = client.jobs.wait(job.job_id)

# 3. score every feature against the target with AUROC
exp = client.experiments.create(
    job_id=job.job_id,
    target_column="is_ai",
    target_column_type="binary",
    positive_value="1",
    scoring_method="auroc",
)
exp = client.experiments.wait(exp.experiment_id)

# 4. read back ranked features and token-level examples
for feature in client.experiments.features(exp.experiment_id)[:10]:
    print(feature.rank, feature.feature_id, feature.score)

The full runnable script lives in examples/simple_binary_features_extraction.py, with a companion 100-row parquet. On production the whole flow runs in a couple of minutes. See docs/getting-started.md for the walkthrough, SAE selection guidance, and how token examples are served.

The bundled example is a curated showcase, not a benchmark — its 50 AI passages were picked to exhibit a handful of recognizable AI-writing features, so those features separate the two classes near-perfectly there. Run it on your own data to see a realistic ranking.

API surface

A single Gutenberg(...) client with namespaced resources: datasets, jobs, experiments, aggregations, autointerp, meta_autointerp, subsets, plus the sync helpers activations(), interpret(), models(), and saes().

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

gutenberg_sdk-0.1.1.tar.gz (584.1 kB view details)

Uploaded Source

Built Distribution

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

gutenberg_sdk-0.1.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file gutenberg_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: gutenberg_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 584.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gutenberg_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5515108277e1a3244fed3be5cc4589026808dd7b21c3ef98880a48e98bb8cae3
MD5 47a5a9d9fa30789b66b0e5bbecf427ec
BLAKE2b-256 afefc865d739957211c8f68547257b516590cf99083f808546a06f38017cf888

See more details on using hashes here.

File details

Details for the file gutenberg_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gutenberg_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gutenberg_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d113c3fb22646dad0cf99de34647bfde1f2b47647bb50c8207411b1c094437a
MD5 133162664473a1b1041689a8ca73f486
BLAKE2b-256 669420a4ce369b1d80eee1434310669d4b2cdc40b5335e3440ffd55614e9b503

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