| { |
| "task": { |
| "id": "case_14", |
| "name": "count_a", |
| "summary": "Returns the count of 'a' in the input sequence.", |
| "examples": [ |
| { |
| "input": [ |
| "BOS", |
| "b", |
| "b", |
| "a", |
| "a", |
| "b", |
| "b", |
| "a", |
| "a", |
| "a" |
| ], |
| "output": [ |
| "BOS", |
| 5, |
| 5, |
| 5, |
| 5, |
| 5, |
| 5, |
| 5, |
| 5, |
| 5 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "c", |
| "c", |
| "a", |
| "c", |
| "a", |
| "c", |
| "c", |
| "a", |
| "a" |
| ], |
| "output": [ |
| "BOS", |
| 4, |
| 4, |
| 4, |
| 4, |
| 4, |
| 4, |
| 4, |
| 4, |
| 4 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "c", |
| "a", |
| "c", |
| "c", |
| "a", |
| "a", |
| "c", |
| "b", |
| "c" |
| ], |
| "output": [ |
| "BOS", |
| 3, |
| 3, |
| 3, |
| 3, |
| 3, |
| 3, |
| 3, |
| 3, |
| 3 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "c", |
| "c", |
| "c", |
| "b", |
| "c", |
| "b", |
| "b", |
| "c", |
| "b" |
| ], |
| "output": [ |
| "BOS", |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "c", |
| "c", |
| "c", |
| "a", |
| "c", |
| "b", |
| "a", |
| "b", |
| "b" |
| ], |
| "output": [ |
| "BOS", |
| 2, |
| 2, |
| 2, |
| 2, |
| 2, |
| 2, |
| 2, |
| 2, |
| 2 |
| ] |
| } |
| ], |
| "is_categorical": true |
| }, |
| "program": "count_a_selector = rasp.Select(sop, sop, lambda k, q: k == token).named(\"count_a_selector\")\ncount_a = rasp.SelectorWidth(count_a_selector).named(\"count_a\")\nreturn count_a", |
| "components": [ |
| { |
| "id": "L0H0_ATTN", |
| "hook": "blocks.0.attn.hook_result[0]", |
| "role": { |
| "tag": "AGGREGATOR", |
| "note": "Aggregates positions containing the target token 'a' into a per-position match count." |
| }, |
| "rasp_vars": [ |
| "count_a_selector" |
| ], |
| "labels": [ |
| "count_a_1_selector_width_attn_output" |
| ] |
| }, |
| { |
| "id": "L0_MLP", |
| "hook": "blocks.0.mlp.hook_post", |
| "role": { |
| "tag": "MAPPER", |
| "note": "Turns the match pattern into a per-position total count of 'a' in the sequence." |
| }, |
| "rasp_vars": [ |
| "count_a" |
| ], |
| "labels": [ |
| "count_a_1" |
| ] |
| } |
| ] |
| } |
|
|