File size: 4,170 Bytes
3d3ae36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
{
  "task": {
    "id": "case_18",
    "name": "token_frequency_classifier",
    "summary": "Classify each token based on its frequency as 'rare', 'common', or 'frequent'.",
    "examples": [
      {
        "input": [
          "BOS",
          "a",
          "d",
          "b",
          "e",
          "d",
          "a",
          "a",
          "c",
          "c"
        ],
        "output": [
          "BOS",
          "common",
          "rare",
          "rare",
          "rare",
          "rare",
          "common",
          "common",
          "rare",
          "rare"
        ]
      },
      {
        "input": [
          "BOS",
          "b",
          "d",
          "d",
          "c",
          "d",
          "d",
          "a",
          "c",
          "e"
        ],
        "output": [
          "BOS",
          "rare",
          "common",
          "common",
          "rare",
          "common",
          "common",
          "rare",
          "rare",
          "rare"
        ]
      },
      {
        "input": [
          "BOS",
          "c",
          "e",
          "a",
          "b",
          "d",
          "a",
          "d",
          "b",
          "b"
        ],
        "output": [
          "BOS",
          "rare",
          "rare",
          "rare",
          "common",
          "rare",
          "rare",
          "rare",
          "common",
          "common"
        ]
      },
      {
        "input": [
          "BOS",
          "e",
          "d",
          "c",
          "e",
          "b",
          "d",
          "b",
          "d",
          "e"
        ],
        "output": [
          "BOS",
          "common",
          "common",
          "rare",
          "common",
          "rare",
          "common",
          "rare",
          "common",
          "common"
        ]
      },
      {
        "input": [
          "BOS",
          "d",
          "e",
          "c",
          "e",
          "e",
          "b",
          "c",
          "c",
          "c"
        ],
        "output": [
          "BOS",
          "rare",
          "common",
          "common",
          "common",
          "common",
          "rare",
          "common",
          "common",
          "common"
        ]
      }
    ],
    "is_categorical": true
  },
  "program": "frequency = make_hist()\ntotal_tokens = make_length()\nfrequency_classification = rasp.SequenceMap(\n  lambda freq, total: \"frequent\" if freq > total/2 else (\"common\" if freq > total/4 else \"rare\"),\n  frequency, total_tokens)\nreturn frequency_classification",
  "components": [
    {
      "id": "L0H0_ATTN",
      "hook": "blocks.0.attn.hook_result[0]",
      "role": {
        "tag": "AGGREGATOR",
        "note": "Builds the token-equality matching structure used to count how often each token appears."
      },
      "rasp_vars": [
        "same_tok"
      ],
      "labels": [
        "hist_2_selector_width_attn_output"
      ]
    },
    {
      "id": "L0H1_ATTN",
      "hook": "blocks.0.attn.hook_result[1]",
      "role": {
        "tag": "AGGREGATOR",
        "note": "Builds the all-positions selector used as the basis for computing sequence length."
      },
      "rasp_vars": [
        "all_true_selector"
      ],
      "labels": [
        "length_3_selector_width_attn_output"
      ]
    },
    {
      "id": "L0_MLP",
      "hook": "blocks.0.mlp.hook_post",
      "role": {
        "tag": "MAPPER",
        "note": "Turns the selector-width signals into usable numeric features for per-token frequency and total length."
      },
      "rasp_vars": [
        "frequency",
        "total_tokens"
      ],
      "labels": [
        "hist_2",
        "length_3",
        "hist_2_selector_width_attn_output",
        "length_3_selector_width_attn_output"
      ]
    },
    {
      "id": "L1_MLP",
      "hook": "blocks.1.mlp.hook_post",
      "role": {
        "tag": "COMBINER",
        "note": "Combines per-token frequency with total length to assign the label rare/common/frequent."
      },
      "rasp_vars": [
        "frequency_classification"
      ],
      "labels": [
        "sequence_map_1"
      ]
    }
  ]
}