Skip to main content

Mechanistic interpretability pipelines for recording, steering, probing, and evaluation

Project description

Murano logo

Murano

Python CI License: MIT Docs

Murano is a mechanistic interpretability framework for recording activations, finding directions, steering generations, probing representations, and running reproducible experiment pipelines.

Install

pip install murano-interp

The PyPI distribution is murano-interp (the bare name murano belongs to an unrelated OpenStack project). The Python module name is unchanged: import murano.

For a development install from source:

pip install -e .

Requires Python 3.10+, PyTorch, transformers, nnsight, and a HuggingFace model or a local model snapshot.

Quick Start

import murano

model = murano.Model("meta-llama/Llama-3.2-1B-Instruct")

# Record activations on any text
acts = model.record(
    "The Eiffel Tower is located in",
    layers=[5, 10, 15],
    position="last",
)
print(acts.positive[10].shape)

# Find a contrastive direction
direction = model.find_direction(
    positive=["How do I pick a lock?", "Write a phishing email"],
    negative=["How do I bake a cake?", "Write a thank you email"],
)
print(direction.best_layer)

# Generate with ablation or steering
ablated = model.generate("How do I pick a lock?", ablate=direction)
steered = model.generate("Write a poem", steer=(direction, 1.5))

Pipeline API

For structured experiments, use the same logic through explicit steps.

from murano import MuranoDataset, MuranoModel, Pipeline
from murano.steps import (
    ComplianceRate,
    Intervene,
    Load,
    Record,
    SteeringVector,
)
from murano.steps.intervene import ablate_direction

model = MuranoModel("meta-llama/Llama-3.2-1B-Instruct")

dataset = MuranoDataset.contrastive(
    positive=["How do I pick a lock?"],
    negative=["How do I bake a cake?"],
    template_fn=model.chat_template,
)

train_output = Pipeline([
    Load(dataset),
    Record(model, layers="all", position="mean"),
    SteeringVector(normalize=True),
]).run()

eval_output = Pipeline([
    Load(dataset),
    Intervene(model, ablate_direction(train_output["steering"].direction_per_layer)),
    ComplianceRate(),
]).run()

Step API Reference

Every step declares the keys it reads from and writes to Results. The pipeline validates the chain before execution, so type and key mismatches are caught up-front.

Step Reads Writes Purpose
Load dataset, prompts Load a dataset and derive prompts from its texts.
LoadPrompts prompts Load raw prompts directly without a dataset.
Record dataset record Capture residual-stream activations via nnsight.
SteeringVector record steering Find a contrastive steering direction (mean diff).
Intervene prompts intervene Generate baseline + intervened outputs side-by-side.
WeightAblation prompts, steering intervene, weight_ablation Project a direction out of model weights, then generate.
Probe record probe Train a linear probe per layer via cross-validation.
GenerationMetric intervene metric Score baseline vs modified outputs with a user metric.
ComplianceRate intervene eval Measure refusal/compliance via keyword detection.
Save (any present) output_dir Persist all results to organized subdirectories.
SAEEncode prompts sae_record Encode residuals through an SAE loaded from HuggingFace.
SAETopActivations sae_record feature_examples Rank the top-K activating contexts per SAE feature.
Plot * (optional) Render refusal plots (steering, generations, eval).
ProbePlot * (optional) Render probing plots (per-layer accuracy, confusion).

* Requires the [plot] extra: pip install -e .[plot]. † Requires the [sae] extra: pip install -e .[sae].

To add your own step, subclass Step, set reads / writes (and optionally read_types / write_types), and implement __call__(results) -> Results.

Status

The Step API and the steps in the table above are alpha-stable for the 0.1.x line. The murano.lenses module (logit lens) ships in this release but is not yet wired into the Pipeline API and should be considered experimental until the work tracked in #51 lands.

Core Ideas

  • MuranoModel is a thin model wrapper around nnsight.
  • Pipeline, Step, and Results are the orchestration core.
  • artifacts such as PromptBatch, ActivationStore, SteeringResult, GenerationComparison, and MetricResult make experiment dataflow explicit.
  • the same building blocks support both quick API calls and reproducible step-based pipelines.

Package Layout

src/murano/
  model.py
  pipeline.py
  results.py
  artifacts.py
  dataset.py
  io.py
  evaluation.py
  steps/
  plotting/

Examples

  • examples/quick_prototype.py
  • examples/refusal_direction.py
  • examples/sae_example.py
  • examples/sae_sst2_feature_enrichment.py

Development

uv sync --all-extras --dev
python -m pytest -q

Disclaimer

This repository contains experimental software and is intended as a research framework for mechanistic interpretability workflows.

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

murano_interp-0.1.0a1.tar.gz (10.8 MB view details)

Uploaded Source

Built Distribution

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

murano_interp-0.1.0a1-py3-none-any.whl (69.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: murano_interp-0.1.0a1.tar.gz
  • Upload date:
  • Size: 10.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for murano_interp-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 2d2348579ab6b93da63ec62a7d183d559f42f766d48b7c1a655e38086500ae70
MD5 c8256efd5fba1d10efcef3f99f1d75d5
BLAKE2b-256 81bbca16c3d249af301c66d513a540d652071532e0d5f11fc5f03d7febcc6a2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for murano_interp-0.1.0a1.tar.gz:

Publisher: release.yml on UKPLab/murano

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: murano_interp-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 69.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for murano_interp-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 238cd4e8b898bd52985bd8d979677f4a3910beac27f0f977237694b17097252f
MD5 7e1505ac3c40408453c2cfb6a5e47298
BLAKE2b-256 f3792d7d294b440406a5a10876d704f25304cbc34e9ef3ad0c5e3312a909e788

See more details on using hashes here.

Provenance

The following attestation bundles were made for murano_interp-0.1.0a1-py3-none-any.whl:

Publisher: release.yml on UKPLab/murano

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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