| { |
| "task": { |
| "id": "case_4", |
| "name": "pair_balance", |
| "summary": "Return fraction of previous open tokens minus the fraction of close tokens.", |
| "examples": [ |
| { |
| "input": [ |
| "BOS", |
| "(", |
| "b", |
| ")", |
| "c", |
| "b", |
| "(", |
| "(", |
| "a", |
| "a" |
| ], |
| "output": [ |
| "BOS", |
| 1.0, |
| 0.5, |
| 0.0, |
| 0.0, |
| 0.0, |
| 0.16666666666666666, |
| 0.2857142857142857, |
| 0.25, |
| 0.2222222222222222 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| ")", |
| "b", |
| "b", |
| "a", |
| "b", |
| "b", |
| "(", |
| "a", |
| "c" |
| ], |
| "output": [ |
| "BOS", |
| -1.0, |
| -0.5, |
| -0.3333333333333333, |
| -0.25, |
| -0.2, |
| -0.16666666666666666, |
| 0.0, |
| 0.0, |
| 0.0 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "a", |
| "c", |
| "(", |
| ")", |
| "b", |
| "(", |
| "b", |
| ")", |
| ")" |
| ], |
| "output": [ |
| "BOS", |
| 0.0, |
| 0.0, |
| 0.3333333333333333, |
| 0.0, |
| 0.0, |
| 0.16666666666666666, |
| 0.14285714285714285, |
| 0.0, |
| -0.1111111111111111 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "c", |
| "b", |
| "a", |
| "c", |
| ")", |
| "b", |
| ")", |
| "b", |
| "c" |
| ], |
| "output": [ |
| "BOS", |
| 0.0, |
| 0.0, |
| 0.0, |
| 0.0, |
| -0.2, |
| -0.16666666666666666, |
| -0.2857142857142857, |
| -0.25, |
| -0.2222222222222222 |
| ] |
| }, |
| { |
| "input": [ |
| "BOS", |
| "b", |
| "c", |
| "a", |
| "c", |
| "c", |
| ")", |
| "a", |
| "a", |
| "a" |
| ], |
| "output": [ |
| "BOS", |
| 0.0, |
| 0.0, |
| 0.0, |
| 0.0, |
| 0.0, |
| -0.16666666666666666, |
| -0.14285714285714285, |
| -0.125, |
| -0.1111111111111111 |
| ] |
| } |
| ], |
| "is_categorical": false |
| }, |
| "program": "bools_open = rasp.numerical(sop == open_token).named(\"bools_open\"); opens = rasp.numerical(make_frac_prevs(bools_open)).named(\"opens\"); bools_close = rasp.numerical(sop == close_token).named(\"bools_close\"); closes = rasp.numerical(make_frac_prevs(bools_close)).named(\"closes\"); pair_balance = rasp.numerical(rasp.LinearSequenceMap(opens, closes, 1, -1)); return pair_balance.named(\"pair_balance\")", |
| "components": [ |
| { |
| "id": "L0_MLP", |
| "hook": "blocks.0.mlp.hook_post", |
| "role": { |
| "tag": "INDICATOR", |
| "note": "Computes per-token indicator features for open and close tokens." |
| }, |
| "rasp_vars": [ |
| "bools_open", |
| "bools_close" |
| ] |
| }, |
| { |
| "id": "L1H0_ATTN", |
| "hook": "blocks.1.attn.hook_result[0]", |
| "role": { |
| "tag": "AGGREGATOR", |
| "note": "Computes prefix aggregate for opens (fraction/count up to i) by attending over previous positions and reading the open-indicator via values." |
| }, |
| "rasp_vars": [ |
| "opens" |
| ] |
| }, |
| { |
| "id": "L1H1_ATTN", |
| "hook": "blocks.1.attn.hook_result[1]", |
| "role": { |
| "tag": "AGGREGATOR", |
| "note": "Computes prefix aggregate for closes (fraction/count up to i) by attending over previous positions and reading the close-indicator via values." |
| }, |
| "rasp_vars": [ |
| "closes" |
| ] |
| }, |
| { |
| "id": "L1_MLP", |
| "hook": "blocks.1.mlp.hook_post", |
| "role": { |
| "tag": "COMBINER", |
| "note": "Combines the open and close aggregates to compute the final balanced pair output." |
| }, |
| "rasp_vars": [ |
| "pair_balance" |
| ] |
| } |
| ] |
| } |
|
|