import math,json
from pathlib import Path
scores=[0,math.log(3)];values=[2,6];exp=[math.exp(s)for s in scores];weights=[v/sum(exp)for v in exp];answer=sum(w*v for w,v in zip(weights,values))
assert abs(answer-5)<1e-10 and abs(sum(weights)-1)<1e-10
Path('toy-calculation.json').write_text(json.dumps({'scores':scores,'weights':weights,'values':values,'answer':answer},indent=2))
print('softmax weights 0.25 and 0.75; weighted sum 5. Teaching example only.')
