Download research_source/worktree/src/make_report_contract.py from AlephFunk/alg-hodge-27b-01: direct link, hf CLI and curl.
- Browser
- Download file 10.2 kB
-
https://huggingface.co/datasets/AlephFunk/alg-hodge-27b-01/resolve/main/research_source/worktree/src/make_report_contract.py
- Command line
-
hf download hf://datasets/AlephFunk/alg-hodge-27b-01/research_source/worktree/src/make_report_contract.py
-
curl -L -o make_report_contract.py https://huggingface.co/datasets/AlephFunk/alg-hodge-27b-01/resolve/main/research_source/worktree/src/make_report_contract.py
10.2 kB
| """Build stable evidence contracts from reviewed, plot-ready result values.""" | |
| import json,pathlib | |
| root=pathlib.Path(__file__).resolve().parents[1] | |
| repo=pathlib.Path(__file__).resolve().parents[3]/'Compactification-Theory/research/algernon/belief_geometry/experiments/ALG_HODGE_27B_01' | |
| p=json.loads((root/'results/plot_ready.json').read_text()) | |
| ex=json.loads((root/'results/examples_small.json').read_text()) | |
| source=p['sources'];base=f'artifact://moralitylab/experiments/exp_01m6k3brj2fhx8y4b9hgd57pxc/alg_hodge_27b_01/' | |
| artifacts={'frozen_cases':base+'repaired_v2/frozen_cases.jsonl', | |
| 'dataset_manifest':base+'repaired_v2/dataset_manifest.json','activation_manifest':base+'repaired_v2/activation_manifest.json', | |
| 'goodfire_stores':base+'repaired_v2/activations/action/','shards':base+'repaired_v2/shards/', | |
| 'selected_weights':base+'repaired_v2/selected_weights.npz','selected_readout':base+'repaired_v2/selection_freeze.json', | |
| 'probe_metrics':source['probe'],'hodge_metrics':source['hodge'],'intervention_metrics':source['intervention'], | |
| 'intervention_rows':base+'repaired_v2/intervention_rows.json','paired_contrasts':base+'review_v2/paired_contrasts.json', | |
| 'integrity':base+'review/integrity.json','examples_full':ex['source'], | |
| 'local_hodge':source['local_hodge'],'batch_parity':base+'batch_parity_diagnostic.json', | |
| 'matched_batch':base+'matched_batch_diagnostic.json','runtime':base+'repaired_v2/runtime_end.json'} | |
| summary={ | |
| 'question':'Does Qwen3.5-27B linearly encode exact Bayesian posteriors and additive evidence updates across unseen likelihood families, preserve evidence-order consistency, relate errors to stopping, and improve decisions when its frozen residual direction is edited?', | |
| 'headline':'Bayesian quantities are partly decodable in Qwen3.5-27B, but its decoded evidence updates are order-sensitive and the frozen edit has no detected decision or utility benefit.', | |
| 'assessment':{'measurement':'partial_signal for linear decoding; no support for order-consistent update representation or advantageous causal direction under this protocol', | |
| 'interpretation':'A probe can extract some task information; exact public arithmetic is better, cube defects are nonzero, and direction effects do not separate matched controls.'}, | |
| 'decision_rule':'Compare training-only linear/ridge readouts selected by calibration MAE with constant, shuffled and public-state controls on 128 untouched families. For the causal question, freeze the edit layer/scale on calibration and compare recipient-paired direction changes against sham, random, shuffled, norm-matched and swaps with family-clustered intervals. Report a failure or null without changing a scoring threshold. The mathematical cube bound alone is not evidence of model competence.', | |
| 'methods':{'model':'Qwen/Qwen3.5-27B','revision':'fc05daec18b0a78c049392ed2e771dde82bdf654','precision':'BF16','GPU':'one 80 GB H100', | |
| 'source_repo':'MoralityLabAI/Compactification-Theory','source_main_commit':'fab953c987b3b39a2a3780400adb608daaaa3a7d', | |
| 'data':'512 finite Bayesian three-test families, 79 ordered contexts per family, family-disjoint 256 train/128 calibration/128 evaluation', | |
| 'evaluation':'128 families, 10,112 contexts, 1,024 filled assignment cubes, 128 opposite-decision pairs / 256 recipients drawn from 114 families', | |
| 'hooks':'post language-model blocks 7,16,27,40,51,60; action final token, belief final token, last evidence token', | |
| 'batch':'up to eight prompts per frozen shard group; intervention replay with original batch neighbors and recipient-only hook edit', | |
| 'causal_layer':'block 40 G direction fit on training families, alpha=1000 selected within that layer on calibration; calibration edit scale 0.5 train projection SD', | |
| 'inference':'single-token restricted 0/1 scores, no unconstrained numeric posterior generation', | |
| 'uncertainty':'family-clustered bootstrap; 128 families for probe/Hodge, 114 families represented among 256 intervention recipients', | |
| 'utility':'first choice only changed; expected and intervention realized rewards assume exact host continuation and terminal hypothesis; natural realized uses a model hypothesis choice plus exact host test choice on one common world/family'}, | |
| 'results':{'evaluation_mae':p['evaluation_mae'],'stopping_accuracy':p['stopping_accuracy'], | |
| 'hodge':p['hodge'],'interventions':p['interventions'],'single_context_hodge':p['local_context_hodge_change'], | |
| 'paired_direction_minus_random':{'directional_p_change':-0.0007077027439025411,'ci95':[-0.0025355199362799437,0.0011640851827044237]}, | |
| 'paired_direction_minus_shuffled':{'directional_p_change':0.00011520000577670089,'ci95':[-0.0013682840729666037,0.0016645884348286523]}, | |
| 'calibration_layers':p['calibration_mae_alpha_100'], | |
| 'example_cases':ex['examples'],'integrity':{'shards_verified':128,'cube_certificates':1024,'goodfire_per_layer_rows':40448, | |
| 'edited_forwards':2048,'unedited_baseline_records':256,'reference_tests':23,'generator_tests':3}, | |
| 'compute':{'conservative_debit_h100_hours':31.666666666666668,'authorized_ceiling_h100_hours':48, | |
| 'provider_ru_balance':None,'billable_h100_hours':'unavailable; ledger conservatively charges full unknown-billing timeouts'}}, | |
| 'limitations':['The BF16 model gives different probabilities and states on individually replayed prompts; all confirmatory edit comparisons use its validated fixed batch grouping, not single-prompt deployment.', | |
| 'The exact public priors and likelihoods determine the Bayesian posterior, so a probe beating shuffled labels shows recoverability from residuals but not use of a Bayesian algorithm; the decoded cube is strongly nonflat.', | |
| 'Local single-context cube edits are not a global update intervention, and utility after the initial edited action assumes an exact host planner and terminal guess. Intervention comparisons involve only 114 independent evaluation families; null intervals do not prove zero effect.'], | |
| 'supporting_artifact_paths':artifacts, | |
| 'plot_ready_file':str((root/'results/plot_ready.json').resolve()), | |
| 'examples_file':str((root/'results/examples_small.json').resolve()), | |
| 'source_files':[str((repo/n).resolve()) for n in ('prepare.py','analyze.py','run.py','local_hodge.py','review_results.py','hodge_results.json','intervention_results.json','REPORT.md')], | |
| 'code_snapshot':str((root/'src/repaired_run.py').resolve()), | |
| 'validation_file':str((root/'results/validation.txt').resolve())} | |
| (root/'report_summary.json').write_text(json.dumps(summary,indent=2,sort_keys=True,allow_nan=False)+'\n') | |
| claims=[] | |
| def claim(text,path,key,notes=''): | |
| claims.append({'claim':text,'source_file':str(path),'source_key':key,'notes':notes}) | |
| claim('512 disjoint families 256/128/128 and 40,448 contexts',artifacts['dataset_manifest'],'family_count;family_counts_by_split;row_count') | |
| claim('128 matched pairs, 113 within-family and 15 cross-family; 114 independent families represented',str(repo/'dataset_manifest.json'),'pair_types;pair_independence') | |
| claim('40,448 activation rows at six layers, complete shard checksum verification',artifacts['integrity'],'all_128_shard_checksums;expected_rows;store_roundtrip') | |
| claim('Exact BF16 checkpoint, six layers and hook site',artifacts['activation_manifest'],'model;revision;layers;site;dtype') | |
| claim('Single versus batch scores/residuals differ',artifacts['batch_parity'],'max_abs_probability_change;max_activation_relative_l2_by_layer;equal_length_check') | |
| claim('Identical original batch replay, sham identity and target-only known edit',artifacts['matched_batch'],'max_replay_p_difference;max_sham_p_difference;max_unchanged_companion_p_difference;edit_norms') | |
| for task in ('posterior','increment','G'): | |
| claim(f'Held-out {task} readout MAE and controls',artifacts['probe_metrics'],f'readouts.{task}.mae;readouts.{task}.controls_mae') | |
| claim('Natural, probe, public-feature and margin-stratified stopping accuracies',artifacts['probe_metrics'],'stopping.accuracy;stopping.accuracy_controls;stopping.receipt_p_continue.accuracy_at_half;stopping.by_abs_G_margin') | |
| claim('Bayesian cube defects, Hodge certificate, endpoint order spread and family-error correlation',artifacts['hodge_metrics'],'curl_l2;residual_l2;endpoint_spread;max_bound_violation;max_bayes_curl_l2;family_curl_stopping_error_pearson;records') | |
| claim('Direction and all controls probability/decision/utility changes and edit norms',artifacts['intervention_metrics'],'conditions;count;baseline_recipients','Utility is exact-host-conditional, not edited model trajectory.') | |
| claim('Direct paired direction-minus-random and direction-minus-shuffled contrasts',artifacts['paired_contrasts'],'contrasts.direction_minus_random;contrasts.direction_minus_shuffled') | |
| claim('Single-context edited cube defect deltas, not global edits',artifacts['local_hodge'],'conditions;convention;interpretation') | |
| claim('Example successes, failures and natural stopping errors',artifacts['examples_full'],'best_posterior;worst_posterior;natural_errors;counts') | |
| claim('Selected readout and causal edit layer, alpha and scale',artifacts['selected_readout'],'selected;G_intervention_layer;G_intervention_alpha;scale;calibration_trials') | |
| claim('Natural and oracle-conditional realized/expected value',artifacts['probe_metrics'],'utility.realized_common_world;utility.expected_oracle_terminal_value_at_policy_first_action;utility.interpretation') | |
| claim('Input positions, process time and GPU peak',artifacts['runtime'],'total_input_token_positions;process_seconds;peak_gpu_allocated_bytes') | |
| claim('2048 edited forwards and 256 baseline records correct an original runtime mislabel',artifacts['paired_contrasts'],'original_runtime_call_count_correction') | |
| claim('Conservative H100 ceiling/debit and RU unavailable',str(repo/'compute_accounting.json'),'hard_cumulative_h100_hours;prior_conservative_debit_hours;ru_meter;entries') | |
| claim('23 reference and 3 generator tests passed',str(root/'results/validation.txt'),'REFERENCE TESTS;GENERATOR TESTS') | |
| (root/'claims_manifest.json').write_text(json.dumps({'version':1,'claims':claims},indent=2,sort_keys=True,allow_nan=False)+'\n') | |
| print('report_summary +',len(claims),'claims written') | |