PageSourceSearch

https://embed-goodfire-attr-graph.netlify.app/feature_examples/init-feature-examples.js

js embed-goodfire-attr-graph.netlify.app collected 2026-10-03 10:41:41 UTC 1,781 bytes, 60 lines download raw bytes

1window.initFeatureExamples = function({containerSel, showLogits=true, showExamples=true, hideStaleOutputs=false}){
2  var visState = {
3    isDev: 0,
4    showLogits,
5    showExamples,
6    hideStaleOutputs,
7
8    activeToken: null,
9    feature: null,
10    featureIndex: -1,
11
12    chartRowTop: 16,
13    chartRowHeight: 82,
14  }
15
16  // set up dom and render fns
17  var sel = containerSel.html('').append('div.feature-examples')
18  if (visState.showLogits) sel.append('div.feature-example-logits')
19  if (visState.showExamples) sel.append('div.feature-example-list')
20  var renderAll = util.initRenderAll(['feature'])
21
22  
23  if (visState.showLogits) window.initFeatureExamplesLogits({renderAll, visState, sel})
24  if (visState.showExamples) window.initFeatureExamplesList({renderAll, visState, sel})
25
26  return {loadFeature, renderFeature}
27
28  async function renderFeature(scan, featureIndex){
29    if (visState.hideStaleOutputs) sel.classed('is-stale-output', 1)
30
31    // load feature data and exit early if featureIndex has changed
32    visState.featureIndex = featureIndex
33    var feature = await loadFeature(scan, featureIndex)
34    if (feature.featureIndex == visState.featureIndex){
35      visState.feature = feature
36      renderAll.feature()
37      if (visState.hideStaleOutputs) sel.classed('is-stale-output', 0)
38    }
39
40    return feature
41  }
42
43  async function loadFeature(scan, featureIndex){
44    try {
45      var feature = await  util.getFile(`https://clt-frontend.goodfire.pub/features/${scan}/${featureIndex}.json`)
46    } catch {
47      var feature = {isDead: true, statistics: {}}
48    }
49
50    feature.colorScale = d3.scaleSequential(d3.interpolateOranges)
51      .domain([0, 1.4]).clamp(1)
52
53    feature.featureIndex = featureIndex
54    feature.scan = scan
55
56    return feature
57  }
58}
59
60window.init?.()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.