aaron0eidt commited on
Commit
850edb3
Β·
1 Parent(s): ab1ff5b

Fix embedding tokens: soft blue instead of viridis black/green; make toggles, sidebar button, checkboxes more visible in light mode

Browse files
Files changed (2) hide show
  1. circuit_analysis/circuit_trace_page.py +45 -32
  2. web_app.py +29 -0
circuit_analysis/circuit_trace_page.py CHANGED
@@ -1840,41 +1840,54 @@ def create_interactive_attribution_graph(analysis, prompt_idx, enable_explanatio
1840
  traces = edge_traces
1841
  traces.extend(path_highlight_traces)
1842
 
1843
- colors = {'embedding': 'lightblue', 'feature': 'lightgreen', 'output': 'orange'}
1844
-
1845
  for node_type, data in node_traces.items():
1846
  if data['x']:
1847
- trace = go.Scatter(
1848
- x=data['x'], y=data['y'],
1849
- mode='markers+text',
1850
- hoverinfo='text',
1851
- hovertext=data['hovertext'],
1852
- text=data['text'],
1853
- textposition="middle center",
1854
- marker=dict(
1855
- size=data['size'],
1856
- color=data['color'],
1857
- colorscale='viridis',
1858
- showscale=True if node_type == 'feature' else False,
1859
- colorbar=dict(
1860
- title=tr('colorbar_title'),
1861
- x=0.97,
1862
- xanchor="left",
1863
- thickness=15,
1864
- len=0.7,
1865
- tickfont=dict(color=tc_graph['text']),
1866
- title_font=dict(color=tc_graph['text']),
1867
- ) if node_type == 'feature' else None,
1868
- line=dict(width=0.5, color=tc_graph['node_outline'])
1869
- ),
1870
- name=node_type.title()
1871
- )
1872
- # Manually translate the legend names.
1873
  if node_type == 'embedding':
1874
- trace.name = tr('embedding_legend')
1875
- elif node_type == 'feature':
1876
- trace.name = tr('feature_legend')
1877
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1878
  traces.append(trace)
1879
 
1880
  # Calculate the total width needed for the plot.
 
1840
  traces = edge_traces
1841
  traces.extend(path_highlight_traces)
1842
 
 
 
1843
  for node_type, data in node_traces.items():
1844
  if data['x']:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1845
  if node_type == 'embedding':
1846
+ # Embeddings: fixed soft blue, no colorscale
1847
+ trace = go.Scatter(
1848
+ x=data['x'], y=data['y'],
1849
+ mode='markers+text',
1850
+ hoverinfo='text',
1851
+ hovertext=data['hovertext'],
1852
+ text=data['text'],
1853
+ textposition="middle center",
1854
+ textfont=dict(color=tc_graph['text'], size=11),
1855
+ marker=dict(
1856
+ size=data['size'],
1857
+ color='#60a5fa',
1858
+ showscale=False,
1859
+ line=dict(width=0.5, color=tc_graph['node_outline'])
1860
+ ),
1861
+ name=tr('embedding_legend')
1862
+ )
1863
+ else:
1864
+ # Features: viridis colorscale with colorbar
1865
+ trace = go.Scatter(
1866
+ x=data['x'], y=data['y'],
1867
+ mode='markers+text',
1868
+ hoverinfo='text',
1869
+ hovertext=data['hovertext'],
1870
+ text=data['text'],
1871
+ textposition="middle center",
1872
+ textfont=dict(color=tc_graph['text']),
1873
+ marker=dict(
1874
+ size=data['size'],
1875
+ color=data['color'],
1876
+ colorscale='viridis',
1877
+ showscale=True,
1878
+ colorbar=dict(
1879
+ title=tr('colorbar_title'),
1880
+ x=0.97,
1881
+ xanchor="left",
1882
+ thickness=15,
1883
+ len=0.7,
1884
+ tickfont=dict(color=tc_graph['text']),
1885
+ title_font=dict(color=tc_graph['text']),
1886
+ ),
1887
+ line=dict(width=0.5, color=tc_graph['node_outline'])
1888
+ ),
1889
+ name=tr('feature_legend')
1890
+ )
1891
  traces.append(trace)
1892
 
1893
  # Calculate the total width needed for the plot.
web_app.py CHANGED
@@ -225,6 +225,35 @@ if _is_light:
225
  border-color: #c8cdd5 !important;
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  /* ── Option menu (sidebar nav) ────────────────────────────── */
229
  [data-testid="stSidebar"] iframe + div,
230
  [data-testid="stSidebar"] .nav {
 
225
  border-color: #c8cdd5 !important;
226
  }
227
 
228
+ /* ── Toggle switches ──────────────────────────────────────── */
229
+ [data-testid="stToggle"] label,
230
+ [data-testid="stToggle"] span {
231
+ color: #1b1b2f !important;
232
+ }
233
+ [data-testid="stToggle"] [role="checkbox"] {
234
+ border: 2px solid #2f3f70 !important;
235
+ }
236
+
237
+ /* ── Sidebar collapse button ──────────────────────────────── */
238
+ [data-testid="stSidebar"] button[kind="header"],
239
+ [data-testid="collapsedControl"] button,
240
+ button[data-testid="stBaseButton-headerNoPadding"] {
241
+ color: #1b1b2f !important;
242
+ background-color: #e8ecf6 !important;
243
+ border: 1px solid #c8cdd5 !important;
244
+ border-radius: 8px !important;
245
+ }
246
+
247
+ /* ── Slider thumb & track ─────────────────────────────────── */
248
+ [data-testid="stSlider"] label {
249
+ color: #1b1b2f !important;
250
+ }
251
+
252
+ /* ── Checkbox ─────────────────────────────────────────────── */
253
+ .stCheckbox label span {
254
+ color: #1b1b2f !important;
255
+ }
256
+
257
  /* ── Option menu (sidebar nav) ────────────────────────────── */
258
  [data-testid="stSidebar"] iframe + div,
259
  [data-testid="stSidebar"] .nav {