| { |
| "task": { |
| "id": "case_11", |
| "name": "word_count_by_length", |
| "summary": "Returns the length of each word in the input sequence.", |
| "examples": [ |
| { |
| "input": [ |
| "BOS", |
| "oCLrZaW", |
| "V", |
| "b", |
| "oCLrZaW", |
| "TPSI", |
| "poiVg", |
| "b", |
| "b", |
| "oCLrZaW" |
| ], |
| "output": [ |
| "BOS", |
| 7.0, |
| 1.0, |
| 1.0, |
| 7.0, |
| 4.0, |
| 5.0, |
| 1.0, |
| 1.0, |
| 7.0 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "LB", |
| "TPSI", |
| "oCLrZaW", |
| "TPSI", |
| "TPSI", |
| "poiVg", |
| "b", |
| "V", |
| "poiVg" |
| ], |
| "output": [ |
| "BOS", |
| 2.0, |
| 4.0, |
| 7.0, |
| 4.0, |
| 4.0, |
| 5.0, |
| 1.0, |
| 1.0, |
| 5.0 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "poiVg", |
| "TPSI", |
| "no", |
| "b", |
| "LB", |
| "poiVg", |
| "V", |
| "no", |
| "no" |
| ], |
| "output": [ |
| "BOS", |
| 5.0, |
| 4.0, |
| 2.0, |
| 1.0, |
| 2.0, |
| 5.0, |
| 1.0, |
| 2.0, |
| 2.0 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "V", |
| "J", |
| "J", |
| "TPSI", |
| "TPSI", |
| "oCLrZaW", |
| "LB", |
| "poiVg", |
| "V" |
| ], |
| "output": [ |
| "BOS", |
| 1.0, |
| 1.0, |
| 1.0, |
| 4.0, |
| 4.0, |
| 7.0, |
| 2.0, |
| 5.0, |
| 1.0 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "LB", |
| "poiVg", |
| "V", |
| "b", |
| "J", |
| "V", |
| "LB", |
| "no", |
| "b" |
| ], |
| "output": [ |
| "BOS", |
| 2.0, |
| 5.0, |
| 1.0, |
| 1.0, |
| 1.0, |
| 1.0, |
| 2.0, |
| 2.0, |
| 1.0 |
| ] |
| } |
| ], |
| "is_categorical": true |
| }, |
| "program": "word_length = rasp.Map(lambda x: len(x), sop)\nlength_selector = rasp.Select(word_length, word_length, rasp.Comparison.EQ)\nword_count = rasp.Aggregate(length_selector, word_length, default=None)\nreturn word_count", |
| "components": [ |
| { |
| "id": "L0_MLP", |
| "hook": "blocks.0.mlp.hook_post", |
| "role": { |
| "tag": "MAPPER", |
| "note": "Computes a per-token length feature that will be used to group tokens by equal length." |
| }, |
| "rasp_vars": [ |
| "word_length" |
| ], |
| "labels": [ |
| "map_3" |
| ] |
| }, |
| { |
| "id": "L1H0_ATTN", |
| "hook": "blocks.1.attn.hook_result[0]", |
| "role": { |
| "tag": "AGGREGATOR", |
| "note": "Groups positions by matching word length and aggregates to produce the per-length count-style output." |
| }, |
| "rasp_vars": [ |
| "length_selector", |
| "word_count" |
| ], |
| "labels": [ |
| "aggregate_1" |
| ] |
| } |
| ] |
| } |
|
|