Skip to content

Jupyter Integration

Energy Language provides IPython magics and interactive widgets for Jupyter notebooks.

Setup

bash
pip install qriton-hlm[jupyter]
python
%load_ext qriton_hlm.jupyter

Magics

%hlm_load — Load a checkpoint

python
surgeon = %hlm_load model.pt

This creates a surgeon variable in your notebook namespace.

%hlm — Run a single command

python
%hlm survey 0
%hlm inject 0 42 0.1
%hlm verify 0 42

%%hlm — Run multiple commands

python
%%hlm
capture 5 polite Thank you so much
capture 5 polite I really appreciate it
inject-concept 5 polite 0.1
apply 5

%hlm_survey — Survey with visualization

python
%hlm_survey 0

Renders an interactive Plotly chart showing basin energies and populations.

%hlm_landscape — Full landscape visualization

python
%hlm_landscape 0

Shows a 2D PCA projection of basin locations with energy coloring.

%hlm_concepts — Visualize concept space

python
%hlm_concepts

PCA projection of all captured concepts and their centroids.

Interactive Widget

python
from qriton_hlm.jupyter import basin_explorer

basin_explorer(surgeon, layer=0)

Provides layer/inits sliders with a survey button for interactive exploration.

Visualization Functions

Available for custom notebooks:

python
from qriton_hlm.jupyter import (
    plot_landscape,        # Basin energy + population bars
    plot_landscape_2d,     # PCA projection
    plot_surgery_diff,     # Before/after comparison
    plot_convergence,      # Energy over iterations
    plot_concept_space,    # Concept PCA visualization
)

Notebooks

Five progressive tutorials are included in the Jupyter/ directory:

NotebookTopic
01_quickstartSurvey, inject, verify — synthetic W
02_concept_surgeryCapture, inject, blend concepts
03_landscape_visualizationInteractive Plotly plots
04_model_comparisonCompare models, transplant concepts
05_hlm_scriptsIPython magics, .hlm scripts