Skip to main content

Terminal-native IDE for learned representations.

Project description

Spelunk

Spelunk is a terminal-native toolkit for inspecting learned representations. It captures PyTorch activations, stores them locally, computes layer and feature statistics, runs diagnostics, compares runs, and exports Markdown or JSON reports.

The current release target is a local-first pre-alpha for researchers who are comfortable using a Python model factory and CLI workflow.

Install

From PyPI:

python -m pip install spelunk-ml

From a checkout:

python -m pip install -e ".[dev,arrays,datasets,tui]"

Add PyTorch support when you want to capture activations:

python -m pip install -e ".[pytorch]"

Run checks:

python -m pytest
python -m ruff check .
python -m mypy

Quickstart

Generate the example dataset:

python examples/generate_samples.py

Discover valid layer selectors from a PyTorch model factory:

spelunk layers --model-path examples/model_factory.py --factory build_model

Run the lowest-friction workflow:

spelunk quickstart \
  --run runs/tiny-autoencoder.spelunk \
  --model-path examples/model_factory.py \
  --factory build_model \
  --dataset examples/samples.npy \
  --layers encoder

Or capture directly from flags:

spelunk capture \
  --run runs/tiny-autoencoder.spelunk \
  --model-path examples/model_factory.py \
  --factory build_model \
  --dataset examples/samples.npy \
  --layers encoder

For reproducible workflows, generate or edit a config:

spelunk init --model-path model_factory.py --dataset samples.npy --layers encoder
spelunk capture examples/capture.json

Scan the captured run:

spelunk scan runs/tiny-autoencoder.spelunk
spelunk scan runs/tiny-autoencoder.spelunk --json

Inspect one feature:

spelunk inspect runs/tiny-autoencoder.spelunk --layer encoder --feature 0
spelunk inspect runs/tiny-autoencoder.spelunk --layer encoder --feature 0 --json

Generate reports:

spelunk report runs/tiny-autoencoder.spelunk --format markdown
spelunk report runs/tiny-autoencoder.spelunk --format json

Compare two runs:

spelunk compare runs/baseline.spelunk runs/experiment.spelunk
spelunk compare runs/baseline.spelunk runs/experiment.spelunk --json

Open the TUI:

spelunk
spelunk open runs/tiny-autoencoder.spelunk

Capture Configs

Capture configs are JSON or TOML files. See:

  • examples/capture.json
  • examples/capture.toml
  • examples/model_factory.py
  • docs/CAPTURE_CONFIG.md
  • docs/EXAMPLE_SMOKE.md

The model factory must be callable with no arguments and return a torch.nn.Module. Layer names in the capture config are PyTorch named_modules() paths.

Python API

from spelunk import Session

session = Session.open("runs/tiny-autoencoder.spelunk")
scan = session.scan()
feature = session.inspect_feature(layer_id="encoder", feature_id="0")
report = session.report(format="markdown")

See docs/PYTHON_API.md.

What Works Today

  • layer discovery for PyTorch model factories
  • direct flag-based capture
  • one-shot quickstart capture, scan, and report generation
  • starter config generation
  • JSON and TOML capture configs
  • Spelunk-owned dataset loading for NumPy, CSV, JSONL, and image folders
  • PyTorch activation capture through selected forward hooks
  • NumPy shard and Zarr activation stores
  • layer statistics
  • feature statistics and top examples
  • activation health diagnostics
  • run comparison
  • Markdown and JSON reports
  • Textual TUI shell with run overview, layers, diagnostics, reports, and report generation

Current Limitations

  • capture requires a local PyTorch model factory
  • model loading does not handle checkpoint files directly yet
  • PyPI distribution name is spelunk-ml; the CLI and import name remain spelunk
  • diagnostics are intentionally limited to activation health for now

Documentation

  • docs/VISION.md
  • docs/ARCHITECTURE.md
  • docs/DOMAIN_MODEL.md
  • docs/PYTHON_API.md
  • docs/CAPTURE_ARCHITECTURE.md
  • docs/CAPTURE_CONFIG.md
  • docs/EXAMPLE_SMOKE.md
  • docs/STORAGE_FORMAT.md
  • docs/TUI_DESIGN.md
  • docs/TUI_COMPONENTS.md
  • docs/DESIGN_LANGUAGE.md
  • docs/CLI_SPEC.md
  • docs/TESTING_STRATEGY.md
  • docs/ROADMAP.md
  • docs/RELEASE.md
  • docs/CLEAN_INSTALL.md
  • docs/PYPI_RELEASE.md
  • docs/CONTRIBUTING.md
  • docs/DECISIONS.md

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

spelunk_ml-0.1.0a1.tar.gz (63.8 kB view details)

Uploaded Source

Built Distribution

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

spelunk_ml-0.1.0a1-py3-none-any.whl (53.6 kB view details)

Uploaded Python 3

File details

Details for the file spelunk_ml-0.1.0a1.tar.gz.

File metadata

  • Download URL: spelunk_ml-0.1.0a1.tar.gz
  • Upload date:
  • Size: 63.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for spelunk_ml-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 0f524f1fa6ff2878262c17e9b670be91280449b2930b51c77ec577dac3cb2155
MD5 1ae93cf19648f31f7fc034b81c40873e
BLAKE2b-256 66b9b099357d4ffed0402540a4963a6eff03437ce3ee0cb81f1beaa7edff80b7

See more details on using hashes here.

File details

Details for the file spelunk_ml-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: spelunk_ml-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 53.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for spelunk_ml-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 489666f9a08e54e2a9f72cc5b8349b5ac3768ba4895775e93f4234015e49f2ae
MD5 5982cbec24c4e3d50e6853920bcd541f
BLAKE2b-256 92262e878813a6fa49b227406cfd02bccf24fa75a6f26e498d656fc3467fa980

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