Activations
Plotly visualization for recorded activations.
Projects a single component’s high-dimensional activations down to two dimensions and scatters them by class, so the linear structure a probe or a steering vector exploits becomes visible.
The dimensionality reducer is supplied by the caller rather than imported here, which keeps scikit-learn out of this module’s dependencies and leaves the choice of method (PCA, LDA, t-SNE, UMAP, …) open.
Requires the plot extra (install with pip install murano-interp[plot]).
Reducer
Section titled “Reducer”Any scikit-learn-style dimensionality reducer.
Supervised reducers such as LDA consume y; unsupervised ones such as PCA
accept and ignore it, so a single call site serves both.
fit_transform
Section titled “fit_transform”def fit_transform(self, X: Any, y: Any = None) -> Any:plot_activation_projection
Section titled “plot_activation_projection”def plot_activation_projection(store: ActivationStore | LabeledActivationStore, layer: AddressLike, reducer: Reducer, normalize: bool = True, label_names: list[str] | None = None, title: str = 'Activation projection') -> go.Figure:Scatter one component’s activations in a two-dimensional projection.
Accepts either activation store: a contrastive
:class:~murano.steps.record.ActivationStore is colored positive against
negative, while a :class:~murano.steps.record.LabeledActivationStore is
colored by its integer labels. That lets a single Record feed both this
plot and the :class:~murano.steps.probe.Probe step.
A reducer yielding one component is scattered along x with the classes separated vertically; two or more components use the first two.
Args:
store: Activation store recorded at a reduced token position.layer: Component address to project.reducer: Fitted-on-call reducer, e.g.PCA(n_components=2)orLinearDiscriminantAnalysis(n_components=1). Class labels are- passed to
fit_transformso supervised reducers work unchanged. normalize: Scale each activation vector to unit L2 norm before- reducing, so the projection reflects direction rather than
- magnitude. Zero vectors are left untouched.
label_names: Names for the integer labels of a labeled store, indexed- by label value. Ignored for a contrastive store.
title: Plot title.
Returns:
- A
plotly.graph_objects.Figurewith one scatter trace per class. - Classes are colored by label value (or positive-then-negative), not by
- the order they appear in the data, so the same class keeps its color
- across runs on reordered data.
Raises:
ValueError: Ifstorewas recorded withposition="none"orper_head=True, which carry extra dimensions this projection- cannot interpret, or if
label_namesdoes not cover every label - in the store.