Download tests/test_interventions.py from BurnyCoder/novel-tokens-reasoning-diffusion-llm: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/BurnyCoder/novel-tokens-reasoning-diffusion-llm/resolve/main/tests/test_interventions.py
- Command line
-
hf download hf://BurnyCoder/novel-tokens-reasoning-diffusion-llm/tests/test_interventions.py
-
curl -L -o test_interventions.py https://huggingface.co/BurnyCoder/novel-tokens-reasoning-diffusion-llm/resolve/main/tests/test_interventions.py
1.49 kB
| """Verify which questions and positions enter the mixed and delayed diagnostics.""" | |
| from novel_tokens.interventions import summarize | |
| def test_targeted_replacement_and_counterfactual_truth(): | |
| rows = [ | |
| {"answer":"A","gold":"A","trace_ids":[12,30],"correct":True, | |
| "outputs":{"novel_only":"B","hybrid":"D"},"expected_counterfactual":"D", | |
| "hybrid_key":"other","intervention_ids":{"novel_only":[12,31]}}, | |
| {"answer":"C","gold":"A","trace_ids":[12,13],"correct":False, | |
| "outputs":{"novel_only":"C","hybrid":"A"},"expected_counterfactual":"C", | |
| "hybrid_key":"other2","intervention_ids":{"novel_only":[12,13]}}, | |
| ] | |
| measured = summarize(rows, {30,31}) | |
| assert measured["targeted"]["exposed"] == measured["targeted"]["changed"] == 1 | |
| assert measured["targeted"]["gap"] == .5 | |
| assert measured["targeted"]["gap_given_change"] == 1. | |
| state = measured["state"] | |
| assert state["n"] == 2 and state["toward"] == state["away"] == 1 | |
| assert state["before"] == state["after"] == .5 | |
| def test_zero_advantage_does_not_require_a_whole_batch_to_have_the_same_reward(): | |
| from novel_tokens.signal_audit import informative_groups | |
| def row(prompt,answer): | |
| return {"prompt":prompt,"reader":prompt,"gold":"A","answer":answer} | |
| outputs=[row("first","A")]*4+[row("second","B")]*4 | |
| assert informative_groups(outputs,numeric=False)==0 | |
| outputs[-1]=row("second","A") | |
| assert informative_groups(outputs,numeric=False)==1 | |