okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
1be67e894
main
1#!/usr/bin/env python3 2"""Recall checks: put a needle at several depths and verify the answer. 3 4Reuses the prompt builder from strata-bench.py so the prompts are identical in shape. 5""" 6from __future__import annotations 7 8import importlib .util 9import json 10import random 11from pathlib import Path 12 13spec = importlib .util .spec_from_file_location ("sb" ,r"F:\harness\strata-bench.py" ) 14sb = importlib .util .module_from_spec (spec ) 15spec .loader .exec_module (sb ) 16 17CHECKS = [ 18 (2048 ,0.25 ), 19 (2048 ,0.50 ), 20 (2048 ,0.75 ), 21 (8192 ,0.25 ), 22 (8192 ,0.50 ), 23 (8192 ,0.75 ), 24] 25 26rows = [] 27f" { 'target' :>7 } { 'depth' :>7 } { 'prompt_n' :>10 } { 'prompt_tok/s' :>14 } { 'found' :>8 } answer" ) 28"-" * 90 ) 29for size ,depth in CHECKS : 30prompt = sb .build_prompt (size ,needle_depth = depth ,nonce = f"recall- { random . randrange ( 10 ** 9 ) } " ) 31r = sb .call (prompt ,max_tokens = 32 ) 32ans = (r .get ("answer_head" )or "" ).strip () 33ok = sb .NEEDLE .lower ()in ans .lower () 34r .update (target = size ,depth = depth ,needle = sb .NEEDLE ,found = ok ) 35rows .append (r ) 36f" { size :>7 } { depth :>7.2f } { r . get ( 'prompt_n' ):>10 } { r . get ( 'prompt_tok_s' ):>14.1f } {( 'YES' if ok else 'NO' ):>8 } { ans [: 40 ]!r } " ) 37 38out = Path (r"F:\harness\strata-bench\strata-bench-recall.json" ) 39out .parent .mkdir (parents = True ,exist_ok = True ) 40out .write_text (json .dumps ({"needle" :sb .NEEDLE ,"checks" :rows },ensure_ascii = False ,indent = 1 ), 41encoding = "utf-8" ) 42f"\n { sum ( 1 for r in rows if r [ 'found' ]) } / { len ( rows ) } found -> { out } " )