This file provides guidance for working with the frontend visualization dashboard.
The frontend is a Dash-based web application for interactive visualization of causal attribution graphs. It displays feature relationships, cluster analysis, and intervention results.
Main Application (app.py):
- Dash app initialization and layout setup
- Integrates all visualization components
Data Layer (data/):
loaders.py: Loads attribution graphs, clustering data, and intervention resultsmodels.py: Data models for graph nodes, edges, and metadata
Visualization Layer (visualization/):
graph/: Core graph rendering (nodes, edges, layout, renderer)components/: Reusable UI components (cluster manager, feature display, etc.)
Callbacks (callbacks/):
graph_callbacks.py: Interactive graph updates and filteringcluster_callbacks.py: Cluster analysis and intervention controlsannotation_callbacks.py: Feature annotation and explanation handling
-
Graph Loading:
data/loaders.pyloadsattribution_graph.ptfiles containing:sparse_pruned_adj: Pruned adjacency matrix from attribution analysis- Feature indices, token information, and intervention results
-
Node Processing: Active nodes determined by adjacency matrix row sums
-
Edge Processing: Edges filtered by weight thresholds and active nodes
-
Layout: Networkx-based graph layout with clustering support
-
Rendering: Plotly-based interactive visualization
Nodes with No Outgoing Edges:
- Attribution graph correctly prunes these nodes via
feature_mask - Frontend should use saved
feature_maskinstead of recalculating from adjacency - Check
data/loaders.pylines 104-105 for active mask calculation
Graph Filtering:
- Multiple threshold controls: feature influence, edge weights, clustering
- Ensure consistent filtering across all visualization components
Settings (config/settings.py):
- Graph layout parameters, color schemes, filtering thresholds
- Cluster analysis parameters and intervention settings
Launch frontend:
python src/circuit-tracing-visual-interface/frontend/launch.pyExpected data structure in attribution_graph.pt:
sparse_pruned_adj: Pruned adjacency matrixfeature_indices: Feature location indicesinput_tokens,token_string: Input text datatop_logit_*: Prediction information- Optional:
feature_maskfor proper node filtering