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.0.tar.gz (654.4 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.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gutenberg_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 654.4 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.0.tar.gz
Algorithm Hash digest
SHA256 04cc809153df5bcf44daa561bd8a533848c7f064c35831fccfeeea4a803b4958
MD5 f93d5e419d6f8140df0f6211ed15bf46
BLAKE2b-256 d527f46d494351f32d1782fb35dd89bf271c153127a11c85a091787646ca87af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gutenberg_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f96a2ef665c5ca7a97e432d1af551acd6f0aa75806edc003426f9a5f126150d2
MD5 1d878507536ec5b242346c5889d5d55a
BLAKE2b-256 107b1e8cf5670e097740a70214ab7b940ccbdf968c3a2a5f7cb00d7f892281b2

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