aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / native / neuralese / metrics.wl
| 1 | (* Read-only Wolfram oracle. The data placeholder is replaced by untouched CSV fields as a JSON string. *) |
| 2 | data = Map[ToExpression,ImportString[__DATA__,"RawJSON"],{2}]; |
| 3 | fromBits[n_Integer] := Module[{sgn,e,m},sgn=If[BitAnd[BitShiftRight[n,63],1]==1,-1,1]; e=BitAnd[BitShiftRight[n,52],2047]; m=BitAnd[n,2^52-1]; If[e==0,sgn m 2^-1074,sgn (2^52+m) 2^(e-1075)]]; |
| 4 | truth[r_] := Reverse[IntegerDigits[r[[4]],2,4]]; |
| 5 | probs[r_] := N[fromBits /@ r[[10;;13]],18]; |
| 6 | pred[r_] := r[[14;;17]]; |
| 7 | correct[r_] := r[[21]]==0 && pred[r]===truth[r]; |
| 8 | part[r_] := If[r[[2]]==0 || EvenQ[Total[truth[r]]],"train","heldout"]; |
| 9 | key[r_] := Append[r[[{1,2,3,5,6}]],part[r]]; |
| 10 | groups=GatherBy[data,key]; |
| 11 | summary[g_] := Module[{ps,ys,pairs,ece,bins,accepted,messages}, |
| 12 | ps=probs/@g; ys=truth/@g; |
| 13 | pairs=Flatten[Map[Function[r,Transpose[{(Max[#,1-#]&/@probs[r]),MapThread[Boole[#1==#2]&,{pred[r],truth[r]}]}]],g],1]; |
| 14 | bins=Table[Select[pairs,(i/5<=#[[1]] && If[i==4,#[[1]]<=1,#[[1]]<(i+1)/5])&],{i,0,4}]; |
| 15 | ece=Total[(If[Length[#]==0,0,Length[#]/Length[pairs] Abs[Mean[#[[All,1]]]-Mean[#[[All,2]]]]]&)/@bins]; |
| 16 | accepted=Select[g,#[[18]]==0 && #[[21]]==0&]; messages=g[[All,7;;9]]; |
| 17 | <|"key"->key[First[g]],"n"->Length[g],"exact"->Count[correct/@g,True],"featureMSE"->Mean[Flatten[(ps-ys)^2]],"featureECE5"->ece,"abstained"->Count[g[[All,18]],1],"accepted"->Length[accepted],"acceptedExact"->Count[correct/@accepted,True],"collisionPairs"->Total[Binomial[#,2]&/@Values[Counts[messages]]],"distinctMessages"->Length[DeleteDuplicates[messages]],"encoderMedianNs"->Median[g[[All,19]]],"decoderMedianNs"->Median[g[[All,20]]],"encoderP95Ns"->Quantile[g[[All,19]],19/20],"decoderP95Ns"->Quantile[g[[All,20]],19/20]|>]; |
| 18 | ExportString[<|"status"->"PASS","scope"->"EXERCISED synthetic aggregation, not campaign qualification","columns"->Keys[summary[First[groups]]],"metrics"->(Values[summary[#]]&/@groups)|>,"RawJSON","Compact"->True] |