Skip to main content

ASTScribe

Evidence-backed scientific explanations for ML notebooks, without LLMs.

PyPI Python CI Downloads License

ASTScribe statically analyzes Python and Jupyter notebooks and turns supported ML operations into deterministic, traceable explanations.

No LLMs. No API keys. No code execution. No telemetry.

Install

python -m pip install astscribe

Optional IPython/Jupyter integration:

python -m pip install "astscribe[ipython]"

Quick start

ASTScribe analyzes source code without executing it:

from astscribe import explain

source = """
import torch

model.eval()
with torch.no_grad():
    outputs = model(inputs)
"""

print(explain(source, style="scientific"))

Output:

Inference procedure

Gradient tracking is disabled for the enclosed operations, so no autograd graph is constructed for computations executed within this context.

The model is explicitly configured in evaluation mode.

A forward pass is performed by invoking the model on the supplied inputs.

For notebook-level structure:

from astscribe import NotebookAnalyzer

notebook = NotebookAnalyzer.from_cells(
    [
        "dataset = load_data()",
        "features = preprocess(dataset)",
        "result = evaluate(features)",
    ]
)

print(notebook.render_dependency_graph())

Output:

# Cell dependency graph

Cell 0 -> Cell 1 [dataset]
Cell 1 -> Cell 2 [features]

ASTScribe only reports claims supported by the source it can inspect.

CLI

astscribe training.py --style concise
astscribe experiment.ipynb --report methodology --evidence
astscribe experiment.ipynb --report diagnostics
astscribe experiment.ipynb --report impact --cell 3
astscribe experiment.ipynb --report ranking
astscribe experiment.ipynb --report dependencies --dot

# Structured output for scripts, CI, and jq
astscribe training.py --json
astscribe experiment.ipynb --report diagnostics --json
astscribe experiment.ipynb --report impact --cell 3 --json

# Read Python source from stdin
printf 'model.eval()\n' | astscribe - --style concise

# Fail if a notebook contains a code cell that is not valid Python
astscribe experiment.ipynb --report diagnostics --strict

# Return exit status 1 when dependency diagnostics contain warnings
astscribe experiment.ipynb --report diagnostics --fail-on-warning

The same CLI is available as python -m astscribe. Use --json with Python source or any notebook report to emit the underlying structured analysis instead of rendered text. JSON output is deterministic and uses only the Python standard library. For CI validation, --fail-on-warning preserves the selected notebook output while returning status 1 when dependency diagnostics contain warnings.

Supported semantics

ASTScribe has first-class static semantics for PyTorch, Hugging Face Transformers, Hugging Face Datasets, and PEFT. It can reconstruct notebook methodology, experiment pipelines, cross-cell dependencies, diagnostics, impact, and conservative composite techniques such as QLoRA.

Generated claims retain source provenance and an evidence level. The scientific renderer uses directly observed, statically resolved, and known-framework claims by default.

Detailed contracts and limitations live in docs.

Development

python -m pip install -e ".[dev]"
pytest
ruff check .
mypy src/astscribe

See CONTRIBUTING.md and docs/releasing.md.

License

Apache License 2.0. See LICENSE.

Metadata

Release files for astscribe 0.8.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astscribe 0.8.8
File Size Uploaded
astscribe-0.8.8.tar.gz 76.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for astscribe 0.8.8
File Interpreter ABI Platform
astscribe-0.8.8-py3-none-any.whl Python 3 none any Details

Total release size: 136.8 kB

Release files / astscribe-0.8.8.tar.gz

Download URL astscribe-0.8.8.tar.gz
Size 76.5 kB
Tags Source
SHA-256 checksum
How to use checksums
54a4be620f8acc002d2d69cb3d305d1264796839ee1433f2a712f348ee2b0d71
BLAKE2b-256 checksum
How to use checksums
420a1422f5e0f9de9594a9bfd93e1e46b5debbf70c7f59fc53636b8d4433eef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / astscribe-0.8.8-py3-none-any.whl

Download URL astscribe-0.8.8-py3-none-any.whl
Size 60.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8eafada69290d8712747279f07ffbfc389a54c6b7da4366daa82221aa60f3832
BLAKE2b-256 checksum
How to use checksums
d1d172b29af4f52ce2bb02d166b4336e993deb2fb3f5158f987df7c09b788c8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.1

2 release files

0.9.0

2 release files

This release

0.8.8 This release

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page