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.jsonexamples/capture.tomlexamples/model_factory.pydocs/CAPTURE_CONFIG.mddocs/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 remainspelunk - diagnostics are intentionally limited to activation health for now
Documentation
docs/VISION.mddocs/ARCHITECTURE.mddocs/DOMAIN_MODEL.mddocs/PYTHON_API.mddocs/CAPTURE_ARCHITECTURE.mddocs/CAPTURE_CONFIG.mddocs/EXAMPLE_SMOKE.mddocs/STORAGE_FORMAT.mddocs/TUI_DESIGN.mddocs/TUI_COMPONENTS.mddocs/DESIGN_LANGUAGE.mddocs/CLI_SPEC.mddocs/TESTING_STRATEGY.mddocs/ROADMAP.mddocs/RELEASE.mddocs/CLEAN_INSTALL.mddocs/PYPI_RELEASE.mddocs/CONTRIBUTING.mddocs/DECISIONS.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f524f1fa6ff2878262c17e9b670be91280449b2930b51c77ec577dac3cb2155
|
|
| MD5 |
1ae93cf19648f31f7fc034b81c40873e
|
|
| BLAKE2b-256 |
66b9b099357d4ffed0402540a4963a6eff03437ce3ee0cb81f1beaa7edff80b7
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
489666f9a08e54e2a9f72cc5b8349b5ac3768ba4895775e93f4234015e49f2ae
|
|
| MD5 |
5982cbec24c4e3d50e6853920bcd541f
|
|
| BLAKE2b-256 |
92262e878813a6fa49b227406cfd02bccf24fa75a6f26e498d656fc3467fa980
|