Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
tests: a tiny Clef and the answers of Clef's own code on it
JustVugg4f9e18337110
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 0d587f7f..d4cddf77 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1143,6 +1143,21 @@ jobs:- name: Generate the fixture, build laya, compare with the committed referencerun: make -C c laya-tiny-check+ clef-tiny-check:+ name: Clef tiny oracle (vs joint_schema_model.py) and POST /v1/systemone on qwen36+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-python@v5+ with:+ python-version: '3.12'+ cache: pip+ cache-dependency-path: c/tools/oracle-requirements.txt+ - name: Install the generator's numpy and the converter's torch + safetensors+ run: pip install numpy -r c/tools/oracle-requirements.txt+ - name: Generate and convert the fixture, build qwen36, compare with the committed reference+ run: make -C c clef-tiny-check+jev-sdk-check:name: TypeSafe's SDKs (Python, TypeScript) against coli serve, base URL changed onlyruns-on: ubuntu-latestdiff --git a/.gitignore b/.gitignoreindex aced65a7..76712acd 100644--- a/.gitignore+++ b/.gitignore@@ -140,6 +140,10 @@ c/qwen38_tiny/c/dsv41_tiny/c/qwen36_tiny/c/qwen36_tiny_c/+# tools/make_clef_tiny.py and its container; clef_tiny/ref.json is committed+c/clef_tiny/*+!c/clef_tiny/ref.json+c/clef_tiny_c/c/qwen38_2p4t_tiny/c/qwen38_2p4t_tiny_c/diff --git a/c/Makefile b/c/Makefileindex 0706ec10..96ee466f 100644--- a/c/Makefile+++ b/c/Makefile@@ -1303,6 +1303,20 @@ laya-tiny-generate:laya-tiny-check: laya-tiny-generate laya$(EXE)LAYA_TINY_REQUIRED=1 $(PYTHON) -m unittest -v tests.test_laya_tiny tests.test_decision_serve+# Tiny Clef checkpoint (Cloudflare/clef's layout at toy widths) + the answers of+# Clef's own joint_schema_model.py on it. The generator is numpy and+# deterministic, the converter is the one users run (torch + safetensors);+# clef_tiny/ref.json is committed and comes from tools/make_clef_ref.py+# (maintainer-run, transformers 5.10.2, fixture SHA-256 pinned). The second+# module is the same fixture through `coli serve`: POST /v1/systemone and a chat.+.PHONY: clef-tiny-generate clef-tiny-check+clef-tiny-generate:+ $(PYTHON) tools/make_clef_tiny.py --output ./clef_tiny+ $(PYTHON) tools/convert_qwen36.py --model ./clef_tiny --out ./clef_tiny_c --ebits 8 --no-readme >/dev/null++clef-tiny-check: clef-tiny-generate qwen36$(EXE)+ CLEF_TINY_REQUIRED=1 $(PYTHON) -m unittest -v tests.test_clef_tiny tests.test_decision_serve+# TypeSafe's own SDKs (Python and TypeScript), unmodified, against `coli serve`# on a language model (tiny MiMo) and a decision engine (tiny Laya): switching# from Jev is a base-URL change. Needs the pinned SDKs first:diff --git a/c/clef_tiny/ref.json b/c/clef_tiny/ref.jsonnew file mode 100644index 00000000..743f345d--- /dev/null+++ b/c/clef_tiny/ref.json@@ -0,0 +1,51 @@+{+ "generator":"tools/make_clef_ref.py",+ "reference":{"joint_schema_model.py":"0e304cf7c6500e8bb59bef7e2afd2c6373f82596dfb3b57d1aa93c175e2dc3a3","torch":"2.13.0+cpu","transformers":"5.10.2","dtype":"float32"},+ "fixture_sha256":{"model.safetensors":"67df1447d9a0c6becab03142a969cab8f11eaf616d97d0ec485c78ec4b694caa","joint_head.safetensors":"7bcad27c7841b32ab2eaa4d8294004742c6f63f957443c3528110f06e34edaf0","joint_head_config.json":"db3e9f978271396dcaa5eff87d52822f1c26e29454f64e3be3b27d75360fff7f","config.json":"fb13ea7e7a900c1ddef2d6b3bd82b220c6a8037baa4dc4d78085fa6a49d1af43","tokenizer.json":"c9a12dc929656d608445833e49254b4c740a1dbe781cd695e72f621968c4fbbc"},+ "tolerance":{"probs":2e-05,"logits":0.0001},+ "tokenizer":[+ {"text":"","ids":[]},+ {"text":" ","ids":[32]},+ {"text":" ","ids":[32,32]},+ {"text":" ","ids":[32,32,32,32,32]},+ {"text":"\n\n","ids":[10,10]},+ {"text":"\t","ids":[9]},+ {"text":"a b c d","ids":[97,32,292,32,32,274,32,32,32,293]},+ {"text":"Hello world","ids":[72,323,303,338,330,108,100]},+ {"text":"Hello world\n\n x","ids":[72,323,303,32,32,338,330,108,100,10,10,32,32,120]},+ {"text":"don't I'll we've they're she'd 'S 'T","ids":[100,258,39,116,337,39,108,108,416,39,118,101,280,121,39,273,267,259,39,100,32,39,83,32,39,84]},+ {"text":"2026-10-03 3.14 1000000 12345678901","ids":[50,48,50,54,45,49,48,45,48,51,32,51,46,49,52,32,49,48,48,48,48,48,48,32,49,50,51,52,53,54,55,56,57,48,49]},+ {"text":"café café Å Ω Å","ids":[99,97,102,195,169,274,97,102,195,169,32,195,133,32,206,169,32,195,133]},+ {"text":"日本語のテキスト","ids":[230,151,165,230,156,172,232,170,158,227,129,174,227,131,134,227,130,173,227,130,185,227,131,136]},+ {"text":"🙂👍🏽","ids":[240,159,153,130,240,159,145,141,240,159,143,189]},+ {"text":"a<|im_end|>b<think>c</think>","ids":[97,419,98,441,99,442]},+ {"text":"<|endoftext|><|im_start|>","ids":[417,418]},+ {"text":"tab\tand\r\nnewline\n","ids":[116,97,98,9,264,100,13,10,110,101,119,108,260,101,10]},+ {"text":" leading spaces","ids":[32,32,32,283,352,302,267,112,299,265]},+ {"text":"trailing spaces ","ids":[335,97,327,302,267,112,299,265,32,32,32]},+ {"text":"mixed ,.;:!? punctuation!!! ... ???","ids":[109,105,120,322,32,44,46,59,58,33,63,279,117,110,99,116,117,97,266,33,33,33,32,46,46,46,32,63,63,63]},+ {"text":"über straße Ελληνικά русский عربي हिन्दी","ids":[391,98,256,267,335,97,195,159,101,32,206,149,206,187,206,187,206,183,206,189,206,185,206,186,206,172,32,209,128,209,131,209,129,209,129,208,186,208,184,208,185,32,216,185,216,177,216,168,217,138,32,224,164,185,224,164,191,224,164,168,224,165,141,224,164,166,224,165,128]},+ {"text":"x̃̄y ̀abc","ids":[120,204,131,204,132,121,32,204,128,97,98,99]},+ {"text":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","ids":[120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120]},+ {"text":"{\"description\":\"The proposition is true or the answer is yes.\",\"option_id\":\"true\"}","ids":[291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296]},+ {"text":"\nFIELD 1\nID: q\nTYPE: noul\nINSTRUCTION: ","ids":[10,312,32,49,10,73,68,58,32,113,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32]}+ ],+ "cases":[+ {"name":"model_card_invoice","state":{"invoice":{"vendor":"Acme","total":1250.0,"currency":"USD","status":"overdue"}},"questions":{"status":{"type":"choice","instructions":"What is the invoice status?","criteria":{"paid":"Invoice is paid.","overdue":"Invoice is past due.","draft":"Not sent."}},"large":{"type":"noul","instructions":"Is the total above 1000 USD?"}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,291,260,390,261,291,99,277,114,269,99,121,268,85,83,68,287,115,116,272,285,268,111,389,287,116,111,116,275,261,49,50,53,48,46,48,281,118,269,100,330,268,65,99,109,101,296,125,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,341,272,285,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,272,278,280,306,390,341,272,285,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,78,111,116,267,282,343,111,276,315,268,100,114,97,102,116,296,10,349,32,50,58,32,291,359,268,73,110,390,278,279,97,115,116,293,304,343,111,276,315,268,111,389,296,10,349,32,51,58,32,291,359,268,73,110,390,278,279,97,288,343,111,276,315,268,112,97,288,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,108,316,103,101,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,280,342,116,275,398,98,111,118,101,32,49,48,48,48,32,85,83,68,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"status","type":1,"question_span":[167,178],"option_spans":[[195,214],[220,241],[247,266]],"option_ids":["draft","overdue","paid"],"logits":[0.9154882431030273,1.1947027444839478,0.11060559749603271],"probs":[0.361111044883728,0.4774216115474701,0.16146732866764069]},{"id":"large","type":0,"question_span":[304,325],"option_spans":[[342,365],[371,392]],"option_ids":["true","false"],"logits":[1.855867624282837,1.1525310277938843],"probs":[0.6689270734786987,0.3310728669166565]}],"systemone":{"model":"clef-tiny","answers":{"status":{"type":"choice","choice":"overdue","confidence":0.4774,"probabilities":{"paid":0.1615,"overdue":0.4774,"draft":0.3611}},"large":{"type":"noul","noul":0.6689}},"usage":{"input_tokens":430,"output_tokens":0}}},+ {"name":"model_card_systemone","state":"Our checkout started returning errors and orders are blocked.","questions":{"department":{"type":"choice","instructions":"Which team should handle the message?","criteria":{"billing":"Payments or invoices","technical":"Bugs or outages"}},"urgency":{"type":"score","criteria":["Can wait","This week","Today"]},"outage":{"type":"noul","instructions":"Is a service down?"}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,79,277,274,259,319,331,116,341,356,322,295,385,110,302,400,405,307,100,256,115,398,273,406,322,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,293,101,112,356,328,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,270,104,257,101,97,109,267,104,331,108,100,32,104,264,100,283,280,401,265,115,353,101,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,80,357,115,307,306,118,111,270,265,287,111,276,315,268,98,372,302,296,10,349,32,50,58,32,291,359,268,66,117,103,115,307,263,117,116,353,265,287,111,276,315,268,116,101,318,110,270,275,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,277,103,269,99,121,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,277,103,269,99,121,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,67,264,338,97,105,116,287,111,276,315,268,48,296,10,349,32,50,58,32,291,359,268,84,104,271,416,101,107,287,111,276,315,268,49,296,10,349,32,51,58,32,291,359,268,84,111,100,300,287,111,276,315,268,50,296,10,69,78,68,336,10,10,312,32,51,10,73,68,58,263,117,116,353,101,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,398,267,256,118,301,293,380,110,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"department","type":1,"question_span":[147,172],"option_spans":[[189,210],[216,241]],"option_ids":["billing","technical"],"logits":[0.5397498607635498,-0.159115731716156],"probs":[0.6679362058639526,0.33206379413604736]},{"id":"urgency","type":2,"question_span":[281,286],"option_spans":[[303,319],[325,341],[347,361]],"option_ids":["0","1","2"],"logits":[0.4656486511230469,1.7831664085388184,1.8825340270996094],"probs":[0.11288726329803467,0.42153695225715637,0.46557584404945374]},{"id":"outage","type":0,"question_span":[399,410],"option_spans":[[427,450],[456,477]],"option_ids":["true","false"],"logits":[2.3275585174560547,2.4374260902404785],"probs":[0.47256070375442505,0.527439296245575]}],"systemone":{"model":"clef-tiny","answers":{"department":{"type":"choice","choice":"billing","confidence":0.6679,"probabilities":{"billing":0.6679,"technical":0.3321}},"urgency":{"type":"score","score":1.3527,"confidence":0.4656,"legend":{"0":"Can wait","1":"This week","2":"Today"},"probabilities":{"0":0.1129,"1":0.4215,"2":0.4656}},"outage":{"type":"noul","noul":0.4726}},"usage":{"input_tokens":515,"output_tokens":0}}},+ {"name":"ticket_four_questions","state":{"from":"[email protected]","subject":"Duplicate charge on invoice #4411","body":"Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan."},"questions":{"department":{"type":"choice","instructions":"Which department should handle this request?","criteria":{"billing":"invoices, payments, refunds","technical":"bugs, outages, system errors","sales":"pricing, new contracts","other":"everything else"}},"urgency":{"type":"score","instructions":"How urgent is this request?","criteria":["not urgent","soon","critical deadline or blocking issue"]},"churn_risk":{"type":"noul","instructions":"Does the user threaten to cancel or leave?"},"refund":{"type":"noul","instructions":"Is a refund requested?","criteria":{"true":"the customer asks for money back","false":"no refund is mentioned"}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,291,98,111,100,121,268,72,105,44,416,32,305,101,292,327,283,100,257,119,301,294,330,395,316,318,46,32,80,374,333,412,280,293,117,112,108,270,317,342,100,300,307,416,338,372,407,99,323,263,277,279,108,264,343,102,284,109,268,387,64,299,109,101,46,99,377,287,115,117,98,106,101,99,116,268,68,117,112,108,270,317,274,104,316,103,101,32,258,306,390,32,35,52,52,49,49,296,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,293,101,112,356,328,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,270,104,293,101,112,356,328,267,104,331,108,100,32,104,264,100,283,415,413,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,260,118,111,270,265,44,410,115,44,412,115,287,111,276,315,268,98,372,302,296,10,349,32,50,58,32,291,359,268,101,118,256,121,116,104,302,32,323,333,287,111,276,315,268,111,116,104,256,296,10,349,32,51,58,32,291,359,268,112,114,270,302,44,32,110,101,119,274,258,335,354,115,287,111,276,315,268,115,275,265,296,10,349,32,52,58,32,291,359,268,98,117,103,115,44,263,117,116,353,265,44,267,121,115,116,101,109,400,287,111,276,315,268,116,101,318,110,270,275,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,277,103,269,99,121,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,72,380,403,278,415,413,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,376,403,287,111,276,315,268,48,296,10,349,32,50,58,32,291,359,268,115,111,258,287,111,276,315,268,49,296,10,349,32,51,58,32,291,359,268,320,262,99,275,293,360,108,260,101,307,406,302,278,115,304,287,111,276,315,268,50,296,10,69,78,68,336,10,10,312,32,51,10,73,68,58,274,104,277,110,95,114,271,107,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,68,111,265,280,32,387,308,273,272,269,342,407,99,323,307,32,374,118,101,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,52,10,73,68,58,412,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,398,412,413,322,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,116,259,274,388,377,256,398,115,107,115,294,330,401,258,101,121,292,299,107,287,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,289,412,278,401,269,266,322,287,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"department","type":1,"question_span":[219,241],"option_spans":[[258,281],[287,310],[316,342],[348,381]],"option_ids":["billing","other","sales","technical"],"logits":[-0.0806606113910675,-0.2691041827201843,1.109460473060608,-0.007556557655334473],"probs":[0.16150996088981628,0.1337701827287674,0.5309606194496155,0.17375926673412323]},{"id":"urgency","type":2,"question_span":[421,428],"option_spans":[[445,457],[463,476],[482,507]],"option_ids":["0","1","2"],"logits":[1.317476511001587,2.6444015502929688,0.4393831491470337],"probs":[0.19286368787288666,0.7269870638847351,0.08014921844005585]},{"id":"churn_risk","type":0,"question_span":[548,568],"option_spans":[[585,608],[614,635]],"option_ids":["true","false"],"logits":[-0.27992522716522217,-0.8304091691970825],"probs":[0.634247899055481,0.3657521605491638]},{"id":"refund","type":0,"question_span":[669,676],"option_spans":[[693,723],[729,747]],"option_ids":["true","false"],"logits":[1.0331885814666748,1.6130753755569458],"probs":[0.3589586317539215,0.6410413384437561]}],"systemone":{"model":"clef-tiny","answers":{"department":{"type":"choice","choice":"sales","confidence":0.531,"probabilities":{"billing":0.1615,"technical":0.1738,"sales":0.531,"other":0.1338}},"urgency":{"type":"score","score":0.8873,"confidence":0.727,"legend":{"0":"not urgent","1":"soon","2":"critical deadline or blocking issue"},"probabilities":{"0":0.1929,"1":0.727,"2":0.0801}},"churn_risk":{"type":"noul","noul":0.6342},"refund":{"type":"noul","noul":0.359}},"usage":{"input_tokens":785,"output_tokens":0}}},+ {"name":"choice_descriptions","state":"We would like a demo of the product next week.","questions":{"intent":{"type":"choice","instructions":"What does the sender want?","criteria":{"Zeta":"a product demonstration","alpha":null,"Beta":"","émigré":{"k":[1,2.5,{"z":null,"a":true}],"b":"x"},"中文":3,"quote\"d":["x","y"],"back\\slash":"tab\there\nnewline \"quoted\""}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,87,101,338,331,108,100,32,108,105,107,101,398,293,101,109,111,263,102,280,340,100,117,99,116,32,110,101,120,116,416,101,107,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,306,116,282,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,272,293,111,265,280,267,269,100,256,338,264,116,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,287,111,276,315,268,66,101,116,97,296,10,349,32,50,58,32,291,359,268,97,340,100,117,99,116,293,101,109,258,115,335,97,266,287,111,276,315,268,90,101,116,97,296,10,349,32,51,58,32,291,111,276,315,268,275,112,104,97,296,10,349,32,52,58,32,291,359,268,116,97,98,92,116,104,256,101,92,110,110,101,119,108,260,101,32,92,34,383,111,116,322,92,34,287,111,276,315,268,98,299,107,92,92,115,108,97,115,104,296,10,349,32,53,58,32,291,359,261,91,34,120,287,121,34,93,281,111,276,315,268,383,111,116,101,92,34,100,296,10,349,32,54,58,32,291,359,261,291,98,268,120,287,107,261,91,49,44,50,46,53,44,291,97,261,335,304,281,122,261,110,117,108,108,125,93,125,281,111,276,315,268,195,169,109,105,103,114,195,169,296,10,349,32,55,58,32,291,359,261,51,281,111,276,315,268,228,184,173,230,150,135,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"intent","type":1,"question_span":[153,168],"option_spans":[[185,198],[204,231],[237,247],[253,297],[303,326],[332,378],[384,400]],"option_ids":["Beta","Zeta","alpha","back\\slash","quote\"d","émigré","中文"],"logits":[-2.1980934143066406,-2.756772041320801,-0.9637116193771362,-1.7282432317733765,-0.6392026543617249,-3.165788173675537,-3.7222847938537598],"probs":[0.08361711353063583,0.04782600700855255,0.28732961416244507,0.13376687467098236,0.39747777581214905,0.0317709855735302,0.018211565911769867]}],"systemone":{"model":"clef-tiny","answers":{"intent":{"type":"choice","choice":"quote\"d","confidence":0.3975,"probabilities":{"Zeta":0.0478,"alpha":0.2873,"Beta":0.0836,"émigré":0.0318,"中文":0.0182,"quote\"d":0.3975,"back\\slash":0.1338}}},"usage":{"input_tokens":438,"output_tokens":0}}},+ {"name":"scores","state":"This is the worst service I have ever used, nothing works.","questions":{"sentiment":{"type":"score","instructions":"What is the tone?","criteria":["angry",null,"neutral",{"label":"positive","w":1},"delighted"]},"two_levels":{"type":"score","instructions":"Is any action needed?","criteria":["no action","action needed"]},"numeric_levels":{"type":"score","instructions":"Rate the urgency.","criteria":[1,2,3]}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,84,104,271,278,280,338,330,115,116,267,256,118,301,337,32,104,97,118,101,399,118,256,32,285,322,44,32,376,104,302,338,330,107,115,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,267,269,262,328,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,87,104,272,278,280,257,258,101,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,264,103,114,121,287,111,276,315,268,48,296,10,349,32,50,58,32,291,111,276,315,268,49,296,10,349,32,51,58,32,291,359,268,110,101,117,335,275,287,111,276,315,268,50,296,10,349,32,52,58,32,291,359,261,291,108,97,98,323,268,112,379,105,262,118,101,287,119,261,49,125,281,111,276,315,268,51,296,10,349,32,53,58,32,291,359,268,100,323,105,103,104,116,322,287,111,276,315,268,52,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,257,119,111,95,283,118,323,115,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,73,115,286,121,32,299,266,32,110,101,322,322,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,289,32,299,266,287,111,276,315,268,48,296,10,349,32,50,58,32,291,359,268,299,266,32,110,101,322,322,287,111,276,315,268,49,296,10,69,78,68,336,10,10,312,32,51,10,73,68,58,32,110,117,109,256,270,95,283,118,323,115,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,82,317,280,32,277,103,269,99,121,46,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,261,49,281,111,276,315,268,48,296,10,349,32,50,58,32,291,359,261,50,281,111,276,315,268,49,296,10,349,32,51,58,32,291,359,261,51,281,111,276,315,268,50,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"sentiment","type":2,"question_span":[157,166],"option_spans":[[183,197],[203,210],[216,231],[237,264],[270,287]],"option_ids":["0","1","2","3","4"],"logits":[0.2639131546020508,1.562415599822998,1.144463062286377,-0.20394718647003174,-0.1468263864517212],"probs":[0.11953812837600708,0.4379644989967346,0.28835296630859375,0.07487163692712784,0.07927286624908447]},{"id":"two_levels","type":2,"question_span":[329,342],"option_spans":[[359,373],[379,396]],"option_ids":["0","1"],"logits":[2.2924070358276367,0.9775638580322266],"probs":[0.7883224487304688,0.21167752146720886]},{"id":"numeric_levels","type":2,"question_span":[441,451],"option_spans":[[468,479],[485,496],[502,513]],"option_ids":["0","1","2"],"logits":[2.3375372886657715,2.326552391052246,3.4103164672851562],"probs":[0.2035595178604126,0.20133565366268158,0.5951048135757446]}],"systemone":{"model":"clef-tiny","answers":{"sentiment":{"type":"score","score":1.5564,"confidence":0.438,"legend":{"0":"angry","1":null,"2":"neutral","3":{"label":"positive","w":1},"4":"delighted"},"probabilities":{"0":0.1195,"1":0.438,"2":0.2884,"3":0.0749,"4":0.0793}},"two_levels":{"type":"score","score":0.2117,"confidence":0.7883,"legend":{"0":"no action","1":"action needed"},"probabilities":{"0":0.7883,"1":0.2117}},"numeric_levels":{"type":"score","score":1.3915,"confidence":0.5951,"legend":{"0":1,"1":2,"2":3},"probabilities":{"0":0.2036,"1":0.2013,"2":0.5951}}},"usage":{"input_tokens":551,"output_tokens":0}}},+ {"name":"noul_variants","state":"The package arrived late and the box was damaged.","questions":{"late":{"type":"noul","instructions":"Was it late?","criteria":{"true":"it came after the date"}},"damaged":{"type":"noul","instructions":"Was it damaged?","criteria":{"false":null}},"both":{"type":"noul","instructions":"Both?","criteria":{"true":null,"false":""}},"plain":{"type":"noul","instructions":"Should we refund?"},"cased":{"type":"noul","instructions":"Is it urgent?","criteria":{"True":"ignored: not the key true","false":"the answer is no"}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,314,279,299,107,353,101,32,316,290,118,322,32,108,317,405,280,292,111,120,338,97,115,293,97,109,353,322,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,32,108,317,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,87,97,115,32,105,116,32,108,317,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,105,116,274,97,109,101,398,102,116,256,280,293,317,287,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,293,97,109,353,322,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,87,97,115,32,105,116,293,97,109,353,322,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,51,10,73,68,58,292,111,116,104,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,66,111,116,104,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,287,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,52,10,73,68,58,279,108,97,260,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,83,104,331,108,100,416,412,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,53,10,73,68,58,274,97,115,322,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,32,105,116,403,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,116,259,339,278,402,287,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"late","type":0,"question_span":[148,158],"option_spans":[[175,199],[205,226]],"option_ids":["true","false"],"logits":[0.3964632749557495,1.5161614418029785],"probs":[0.24606727063655853,0.7539327144622803]},{"id":"damaged","type":0,"question_span":[264,276],"option_spans":[[293,316],[322,330]],"option_ids":["true","false"],"logits":[0.6280949115753174,-0.3258349895477295],"probs":[0.7219048738479614,0.27809521555900574]},{"id":"both","type":0,"question_span":[367,372],"option_spans":[[389,397],[403,414]],"option_ids":["true","false"],"logits":[0.009809315204620361,-0.4327448010444641],"probs":[0.6088674664497375,0.39113256335258484]},{"id":"plain","type":0,"question_span":[451,459],"option_spans":[[476,499],[505,526]],"option_ids":["true","false"],"logits":[0.9093382358551025,0.8931791186332703],"probs":[0.5040397047996521,0.4959603250026703]},{"id":"cased","type":0,"question_span":[563,570],"option_spans":[[587,610],[616,632]],"option_ids":["true","false"],"logits":[2.000317096710205,1.2125566005706787],"probs":[0.6873502731323242,0.31264975666999817]}],"systemone":{"model":"clef-tiny","answers":{"late":{"type":"noul","noul":0.2461},"damaged":{"type":"noul","noul":0.7219},"both":{"type":"noul","noul":0.6089},"plain":{"type":"noul","noul":0.504},"cased":{"type":"noul","noul":0.6874}},"usage":{"input_tokens":670,"output_tokens":0}}},+ {"name":"instructions_forms","state":"A customer wrote to support about a login problem.","questions":{"as_object":{"type":"noul","instructions":{"task":"is it about login","steps":["read","decide"]}},"as_list":{"type":"noul","instructions":["Is","it","urgent?"]},"empty":{"type":"noul","instructions":""},"spaces":{"type":"noul","instructions":" "},"missing":{"type":"noul"},"number":{"type":"noul","instructions":7}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,65,274,388,377,256,338,284,116,101,342,267,117,112,112,330,116,398,98,331,116,398,32,303,103,260,340,98,283,109,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,398,115,95,111,98,106,101,99,116,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,291,115,116,101,112,115,261,91,34,273,352,287,100,101,99,288,101,34,93,281,116,97,115,107,268,271,32,105,116,398,98,331,116,32,303,103,260,296,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,398,115,95,108,271,116,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,91,34,73,115,287,105,116,287,386,63,34,93,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,51,10,73,68,58,399,109,112,116,121,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,101,109,112,116,121,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,52,10,73,68,58,267,112,299,265,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,32,32,32,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,53,10,73,68,58,401,271,115,302,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,109,271,115,302,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,54,10,73,68,58,32,110,117,109,98,256,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,55,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"as_object","type":0,"question_span":[156,194],"option_spans":[[211,234],[240,261]],"option_ids":["true","false"],"logits":[2.6694562435150146,1.6153161525726318],"probs":[0.7415691614151001,0.2584308981895447]},{"id":"as_list","type":0,"question_span":[300,312],"option_spans":[[329,352],[358,379]],"option_ids":["true","false"],"logits":[2.440708637237549,1.6098711490631104],"probs":[0.6965320110321045,0.3034680485725403]},{"id":"empty","type":0,"question_span":[417,422],"option_spans":[[439,462],[468,489]],"option_ids":["true","false"],"logits":[3.33303165435791,3.232635974884033],"probs":[0.5250778198242188,0.4749220907688141]},{"id":"spaces","type":0,"question_span":[526,529],"option_spans":[[546,569],[575,596]],"option_ids":["true","false"],"logits":[2.659193277359009,2.5496625900268555],"probs":[0.5273553133010864,0.4726446568965912]},{"id":"missing","type":0,"question_span":[633,637],"option_spans":[[654,677],[683,704]],"option_ids":["true","false"],"logits":[3.3364572525024414,2.9328856468200684],"probs":[0.5995454788208008,0.4004545211791992]},{"id":"number","type":0,"question_span":[743,744],"option_spans":[[761,784],[790,811]],"option_ids":["true","false"],"logits":[-1.3729013204574585,-0.7311528921127319],"probs":[0.34485143423080444,0.6551486253738403]}],"systemone":{"model":"clef-tiny","answers":{"as_object":{"type":"noul","noul":0.7416},"as_list":{"type":"noul","noul":0.6965},"empty":{"type":"noul","noul":0.5251},"spaces":{"type":"noul","noul":0.5274},"missing":{"type":"noul","noul":0.5995},"number":{"type":"noul","noul":0.3449}},"usage":{"input_tokens":849,"output_tokens":0}}},+ {"name":"json_state","state":{"ticket":{"id":4411,"amount":129.5,"ratio":1e-05,"big":1e+21,"neg":-0.0,"huge":123456789012345678901234567890,"paid":true,"refund":null,"tags":["billing","urgent"],"ä":"umlaut","Z":"upper","a":"lower","nested":{"b":[1,2.0,{"c":"d"}],"a":{}}}},"questions":{"paid":{"type":"noul","instructions":"Was the ticket paid?"},"action":{"type":"choice","instructions":{"task":"pick the next action"},"criteria":{"refund":"give the money back","escalate":"a human decides","close":"nothing to do"}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,291,262,319,101,116,261,291,90,268,117,112,112,256,287,97,268,303,305,287,97,109,331,110,116,261,49,50,57,46,53,281,98,105,103,261,49,101,43,50,49,281,104,117,103,101,261,49,50,51,52,53,54,55,56,57,48,49,50,51,52,53,54,55,56,57,48,49,50,51,52,53,54,55,56,57,48,281,288,261,52,52,49,49,281,110,101,103,261,45,48,46,48,281,110,326,322,261,291,97,261,123,125,281,98,261,91,49,44,50,46,48,44,291,99,268,100,296,93,125,281,112,97,288,261,335,304,281,114,97,262,111,261,49,101,45,48,53,281,273,368,261,110,117,108,108,281,116,353,115,261,91,34,98,372,302,287,386,34,93,281,195,164,268,117,109,108,97,117,116,296,125,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,279,97,288,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,87,97,115,280,257,270,107,101,116,279,97,288,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,299,266,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,291,116,97,115,107,268,112,270,107,280,32,110,101,120,116,32,299,266,296,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,376,104,302,342,293,111,287,111,276,315,268,99,303,333,296,10,349,32,50,58,32,291,359,268,97,32,104,117,109,264,293,101,99,288,265,287,111,276,315,268,265,99,275,317,296,10,349,32,51,58,32,291,359,268,103,105,118,101,280,401,258,101,121,292,299,107,287,111,276,315,268,273,368,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"paid","type":0,"question_span":[291,304],"option_spans":[[321,344],[350,371]],"option_ids":["true","false"],"logits":[0.43724995851516724,0.33808833360671997],"probs":[0.5247701406478882,0.4752299189567566]},{"id":"action","type":1,"question_span":[407,426],"option_spans":[[443,461],[467,491],[497,520]],"option_ids":["close","escalate","refund"],"logits":[1.0007648468017578,0.6837937235832214,0.4168078303337097],"probs":[0.43743783235549927,0.3186086118221283,0.24395349621772766]}],"systemone":{"model":"clef-tiny","answers":{"paid":{"type":"noul","noul":0.5248},"action":{"type":"choice","choice":"close","confidence":0.4374,"probabilities":{"refund":0.244,"escalate":0.3186,"close":0.4374}}},"usage":{"input_tokens":558,"output_tokens":0}}},+ {"name":"conversation","state":[{"role":"user","content":"Hi, I cannot log in to my account since yesterday."},{"role":"assistant","content":"Did you try to reset the password?"},{"role":"user","content":"Yes, twice. If it is not fixed today I will cancel."}],"questions":{"churn":{"type":"noul","instructions":"Does the user threaten to cancel?"},"topic":{"type":"choice","instructions":"What is it about?","criteria":{"login":"access to the account","billing":"payments","other":"anything else"}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,91,291,99,258,116,282,268,72,105,44,337,407,376,32,303,103,306,342,401,121,32,299,99,331,110,116,267,260,99,101,404,326,324,300,343,284,283,268,387,296,44,291,99,258,116,282,268,68,288,404,331,257,114,121,342,32,114,265,101,116,280,279,97,115,115,119,330,100,63,287,284,283,268,97,115,115,271,116,264,116,296,44,291,99,258,116,282,268,89,265,44,257,119,301,46,337,102,32,105,116,278,32,376,294,105,120,322,342,100,300,337,338,372,407,99,323,343,284,283,268,387,296,93,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,274,104,277,110,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,68,111,265,280,32,387,308,273,272,269,342,407,99,323,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,342,112,270,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,272,278,32,105,116,398,98,331,116,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,112,357,115,287,111,276,315,268,98,372,302,296,10,349,32,50,58,32,291,359,268,299,99,265,115,342,280,32,299,99,331,110,116,287,111,276,315,268,303,103,260,296,10,349,32,51,58,32,291,359,268,264,121,116,104,302,32,323,333,287,111,276,315,268,111,116,104,256,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"churn","type":0,"question_span":[244,259],"option_spans":[[276,299],[305,326]],"option_ids":["true","false"],"logits":[-0.4425595998764038,-0.36457160115242004],"probs":[0.4805128872394562,0.5194871425628662]},{"id":"topic","type":1,"question_span":[362,374],"option_spans":[[391,406],[412,436],[442,463]],"option_ids":["billing","login","other"],"logits":[0.15592749416828156,-0.5101790428161621,-0.4097936451435089],"probs":[0.4803869426250458,0.24677707254886627,0.27283596992492676]}],"systemone":{"model":"clef-tiny","answers":{"churn":{"type":"noul","noul":0.4805},"topic":{"type":"choice","choice":"billing","confidence":0.4804,"probabilities":{"login":0.2468,"billing":0.4804,"other":0.2728}}},"usage":{"input_tokens":501,"output_tokens":0}}},+ {"name":"special_text","state":"Order arrived broken, see\tphoto.\r\n\r\nThe café (café) said <|im_end|> and <think> then <|endoftext|>. Grüße, ευχαριστώ. हिन्दी भाषा x̃̄y 我们的账户被锁了 🙂👍🏽 'S 'll don't 12345 3.14","questions":{"damaged":{"type":"noul","instructions":"Was the <|im_end|> item damaged?"},"ïd <think>":{"type":"choice","instructions":"Which channel should answer?","criteria":{"email":"write an email back","phone":"call\tthe customer","none":null}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,79,114,100,256,32,316,290,118,322,32,292,284,107,269,44,32,32,267,101,101,9,112,104,111,116,111,46,13,10,13,10,314,274,97,102,195,169,32,40,99,97,102,195,169,41,267,97,288,32,419,405,32,441,280,110,32,417,46,32,71,114,391,195,159,101,44,32,206,181,207,133,207,135,206,177,207,129,206,185,207,131,207,132,207,142,46,32,224,164,185,224,164,191,224,164,168,224,165,141,224,164,166,224,165,128,32,224,164,173,224,164,190,224,164,183,224,164,190,32,120,204,131,204,132,121,32,392,145,228,187,172,231,154,132,232,180,166,392,183,232,162,171,233,148,129,228,186,134,32,240,159,153,130,240,159,145,141,240,159,143,189,32,39,83,32,39,108,108,293,258,39,116,32,49,50,51,52,53,32,51,46,49,52,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,293,97,109,353,322,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,87,97,115,280,32,419,32,105,116,101,109,293,97,109,353,322,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,195,175,100,32,441,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,270,104,274,104,264,110,323,267,104,331,108,100,339,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,119,290,116,101,286,399,109,97,327,292,299,107,287,111,276,315,268,101,109,97,327,296,10,349,32,50,58,32,291,111,276,315,268,110,258,101,296,10,349,32,51,58,32,291,359,268,99,275,108,92,116,116,259,274,388,377,256,287,111,276,315,268,112,104,258,101,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"damaged","type":0,"question_span":[305,322],"option_spans":[[339,362],[368,389]],"option_ids":["true","false"],"logits":[-0.2212679386138916,-0.21124958992004395],"probs":[0.4974953830242157,0.5025045275688171]},{"id":"ïd <think>","type":1,"question_span":[428,444],"option_spans":[[461,486],[492,501],[507,531]],"option_ids":["email","none","phone"],"logits":[-1.5746028423309326,0.41884493827819824,-0.6620057821273804],"probs":[0.09232261031866074,0.6777217984199524,0.22995556890964508]}],"systemone":{"model":"clef-tiny","answers":{"damaged":{"type":"noul","noul":0.4975},"ïd <think>":{"type":"choice","choice":"none","confidence":0.6777,"probabilities":{"email":0.0923,"phone":0.23,"none":0.6777}}},"usage":{"input_tokens":569,"output_tokens":0}}},+ {"name":"many_options","state":"Security incident: a phishing email asked employees to reset passwords.","questions":{"category":{"type":"choice","instructions":"Classify the incident.","criteria":{"cat00":"phishing email","cat01":"malware on a laptop","cat02":"lost badge","cat03":"weak password","cat04":"data leak","cat05":"denial of service","cat06":"insider abuse","cat07":"ransomware","cat08":"stolen phone","cat09":"fake invoice","cat10":"open bucket","cat11":"expired certificate","cat12":"unpatched server","cat13":"social engineering","cat14":"shared account","cat15":"spam wave","cat16":"brute force","cat17":"DNS hijack","cat18":"rogue access point","cat19":"USB drop","cat20":"supply chain","cat21":"typosquatting","cat22":"clickjacking","cat23":"SQL injection","cat24":"cross site scripting","cat25":"privilege escalation","cat26":"misconfigured firewall","cat27":"lost backup","cat28":"shadow IT","cat29":"credential stuffing","cat30":"session theft","cat31":"cryptomining","cat32":"defacement","cat33":"botnet","cat34":"zero day","cat35":"vishing","cat36":"smishing","cat37":"tailgating","cat38":"dumpster diving","cat39":"watering hole"}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,83,101,99,277,105,116,121,306,99,288,282,58,398,279,104,271,104,302,399,109,97,327,398,115,107,322,399,109,112,303,121,101,265,342,32,114,265,101,116,279,97,115,115,119,330,100,115,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,274,317,103,330,121,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,67,108,97,115,115,105,102,121,280,306,99,288,282,46,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,112,104,271,104,302,399,109,97,327,287,111,276,315,268,99,272,48,48,296,10,349,32,50,58,32,291,359,268,109,275,119,97,273,32,258,398,32,108,97,112,116,111,112,287,111,276,315,268,99,272,48,49,296,10,349,32,51,58,32,291,359,268,303,115,116,292,352,103,101,287,111,276,315,268,99,272,48,50,296,10,349,32,52,58,32,291,359,268,119,101,97,107,279,97,115,115,119,330,100,287,111,276,315,268,99,272,48,51,296,10,349,32,53,58,32,291,359,268,100,272,97,32,374,107,287,111,276,315,268,99,272,48,52,296,10,349,32,54,58,32,291,359,268,100,269,105,275,263,102,267,256,118,301,287,111,276,315,268,99,272,48,53,296,10,349,32,55,58,32,291,359,268,260,115,288,256,398,98,285,101,287,111,276,315,268,99,272,48,54,296,10,349,32,56,58,32,291,359,268,114,264,115,377,119,97,273,287,111,276,315,268,99,272,48,55,296,10,349,32,57,58,32,291,359,268,115,116,111,108,269,279,104,258,101,287,111,276,315,268,99,272,48,56,296,10,349,32,49,48,58,32,291,359,268,102,97,107,101,306,390,287,111,276,315,268,99,272,48,57,296,10,349,32,49,49,58,32,291,359,268,111,112,269,292,117,319,101,116,287,111,276,315,268,99,272,49,48,296,10,349,32,49,50,58,32,291,359,268,101,120,112,105,273,100,274,256,262,102,270,317,287,111,276,315,268,99,272,49,49,296,10,349,32,49,51,58,32,291,359,268,117,110,112,272,358,100,267,256,118,256,287,111,276,315,268,99,272,49,50,296,10,349,32,49,52,58,32,291,359,268,115,111,99,105,275,32,269,103,260,101,256,302,287,111,276,315,268,99,272,49,51,296,10,349,32,49,53,58,32,291,359,268,115,104,97,273,100,32,299,99,331,110,116,287,111,276,315,268,99,272,49,52,296,10,349,32,49,54,58,32,291,359,268,115,112,97,109,338,97,118,101,287,111,276,315,268,99,272,49,53,296,10,349,32,49,55,58,32,291,359,268,98,114,117,116,101,294,330,99,101,287,111,276,315,268,99,272,49,54,296,10,349,32,49,56,58,32,291,359,268,68,78,83,32,104,105,106,299,107,287,111,276,315,268,99,272,49,55,296,10,349,32,49,57,58,32,291,359,268,284,103,304,32,299,99,265,115,279,111,260,116,287,111,276,315,268,99,272,49,56,296,10,349,32,50,48,58,32,291,359,268,85,83,66,293,284,112,287,111,276,315,268,99,272,49,57,296,10,349,32,50,49,58,32,291,359,268,115,117,112,112,373,274,104,97,260,287,111,276,315,268,99,272,50,48,296,10,349,32,50,50,58,32,291,359,268,116,121,112,379,383,272,116,302,287,111,276,315,268,99,272,50,49,296,10,349,32,50,51,58,32,291,359,268,99,108,270,107,106,299,107,302,287,111,276,315,268,99,272,50,50,296,10,349,32,50,52,58,32,291,359,268,83,81,76,306,106,101,99,266,287,111,276,315,268,99,272,50,51,296,10,349,32,50,53,58,32,291,359,268,99,284,115,115,267,105,116,101,267,320,112,116,302,287,111,276,315,268,99,272,50,52,296,10,349,32,50,54,58,32,291,359,268,112,290,118,105,283,103,101,32,265,99,275,97,266,287,111,276,315,268,99,272,50,53,296,10,349,32,50,55,58,32,291,359,268,109,271,99,258,102,105,103,117,273,100,294,105,273,119,275,108,287,111,276,315,268,99,272,50,54,296,10,349,32,50,56,58,32,291,359,268,303,115,116,292,299,107,117,112,287,111,276,315,268,99,272,50,55,296,10,349,32,50,57,58,32,291,359,268,115,104,352,380,337,84,287,111,276,315,268,99,272,50,56,296,10,349,32,51,48,58,32,291,359,268,99,273,100,269,262,275,341,117,102,102,302,287,111,276,315,268,99,272,50,57,296,10,349,32,51,49,58,32,291,359,268,115,265,115,105,258,280,102,116,287,111,276,315,268,99,272,51,48,296,10,349,32,51,50,58,32,291,359,268,99,114,121,112,116,377,260,302,287,111,276,315,268,99,272,51,49,296,10,349,32,51,51,58,32,291,359,268,100,101,102,299,101,328,287,111,276,315,268,99,272,51,50,296,10,349,32,51,52,58,32,291,359,268,98,111,116,110,101,116,287,111,276,315,268,99,272,51,51,296,10,349,32,51,53,58,32,291,359,268,122,256,111,293,300,287,111,276,315,268,99,272,51,52,296,10,349,32,51,54,58,32,291,359,268,118,271,104,302,287,111,276,315,268,99,272,51,53,296,10,349,32,51,55,58,32,291,359,268,115,109,271,104,302,287,111,276,315,268,99,272,51,54,296,10,349,32,51,56,58,32,291,359,268,116,97,327,103,272,302,287,111,276,315,268,99,272,51,55,296,10,349,32,51,57,58,32,291,359,268,100,117,109,112,115,116,256,293,105,118,302,287,111,276,315,268,99,272,51,56,296,10,349,32,52,48,58,32,291,359,268,119,272,256,302,32,104,111,283,287,111,276,315,268,99,272,51,57,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"category","type":1,"question_span":[170,184],"option_spans":[[201,223],[229,257],[263,283],[289,313],[319,338],[344,367],[373,394],[400,420],[426,448],[455,474],[481,502],[509,534],[541,564],[571,596],[603,627],[634,655],[662,684],[691,713],[720,745],[752,771],[778,800],[807,828],[835,856],[863,884],[891,917],[924,950],[957,986],[993,1014],[1021,1040],[1047,1071],[1078,1099],[1106,1127],[1134,1153],[1160,1179],[1186,1204],[1211,1228],[1235,1253],[1260,1279],[1286,1310],[1317,1338]],"option_ids":["cat00","cat01","cat02","cat03","cat04","cat05","cat06","cat07","cat08","cat09","cat10","cat11","cat12","cat13","cat14","cat15","cat16","cat17","cat18","cat19","cat20","cat21","cat22","cat23","cat24","cat25","cat26","cat27","cat28","cat29","cat30","cat31","cat32","cat33","cat34","cat35","cat36","cat37","cat38","cat39"],"logits":[1.0729522705078125,-0.2232648730278015,-0.8142780065536499,-0.9791420698165894,-1.1218870878219604,-1.2081364393234253,-1.0098265409469604,-1.1763046979904175,0.9766923189163208,-0.7938417792320251,-0.11191239953041077,-0.9143550395965576,-0.5441151857376099,-1.0470551252365112,-1.3750957250595093,-1.5158671140670776,-1.85256826877594,-0.5000773072242737,-1.0489230155944824,0.5292248129844666,0.7416372895240784,-0.5055141448974609,-0.2384706437587738,-0.5576151609420776,-0.696761965751648,-0.4654664993286133,-0.6469441652297974,-0.13346783816814423,0.5714929103851318,-1.0807714462280273,-0.5941762924194336,-1.3740170001983643,-1.0965321063995361,-0.7143769860267639,1.0981807708740234,-0.49589091539382935,-0.09186792373657227,-1.1476421356201172,0.101337730884552,0.6357796788215637],"probs":[0.0896482765674591,0.02452460117638111,0.01358088944107294,0.01151671539992094,0.009984705597162247,0.009159623645246029,0.01116869691759348,0.009455881081521511,0.08142106235027313,0.013861285522580147,0.027413325384259224,0.01228755060583353,0.017793379724025726,0.01076054759323597,0.007751185912638903,0.006733361165970564,0.00480844359844923,0.018594473600387573,0.01074046827852726,0.052048008888959885,0.06436557322740555,0.01849365234375,0.024154508486390114,0.017554784193634987,0.015274422243237495,0.019249308854341507,0.016054634004831314,0.026828743517398834,0.0542951337993145,0.010403790511190891,0.016924552619457245,0.007759552448987961,0.01024110522121191,0.015007720328867435,0.09193873405456543,0.018672479316592216,0.027968356385827065,0.009730832651257515,0.03392931446433067,0.05790022760629654]}],"systemone":{"model":"clef-tiny","answers":{"category":{"type":"choice","choice":"cat34","confidence":0.0919,"probabilities":{"cat00":0.0896,"cat01":0.0245,"cat02":0.0136,"cat03":0.0115,"cat04":0.01,"cat05":0.0092,"cat06":0.0112,"cat07":0.0095,"cat08":0.0814,"cat09":0.0139,"cat10":0.0274,"cat11":0.0123,"cat12":0.0178,"cat13":0.0108,"cat14":0.0078,"cat15":0.0067,"cat16":0.0048,"cat17":0.0186,"cat18":0.0107,"cat19":0.052,"cat20":0.0644,"cat21":0.0185,"cat22":0.0242,"cat23":0.0176,"cat24":0.0153,"cat25":0.0192,"cat26":0.0161,"cat27":0.0268,"cat28":0.0543,"cat29":0.0104,"cat30":0.0169,"cat31":0.0078,"cat32":0.0102,"cat33":0.015,"cat34":0.0919,"cat35":0.0187,"cat36":0.028,"cat37":0.0097,"cat38":0.0339,"cat39":0.0579}}},"usage":{"input_tokens":1376,"output_tokens":0}}},+ {"name":"many_questions","state":"The invoice from Acme for 1250 USD is overdue by twenty days.","questions":{"q1":{"type":"noul","instructions":"Is it overdue?"},"q2":{"type":"choice","instructions":"Who sent it?","criteria":{"Acme":null,"Globex":null,"Initech":null}},"q3":{"type":"score","instructions":"How late?","criteria":["on time","late","very late"]},"q4":{"type":"noul","instructions":"Is the amount above 1000?"},"größe":{"type":"choice","instructions":"Size?","criteria":{"small":"below 100","large":"above 1000"}},"q6":{"type":"noul","instructions":"Is it in EUR?"},"q7":{"type":"score","instructions":"Risk?","criteria":["low","high"]},"q8":{"type":"choice","instructions":"Next step?","criteria":{"pay":"pay it","dispute":"dispute it"}}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,314,306,390,294,284,109,32,65,99,109,101,294,330,32,49,50,53,48,32,85,83,68,278,263,389,292,121,257,119,282,121,293,300,115,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,32,113,49,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,32,105,116,263,389,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,113,50,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,111,267,282,32,105,116,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,111,276,315,268,65,99,109,101,296,10,349,32,50,58,32,291,111,276,315,268,71,303,98,101,120,296,10,349,32,51,58,32,291,111,276,315,268,73,110,105,116,101,318,296,10,69,78,68,336,10,10,312,32,51,10,73,68,58,32,113,51,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,72,380,32,108,317,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,258,257,105,109,101,287,111,276,315,268,48,296,10,349,32,50,58,32,291,359,268,108,317,287,111,276,315,268,49,296,10,349,32,51,58,32,291,359,268,118,256,121,32,108,317,287,111,276,315,268,50,296,10,69,78,68,336,10,10,312,32,52,10,73,68,58,32,113,52,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,280,398,109,331,110,116,398,98,111,118,101,32,49,48,48,48,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,53,10,73,68,58,32,103,114,195,182,195,159,101,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,83,105,122,101,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,97,98,111,118,101,32,49,48,48,48,287,111,276,315,268,108,316,103,101,296,10,349,32,50,58,32,291,359,268,98,101,303,119,32,49,48,48,287,111,276,315,268,115,109,275,108,296,10,69,78,68,336,10,10,312,32,54,10,73,68,58,32,113,54,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,32,105,116,306,394,85,82,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,312,32,55,10,73,68,58,32,113,55,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,82,271,107,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,303,119,287,111,276,315,268,48,296,10,349,32,50,58,32,291,359,268,104,105,103,104,287,111,276,315,268,49,296,10,69,78,68,336,10,10,312,32,56,10,73,68,58,32,113,56,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,78,101,120,116,341,101,112,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,100,271,112,117,116,101,32,105,116,287,111,276,315,268,100,271,112,117,116,101,296,10,349,32,50,58,32,291,359,268,112,300,32,105,116,287,111,276,315,268,112,300,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"q1","type":0,"question_span":[155,163],"option_spans":[[180,203],[209,230]],"option_ids":["true","false"],"logits":[1.0047773122787476,0.9024161100387573],"probs":[0.5255680084228516,0.4744320213794708]},{"id":"q2","type":1,"question_span":[266,275],"option_spans":[[292,302],[308,319],[325,337]],"option_ids":["Acme","Globex","Initech"],"logits":[1.0174649953842163,1.0283340215682983,0.9106370806694031],"probs":[0.34368881583213806,0.3474447727203369,0.30886638164520264]},{"id":"q3","type":2,"question_span":[374,380],"option_spans":[[397,412],[418,430],[436,452]],"option_ids":["0","1","2"],"logits":[2.0957906246185303,0.7521307468414307,1.1595127582550049],"probs":[0.6049703359603882,0.157830148935318,0.23719950020313263]},{"id":"q4","type":0,"question_span":[488,507],"option_spans":[[524,547],[553,574]],"option_ids":["true","false"],"logits":[1.2415893077850342,1.2569446563720703],"probs":[0.49616125226020813,0.5038387775421143]},{"id":"größe","type":1,"question_span":[615,620],"option_spans":[[637,660],[666,687]],"option_ids":["large","small"],"logits":[0.08964240550994873,0.613842248916626],"probs":[0.3718706965446472,0.6281293034553528]},{"id":"q6","type":0,"question_span":[723,733],"option_spans":[[750,773],[779,800]],"option_ids":["true","false"],"logits":[1.3396525382995605,1.3125512599945068],"probs":[0.50677490234375,0.49322509765625]},{"id":"q7","type":2,"question_span":[837,841],"option_spans":[[858,870],[876,890]],"option_ids":["0","1"],"logits":[2.0465445518493652,1.5347025394439697],"probs":[0.6252381801605225,0.37476181983947754]},{"id":"q8","type":1,"question_span":[926,934],"option_spans":[[951,975],[981,997]],"option_ids":["dispute","pay"],"logits":[1.1696217060089111,1.4007686376571655],"probs":[0.44246920943260193,0.5575308203697205]}],"systemone":{"model":"clef-tiny","answers":{"q1":{"type":"noul","noul":0.5256},"q2":{"type":"choice","choice":"Globex","confidence":0.3474,"probabilities":{"Acme":0.3437,"Globex":0.3474,"Initech":0.3089}},"q3":{"type":"score","score":0.6322,"confidence":0.605,"legend":{"0":"on time","1":"late","2":"very late"},"probabilities":{"0":0.605,"1":0.1578,"2":0.2372}},"q4":{"type":"noul","noul":0.4962},"größe":{"type":"choice","choice":"small","confidence":0.6281,"probabilities":{"small":0.6281,"large":0.3719}},"q6":{"type":"noul","noul":0.5068},"q7":{"type":"score","score":0.3748,"confidence":0.6252,"legend":{"0":"low","1":"high"},"probabilities":{"0":0.6252,"1":0.3748}},"q8":{"type":"choice","choice":"pay","confidence":0.5575,"probabilities":{"pay":0.5575,"dispute":0.4425}}},"usage":{"input_tokens":1035,"output_tokens":0}}},+ {"name":"single_option","state":"Anything at all.","questions":{"only":{"type":"choice","instructions":"Pick one.","criteria":{"yes":"the only label"}},"level":{"type":"score","instructions":"Rate it.","criteria":["the only level"]}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,65,110,121,116,104,302,32,272,32,275,108,46,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,32,258,373,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,80,270,107,32,258,101,46,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,116,259,32,258,373,32,108,97,98,323,287,111,276,315,268,121,265,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,283,118,323,10,84,89,80,69,58,267,99,111,273,10,73,78,351,82,85,67,313,58,32,82,317,32,105,116,46,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,116,259,32,258,373,32,283,118,323,287,111,276,315,268,48,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"only","type":1,"question_span":[132,139],"option_spans":[[156,177]],"option_ids":["yes"],"logits":[1.1065205335617065],"probs":[1.0]},{"id":"level","type":2,"question_span":[215,221],"option_spans":[[238,257]],"option_ids":["0"],"logits":[1.1406850814819336],"probs":[1.0]}],"systemone":{"model":"clef-tiny","answers":{"only":{"type":"choice","choice":"yes","confidence":1.0,"probabilities":{"yes":1.0}},"level":{"type":"score","score":0.0,"confidence":1.0,"legend":{"0":"the only level"},"probabilities":{"0":1.0}}},"usage":{"input_tokens":295,"output_tokens":0}}},+ {"name":"empty_state","state":"","questions":{"empty":{"type":"noul","instructions":"Is there anything to read?"}},"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,399,109,112,116,121,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,308,256,101,286,121,116,104,302,342,295,352,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"empty","type":0,"question_span":[122,136],"option_spans":[[153,176],[182,203]],"option_ids":["true","false"],"logits":[1.499237298965454,1.178579568862915],"probs":[0.5794845819473267,0.4205155074596405]}],"systemone":{"model":"clef-tiny","answers":{"empty":{"type":"noul","noul":0.5795}},"usage":{"input_tokens":241,"output_tokens":0}}},+ {"name":"long_state_cut","state":"Hello team, I am writing again about the invoice we received on the first of the month. The amount is twice what we agreed in the contract and the payment was already taken. Hello team, I am writing again about the invoice we received on the first of the month. The amount is twice what we agreed in the contract and the payment was already taken. Hello team, I am writing again about the invoice we received on the first of the month. The amount is twice what we agreed in the contract and the payment was already taken. Hello team, I am writing again about the invoice we received on the first of the month. The amount is twice what we agreed in the contract and the payment was already taken. Hello team, I am writing again about the invoice we received on the first of the month. The amount is twice what we agreed in the contract and the payment was already taken. Hello team, I am writing again about the invoice we received on the first of the month. The amount is twice what we agreed in the contract and the payment was already taken. ","questions":{"department":{"type":"choice","instructions":"Which department should handle this request?","criteria":{"billing":"invoices, payments, refunds","technical":"bugs, outages, system errors","sales":"pricing, new contracts","other":"everything else"}},"legal":{"type":"noul","instructions":"Is there a legal threat?"}},"max_length":600,"input_ids":[418,115,121,115,116,101,109,10,82,360,280,274,377,112,283,116,101,414,405,267,358,109,97,46,393,101,99,288,101,399,118,256,121,409,32,106,111,260,116,373,46,394,299,104,339,401,388,292,101,399,120,354,373,32,258,101,263,102,308,272,409,39,115,32,275,303,119,322,263,276,115,46,419,10,418,387,10,351,65,84,69,58,10,72,323,303,257,101,97,109,44,337,398,109,338,290,116,302,32,353,97,260,398,98,331,116,280,306,390,416,295,99,101,105,118,322,32,258,280,294,105,114,115,116,263,102,280,401,258,116,104,46,32,314,398,109,331,110,116,278,257,119,301,338,104,272,416,32,353,273,322,306,280,274,258,335,354,405,280,410,338,97,115,32,275,273,352,121,257,97,107,269,46,32,72,323,303,257,101,97,109,44,337,398,109,338,290,116,302,32,353,97,260,398,98,331,116,280,306,390,416,295,99,101,105,118,322,32,258,280,294,105,114,115,116,263,102,280,401,258,116,104,46,32,314,398,109,331,110,116,278,257,119,301,338,104,272,416,32,353,273,322,306,10,10,350,336,83,58,10,10,312,32,49,10,73,68,58,293,101,112,356,328,10,84,89,80,69,58,274,104,329,10,73,78,351,82,85,67,313,58,32,87,104,270,104,293,101,112,356,328,267,104,331,108,100,32,104,264,100,283,415,413,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,260,118,111,270,265,44,410,115,44,412,115,287,111,276,315,268,98,372,302,296,10,349,32,50,58,32,291,359,268,101,118,256,121,116,104,302,32,323,333,287,111,276,315,268,111,116,104,256,296,10,349,32,51,58,32,291,359,268,112,114,270,302,44,32,110,101,119,274,258,335,354,115,287,111,276,315,268,115,275,265,296,10,349,32,52,58,32,291,359,268,98,117,103,115,44,263,117,116,353,265,44,267,121,115,116,101,109,400,287,111,276,315,268,116,101,318,110,270,275,296,10,69,78,68,336,10,10,312,32,50,10,73,68,58,32,283,103,275,10,84,89,80,69,58,402,117,108,10,73,78,351,82,85,67,313,58,32,73,115,308,256,101,398,32,283,103,275,308,273,272,63,10,65,76,76,79,87,69,68,396,83,58,10,349,32,49,58,32,291,359,268,314,411,278,257,114,304,307,280,339,278,404,265,343,111,276,315,268,335,304,296,10,349,32,50,58,32,291,359,268,314,411,278,294,355,307,280,339,278,402,343,111,276,315,268,102,355,296,10,69,78,68,336,10,10,419,10,418,97,115,115,271,116,264,116,10,441,10,10,442,10,10,74,79,73,78,84,397,393,69,67,73,83,298,83,58],"answers":[{"id":"department","type":1,"question_span":[282,304],"option_spans":[[321,344],[350,373],[379,405],[411,444]],"option_ids":["billing","other","sales","technical"],"logits":[-0.44217559695243835,-1.297737956047058,0.08732625097036362,-0.6363812685012817],"probs":[0.2533814311027527,0.10769827663898468,0.4302635192871094,0.20865671336650848]},{"id":"legal","type":0,"question_span":[481,495],"option_spans":[[512,535],[541,562]],"option_ids":["true","false"],"logits":[-0.16828002035617828,0.7156999111175537],"probs":[0.29235371947288513,0.7076462507247925]}],"systemone":{"model":"clef-tiny","answers":{"department":{"type":"choice","choice":"sales","confidence":0.4303,"probabilities":{"billing":0.2534,"technical":0.2087,"sales":0.4303,"other":0.1077}},"legal":{"type":"noul","noul":0.2924}},"usage":{"input_tokens":600,"output_tokens":0}}},+ {"name":"schema_too_long","state":"Too many options for the budget.","questions":{"bucket":{"type":"choice","instructions":"Pick one.","criteria":{"option0":"the description of option 0","option1":"the description of option 1","option2":"the description of option 2","option3":"the description of option 3","option4":"the description of option 4","option5":"the description of option 5","option6":"the description of option 6","option7":"the description of option 7","option8":"the description of option 8","option9":"the description of option 9","option10":"the description of option 10","option11":"the description of option 11","option12":"the description of option 12","option13":"the description of option 13","option14":"the description of option 14","option15":"the description of option 15","option16":"the description of option 16","option17":"the description of option 17","option18":"the description of option 18","option19":"the description of option 19","option20":"the description of option 20","option21":"the description of option 21","option22":"the description of option 22","option23":"the description of option 23","option24":"the description of option 24","option25":"the description of option 25","option26":"the description of option 26","option27":"the description of option 27","option28":"the description of option 28","option29":"the description of option 29","option30":"the description of option 30","option31":"the description of option 31","option32":"the description of option 32","option33":"the description of option 33","option34":"the description of option 34","option35":"the description of option 35","option36":"the description of option 36","option37":"the description of option 37","option38":"the description of option 38","option39":"the description of option 39"}}},"max_length":600,"error":"schema requires 1389 tokens before state; maximum is 600"}+ ]+}diff --git a/c/tests/test_clef_tiny.py b/c/tests/test_clef_tiny.pynew file mode 100644index 00000000..92e73030--- /dev/null+++ b/c/tests/test_clef_tiny.py@@ -0,0 +1,157 @@+"""qwen36's Clef path against Clef's own code, on the tiny fixture.++clef_tiny/ref.json holds what the checkpoint's joint_schema_model.py answered+(encode_record, collate_records, ClefModel, in f32, transformers 5.10.2) on the+checkpoint tools/make_clef_tiny.py writes: per case the input ids, the question+and option spans, the option order, the head's logits and the softmax, or the+refusal. tools/make_clef_ref.py wrote it, offline; this test needs neither torch+nor transformers.++Each case goes through the gateway's record builder in the raw form+(openai_server.systemone_decision_record(body, "raw"), what a POST /v1/systemone+sends an engine that asks for it) and the engine's record parser, and must come+back with:++ - the same input ids, exactly (rendering, tokenizer, the cut at max_length);+ - the same spans and the same option order (choice labels sorted, noul true+ first);+ - logits and probabilities within the tolerance ref.json states (f32 weights+ on both sides: the container holds the reference's F16 values exactly; the+ sums run in a different order, and the reference's DeltaNet is chunked where+ the engine's is recurrent);+ - the same decision on every question, and the same refusal.++The engine runs with COLI_DENSE_I8=0 (f32 dense weights) as every qwen36 oracle+does. Skipped when the fixture, its container or the binary is missing+(`make clef-tiny-check` builds all three and sets CLEF_TINY_REQUIRED=1, which+turns the skip into a failure).+"""+import hashlib+import json+import os+import re+import subprocess+import sys+import tempfile+import unittest+from pathlib import Path++HERE = Path(__file__).resolve().parent.parent+sys.path.insert(0, str(HERE))+from openai_server import systemone_decision_record # noqa: E402++FIXTURE = HERE / "clef_tiny"+CONTAINER = HERE / "clef_tiny_c"+BINARY = HERE / ("qwen36.exe" if os.name == "nt" else "qwen36")+REQUIRED = os.environ.get("CLEF_TINY_REQUIRED") == "1"+++def sha256(path):+ return hashlib.sha256(path.read_bytes()).hexdigest()+++def clef_ready():+ return ((FIXTURE / "ref.json").exists() and (CONTAINER / "joint_head.safetensors").exists()+ and BINARY.exists())+++def engine_env(**extra):+ return dict(os.environ, SNAP=str(CONTAINER), COLI_DENSE_I8="0", OMP_NUM_THREADS="2",+ COLI_NO_OMP_TUNE="1", **extra)+++def run_engine(**extra):+ result = subprocess.run([str(BINARY), "8", "8"], capture_output=True, text=True,+ encoding="utf-8", env=engine_env(**extra), timeout=600)+ if result.returncode:+ raise AssertionError(result.stderr[-3000:])+ return result.stdout+++class ClefTinyOracle(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ if not clef_ready():+ message = "clef_tiny, clef_tiny_c or qwen36 missing: run make clef-tiny-check"+ if REQUIRED:+ raise AssertionError(message)+ raise unittest.SkipTest(message)+ cls.ref = json.loads((FIXTURE / "ref.json").read_text(encoding="utf-8"))+ for name, digest in cls.ref["fixture_sha256"].items():+ if sha256(FIXTURE / name) != digest:+ raise AssertionError(f"clef_tiny/{name} is not the file ref.json was computed on; "+ "regenerate it with make clef-tiny-generate (or the reference "+ "with tools/make_clef_ref.py if the generator changed)")++ def test_tokenizer_matches_the_reference(self):+ strings = [entry["text"] for entry in self.ref["tokenizer"]]+ with tempfile.TemporaryDirectory() as tmp:+ path = Path(tmp) / "strings.json"+ path.write_text(json.dumps(strings, ensure_ascii=False), encoding="utf-8")+ got = json.loads(run_engine(CLEF_TOKENIZE=str(path)))+ self.assertEqual(len(got), len(strings))+ for entry, ids in zip(self.ref["tokenizer"], got):+ self.assertEqual(ids, entry["ids"], f"tokenizer: {entry['text']!r}")++ def run_cases(self, cases, max_length=None):+ records = [{"payload": json.dumps(systemone_decision_record(+ {"state": case["state"], "questions": case["questions"]}, "raw"), ensure_ascii=False)}+ for case in cases]+ extra = {"CLEF_RECORDS": "", "CLEF_IDS": "1"}+ if max_length:+ extra["COLI_CLEF_MAX_LEN"] = str(max_length)+ with tempfile.TemporaryDirectory() as tmp:+ path = Path(tmp) / "records.json"+ path.write_text(json.dumps(records, ensure_ascii=False), encoding="utf-8")+ extra["CLEF_RECORDS"] = str(path)+ lines = run_engine(**extra).splitlines()+ self.assertEqual(len(lines), len(cases))+ return [json.loads(line) for line in lines]++ def test_every_case_matches_the_reference(self):+ tol = self.ref["tolerance"]+ groups = {}+ for case in self.ref["cases"]:+ groups.setdefault(case.get("max_length"), []).append(case)+ worst = {"probs": 0.0, "logits": 0.0}+ decisions = 0+ for max_length, cases in groups.items():+ for case, got in zip(cases, self.run_cases(cases, max_length)):+ name = case["name"]+ if "error" in case:+ self.assertIn("error", got, f"{name}: the reference refused, the engine answered")+ # "schema requires N tokens before state; maximum is M", in the+ # engine's words and naming the field: the same two numbers+ self.assertTrue(got["error"].startswith("questions: "), got["error"])+ self.assertEqual(re.findall(r"\d+", got["error"]), re.findall(r"\d+", case["error"]), name)+ continue+ self.assertNotIn("error", got, f"{name}: {got.get('error')}")+ self.assertEqual(got["input_ids"], case["input_ids"], f"{name}: input ids")+ self.assertEqual(got["input_tokens"], len(case["input_ids"]), name)+ record = systemone_decision_record({"state": case["state"],+ "questions": case["questions"]}, "raw")+ self.assertEqual(len(got["answers"]), len(case["answers"]), name)+ for want, answer, span, question in zip(case["answers"], got["answers"], got["spans"],+ record["questions"]):+ where = f"{name}.{want['id']}"+ self.assertEqual(answer["id"], want["id"], where)+ self.assertEqual(span["type"], want["type"], where)+ self.assertEqual(span["question"], want["question_span"], f"{where}: question span")+ self.assertEqual(span["options"], want["option_spans"], f"{where}: option spans")+ labels = [option["label"] for option in question["options"]]+ order = [labels.index(option) for option in want["option_ids"]]+ self.assertEqual(span["order"], order, f"{where}: option order")+ for key in ("logits", "probs"):+ diff = max(abs(answer[key][i] - want[key][k]) for k, i in enumerate(order))+ worst[key] = max(worst[key], diff)+ self.assertLessEqual(diff, tol[key], f"{where}: {key} {answer[key]} vs {want[key]}")+ pick = max(range(len(order)), key=lambda k: want["probs"][k])+ mine = max(range(len(answer["probs"])), key=lambda i: answer["probs"][i])+ self.assertEqual(mine, order[pick], f"{where}: a different decision")+ decisions += 1+ sys.stderr.write(f"\n[clef tiny] {decisions} decisions identical; max |dp| {worst['probs']:.2e}, "+ f"max |dlogit| {worst['logits']:.2e}\n")+++if __name__ == "__main__":+ unittest.main()diff --git a/c/tools/make_clef_ref.py b/c/tools/make_clef_ref.pynew file mode 100644index 00000000..07e23ab9--- /dev/null+++ b/c/tools/make_clef_ref.py@@ -0,0 +1,311 @@+#!/usr/bin/env python3+"""Write clef_tiny/ref.json: what Clef's own code answers on the tiny fixture.++Maintainer-run, offline, once per change of the fixture: it needs torch,+transformers (the release was tested with 5.10.2) and the checkpoint's own+joint_schema_model.py (Cloudflare/clef), none of which CI installs. The+answers come from that file's encode_record, collate_records and ClefModel on+the checkpoint tools/make_clef_tiny.py writes, in f32; the SHA-256 of the+fixture and of joint_schema_model.py are recorded so tests/test_clef_tiny.py+refuses a fixture that differs.++The model is built the way load_release_model builds it (the backbone with+from_pretrained, the head with load_state_dict(strict=True), both in the same+dtype), with one difference: the tokenizer is AutoTokenizer's, not+AutoProcessor's, because AutoProcessor builds Qwen3VLVideoProcessor, which+needs torchvision. A text-only record never reaches the processor beyond its+tokenizer (encode_record's _encode_media returns early), so the answers are+the same. systemone() is run on every case as well and its rounded answer is+checked against the unrounded one before anything is written.++For every case it records the input ids, the question and option spans, the+option ids in the reference's order, the head's logits and the softmax, and+the error text for a case the reference refuses. Every decision is checked+for a near-tie, so a float-level difference cannot flip an argmax in the test.++ python tools/make_clef_tiny.py --output ./clef_tiny+ python tools/make_clef_ref.py --fixture ./clef_tiny --code ~/clef/joint_schema_model.py+"""++import argparse+import hashlib+import importlib.util+import json+import sys+from pathlib import Path+from types import SimpleNamespace++PINNED_TRANSFORMERS = "5.10.2"+MIN_GAP = 1e-3+SHORT = 600 # max_length of the cases that test the cut and the refusal++LONG = ("Hello team, I am writing again about the invoice we received on the first of the month. "+ "The amount is twice what we agreed in the contract and the payment was already taken. ") * 6++DEPARTMENT = {"type": "choice", "instructions": "Which department should handle this request?",+ "criteria": {"billing": "invoices, payments, refunds",+ "technical": "bugs, outages, system errors",+ "sales": "pricing, new contracts", "other": "everything else"}}++CASES = [+ ("model_card_invoice",+ {"invoice": {"vendor": "Acme", "total": 1250.0, "currency": "USD", "status": "overdue"}},+ {"status": {"type": "choice", "instructions": "What is the invoice status?",+ "criteria": {"paid": "Invoice is paid.", "overdue": "Invoice is past due.",+ "draft": "Not sent."}},+ "large": {"type": "noul", "instructions": "Is the total above 1000 USD?"}}, None),+ ("model_card_systemone", "Our checkout started returning errors and orders are blocked.",+ {"department": {"type": "choice", "instructions": "Which team should handle the message?",+ "criteria": {"billing": "Payments or invoices", "technical": "Bugs or outages"}},+ "urgency": {"type": "score", "criteria": ["Can wait", "This week", "Today"]},+ "outage": {"type": "noul", "instructions": "Is a service down?"}}, None),+ ("ticket_four_questions",+ {"from": "[email protected]", "subject": "Duplicate charge on invoice #4411",+ "body": "Hi, we were billed twice for March. Please refund the duplicate today or we will "+ "cancel our plan."},+ {"department": DEPARTMENT,+ "urgency": {"type": "score", "instructions": "How urgent is this request?",+ "criteria": ["not urgent", "soon", "critical deadline or blocking issue"]},+ "churn_risk": {"type": "noul", "instructions": "Does the user threaten to cancel or leave?"},+ "refund": {"type": "noul", "instructions": "Is a refund requested?",+ "criteria": {"true": "the customer asks for money back",+ "false": "no refund is mentioned"}}}, None),+ ("choice_descriptions", "We would like a demo of the product next week.",+ {"intent": {"type": "choice", "instructions": "What does the sender want?",+ "criteria": {"Zeta": "a product demonstration", "alpha": None, "Beta": "",+ "émigré": {"k": [1, 2.5, {"z": None, "a": True}], "b": "x"},+ "中文": 3, "quote\"d": ["x", "y"],+ "back\\slash": "tab\there\nnewline \"quoted\""}}}, None),+ ("scores", "This is the worst service I have ever used, nothing works.",+ {"sentiment": {"type": "score", "instructions": "What is the tone?",+ "criteria": ["angry", None, "neutral", {"label": "positive", "w": 1}, "delighted"]},+ "two_levels": {"type": "score", "instructions": "Is any action needed?",+ "criteria": ["no action", "action needed"]},+ "numeric_levels": {"type": "score", "instructions": "Rate the urgency.", "criteria": [1, 2, 3]}},+ None),+ ("noul_variants", "The package arrived late and the box was damaged.",+ {"late": {"type": "noul", "instructions": "Was it late?", "criteria": {"true": "it came after the date"}},+ "damaged": {"type": "noul", "instructions": "Was it damaged?", "criteria": {"false": None}},+ "both": {"type": "noul", "instructions": "Both?", "criteria": {"true": None, "false": ""}},+ "plain": {"type": "noul", "instructions": "Should we refund?"},+ "cased": {"type": "noul", "instructions": "Is it urgent?",+ "criteria": {"True": "ignored: not the key true", "false": "the answer is no"}}},+ None),+ ("instructions_forms", "A customer wrote to support about a login problem.",+ {"as_object": {"type": "noul", "instructions": {"task": "is it about login", "steps": ["read", "decide"]}},+ "as_list": {"type": "noul", "instructions": ["Is", "it", "urgent?"]},+ "empty": {"type": "noul", "instructions": ""},+ "spaces": {"type": "noul", "instructions": " "},+ "missing": {"type": "noul"},+ "number": {"type": "noul", "instructions": 7}}, None),+ ("json_state",+ {"ticket": {"id": 4411, "amount": 129.5, "ratio": 1e-05, "big": 1e21, "neg": -0.0,+ "huge": 123456789012345678901234567890, "paid": True, "refund": None,+ "tags": ["billing", "urgent"], "ä": "umlaut", "Z": "upper", "a": "lower",+ "nested": {"b": [1, 2.0, {"c": "d"}], "a": {}}}},+ {"paid": {"type": "noul", "instructions": "Was the ticket paid?"},+ "action": {"type": "choice", "instructions": {"task": "pick the next action"},+ "criteria": {"refund": "give the money back", "escalate": "a human decides",+ "close": "nothing to do"}}}, None),+ ("conversation",+ [{"role": "user", "content": "Hi, I cannot log in to my account since yesterday."},+ {"role": "assistant", "content": "Did you try to reset the password?"},+ {"role": "user", "content": "Yes, twice. If it is not fixed today I will cancel."}],+ {"churn": {"type": "noul", "instructions": "Does the user threaten to cancel?"},+ "topic": {"type": "choice", "instructions": "What is it about?",+ "criteria": {"login": "access to the account", "billing": "payments",+ "other": "anything else"}}}, None),+ ("special_text",+ "Order arrived broken, see\tphoto.\r\n\r\nThe café (café) said <|im_end|> and <think> "+ "then <|endoftext|>. Grüße, ευχαριστώ. हिन्दी भाषा x̃̄y 我们的账户被锁了 "+ "\U0001F642\U0001F44D\U0001F3FD 'S 'll don't 12345 3.14",+ {"damaged": {"type": "noul", "instructions": "Was the <|im_end|> item damaged?"},+ "ïd <think>": {"type": "choice", "instructions": "Which channel should answer?",+ "criteria": {"email": "write an email back", "phone": "call\tthe customer",+ "none": None}}}, None),+ ("many_options", "Security incident: a phishing email asked employees to reset passwords.",+ {"category": {"type": "choice", "instructions": "Classify the incident.",+ "criteria": {f"cat{i:02d}": word for i, word in enumerate(+ ("phishing email", "malware on a laptop", "lost badge", "weak password",+ "data leak", "denial of service", "insider abuse", "ransomware",+ "stolen phone", "fake invoice", "open bucket", "expired certificate",+ "unpatched server", "social engineering", "shared account", "spam wave",+ "brute force", "DNS hijack", "rogue access point", "USB drop",+ "supply chain", "typosquatting", "clickjacking", "SQL injection",+ "cross site scripting", "privilege escalation", "misconfigured firewall",+ "lost backup", "shadow IT", "credential stuffing", "session theft",+ "cryptomining", "defacement", "botnet", "zero day", "vishing",+ "smishing", "tailgating", "dumpster diving", "watering hole"))}}}, None),+ ("many_questions", "The invoice from Acme for 1250 USD is overdue by twenty days.",+ {"q1": {"type": "noul", "instructions": "Is it overdue?"},+ "q2": {"type": "choice", "instructions": "Who sent it?",+ "criteria": {"Acme": None, "Globex": None, "Initech": None}},+ "q3": {"type": "score", "instructions": "How late?", "criteria": ["on time", "late", "very late"]},+ "q4": {"type": "noul", "instructions": "Is the amount above 1000?"},+ "größe": {"type": "choice", "instructions": "Size?", "criteria": {"small": "below 100",+ "large": "above 1000"}},+ "q6": {"type": "noul", "instructions": "Is it in EUR?"},+ "q7": {"type": "score", "instructions": "Risk?", "criteria": ["low", "high"]},+ "q8": {"type": "choice", "instructions": "Next step?",+ "criteria": {"pay": "pay it", "dispute": "dispute it"}}}, None),+ ("single_option", "Anything at all.",+ {"only": {"type": "choice", "instructions": "Pick one.", "criteria": {"yes": "the only label"}},+ "level": {"type": "score", "instructions": "Rate it.", "criteria": ["the only level"]}}, None),+ ("empty_state", "",+ {"empty": {"type": "noul", "instructions": "Is there anything to read?"}}, None),+ ("long_state_cut", LONG, {"department": DEPARTMENT,+ "legal": {"type": "noul", "instructions": "Is there a legal threat?"}},+ SHORT),+ ("schema_too_long", "Too many options for the budget.",+ {"bucket": {"type": "choice", "instructions": "Pick one.",+ "criteria": {f"option{i}": f"the description of option {i}" for i in range(40)}}},+ SHORT),+]++TOKENIZER_STRINGS = [+ "", " ", " ", " ", "\n\n", "\t", "a b c d", "Hello world", "Hello world\n\n x",+ "don't I'll we've they're she'd 'S 'T", "2026-10-03 3.14 1000000 12345678901",+ "café café Å Ω Å", "日本語のテキスト", "\U0001F642\U0001F44D\U0001F3FD",+ "a<|im_end|>b<think>c</think>", "<|endoftext|><|im_start|>", "tab\tand\r\nnewline\n",+ " leading spaces", "trailing spaces ", "mixed ,.;:!? punctuation!!! ... ???",+ "über straße Ελληνικά русский عربي हिन्दी", "x̃̄y ̀abc", "x" * 200,+ "{\"description\":\"The proposition is true or the answer is yes.\",\"option_id\":\"true\"}",+ "\nFIELD 1\nID: q\nTYPE: noul\nINSTRUCTION: ",+]+++def compact_json(ref):+ """One key per line at the top, one case or tokenizer string per line below."""+ def dump(value):+ return json.dumps(value, ensure_ascii=False, separators=(",", ":"))+ lines = ["{"]+ keys = list(ref)+ for i, key in enumerate(keys):+ tail = "," if i + 1 < len(keys) else ""+ value = ref[key]+ if isinstance(value, list):+ lines.append(f" {dump(key)}:[")+ lines.extend(f" {dump(item)}{',' if j + 1 < len(value) else ''}" for j, item in enumerate(value))+ lines.append(f" ]{tail}")+ else:+ lines.append(f" {dump(key)}:{dump(value)}{tail}")+ lines.append("}")+ return "\n".join(lines) + "\n"+++def sha256(path):+ digest = hashlib.sha256()+ with open(path, "rb") as handle:+ for block in iter(lambda: handle.read(1 << 20), b""):+ digest.update(block)+ return digest.hexdigest()+++def load_code(path):+ spec = importlib.util.spec_from_file_location("joint_schema_model", path)+ module = importlib.util.module_from_spec(spec)+ sys.modules["joint_schema_model"] = module # its dataclasses look themselves up there+ spec.loader.exec_module(module)+ return module+++def load_model(jsm, path, dtype):+ """load_release_model, but with AutoTokenizer for AutoProcessor (see above)."""+ import torch+ from safetensors.torch import load_file+ from transformers import AutoTokenizer, Qwen3_5ForConditionalGeneration+ # load_release_model passes device_map={"": device}, which needs accelerate;+ # without one the weights land on the CPU all the same+ backbone, info = Qwen3_5ForConditionalGeneration.from_pretrained(+ path, dtype=dtype, output_loading_info=True)+ loose = {key: value for key, value in info.items() if value and key != "error_msgs"}+ if loose:+ sys.exit(f"the fixture does not load cleanly into Qwen3_5ForConditionalGeneration: {loose}")+ backbone.config.use_cache = False+ head = jsm.JointSchemaHead(**json.loads((Path(path) / "joint_head_config.json").read_text()))+ head.load_state_dict(load_file(str(Path(path) / "joint_head.safetensors")), strict=True)+ head = head.to(device="cpu", dtype=dtype)+ tokenizer = AutoTokenizer.from_pretrained(path)+ return jsm.ClefModel(backbone, head).eval(), SimpleNamespace(tokenizer=tokenizer), torch+++def main():+ parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])+ parser.add_argument("--fixture", default="./clef_tiny")+ parser.add_argument("--code", required=True, help="the release's joint_schema_model.py")+ parser.add_argument("--allow-version", action="store_true",+ help=f"run with a transformers other than {PINNED_TRANSFORMERS}")+ args = parser.parse_args()+ import torch+ import transformers+ if transformers.__version__ != PINNED_TRANSFORMERS and not args.allow_version:+ sys.exit(f"transformers {transformers.__version__} is installed; the reference is pinned "+ f"to {PINNED_TRANSFORMERS}, the release's")+ torch.manual_seed(0)+ jsm = load_code(args.code)+ fixture = Path(args.fixture)+ model, processor, _ = load_model(jsm, str(fixture), torch.float32)+ tokenizer = processor.tokenizer+ cases, ties = [], []+ for name, state, questions, max_length in CASES:+ request = {"model": "clef-tiny", "state": state, "questions": questions}+ case = {"name": name, "state": state, "questions": questions}+ if max_length:+ case["max_length"] = max_length+ limit = max_length or 16384+ try:+ encoded = jsm.encode_record(tokenizer, request, max_length=limit, processor=processor)+ except ValueError as error:+ case["error"] = str(error)+ cases.append(case)+ print(f"{name}: refused ({error})", file=sys.stderr)+ continue+ batch = jsm.collate_records([encoded], tokenizer.pad_token_id, torch.device("cpu"))+ with torch.inference_mode():+ logits = model(batch)[0]+ reply = jsm.systemone(model, processor, request, max_length=limit)+ answers = []+ for question, question_logits in zip(encoded.questions, logits):+ probs = question_logits.float().softmax(-1)+ order = sorted(probs.tolist(), reverse=True)+ if len(order) > 1 and order[0] - order[1] < MIN_GAP:+ ties.append(f"{name}.{question.question_id}: top-2 gap {order[0] - order[1]:.2e}")+ got = reply["answers"][question.question_id]+ unrounded = dict(zip(question.option_ids, probs.tolist()))+ rounded = ({"true": got["noul"]} if got["type"] == "noul" else got["probabilities"])+ if any(abs(round(unrounded[key], 4) - value) > 1e-12 for key, value in rounded.items()):+ sys.exit(f"{name}.{question.question_id}: systemone() disagrees with the forward pass")+ answers.append({"id": question.question_id, "type": question.question_type,+ "question_span": list(question.question_span),+ "option_spans": [list(span) for span in question.option_spans],+ "option_ids": list(question.option_ids),+ "logits": [float(x) for x in question_logits.float()],+ "probs": [float(x) for x in probs]})+ case["input_ids"] = list(encoded.input_ids)+ case["answers"] = answers+ case["systemone"] = reply+ cases.append(case)+ print(f"{name}: {len(answers)} question(s), {len(encoded.input_ids)} tokens", file=sys.stderr)+ if ties:+ sys.exit("near-ties, change these cases or SEED:\n " + "\n ".join(ties))+ strings = [{"text": text, "ids": tokenizer(text, add_special_tokens=False).input_ids}+ for text in TOKENIZER_STRINGS]+ ref = {+ "generator": "tools/make_clef_ref.py",+ "reference": {"joint_schema_model.py": sha256(args.code), "torch": torch.__version__,+ "transformers": transformers.__version__, "dtype": "float32"},+ "fixture_sha256": {name: sha256(fixture / name) for name in (+ "model.safetensors", "joint_head.safetensors", "joint_head_config.json",+ "config.json", "tokenizer.json")},+ "tolerance": {"probs": 2e-5, "logits": 1e-4},+ "tokenizer": strings,+ "cases": cases,+ }+ (fixture / "ref.json").write_text(compact_json(ref), encoding="utf-8")+ print(f"wrote {fixture / 'ref.json'}: {len(cases)} cases, {len(strings)} tokenizer strings",+ file=sys.stderr)+ return 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/c/tools/make_clef_tiny.py b/c/tools/make_clef_tiny.pynew file mode 100644index 00000000..41974e10--- /dev/null+++ b/c/tools/make_clef_tiny.py@@ -0,0 +1,385 @@+#!/usr/bin/env python3+"""Generate the tiny Clef checkpoint used by tests/test_clef_tiny.py.++numpy-only and deterministic: CI regenerates it from SEED and gets byte-identical+files. The reference answers in clef_tiny/ref.json are NOT produced here: they+come from Clef's own joint_schema_model.py on transformers, run offline by+tools/make_clef_ref.py, so the engine and its oracle never share an author.++The fixture has the layout of the release (Cloudflare/clef) at toy widths:++ config.json Qwen3_5ForConditionalGeneration: the dense+ hybrid text model (3 Gated DeltaNet layers per+ attention layer, output-gated attention,+ partial interleaved M-RoPE) and a small ViT+ model.safetensors F16, every value exactly representable, so the+ container (convert_qwen36.py writes F16) holds+ the very weights the f32 reference runs+ joint_head_config.json the joint schema head: 2 routing layers, 4+ joint_head.safetensors decoder layers, as the release, at width 32+ tokenizer.json byte-level BPE trained here, with the release's+ normalizer (NFC), pre-tokenizer regex and added+ tokens (renumbered after the vocabulary)+ tokenizer_config.json the release's (Qwen2Tokenizer)++Then `tools/convert_qwen36.py --model clef_tiny --out clef_tiny_c --ebits 8`+turns it into the container the engine reads, head files included.+"""++import argparse+import json+import re+import struct+import sys+from pathlib import Path++import numpy as np++SEED = 20261003++HIDDEN = 64+LAYERS = 8+Q_HEADS, KV_HEADS, HEAD_DIM = 4, 1, 32+DN_KEY_HEADS, DN_VALUE_HEADS, DN_HEAD_DIM = 2, 4, 16+INTER = 128+VOCAB = 1024+MERGES = 600+HEAD = {"hidden_size": HIDDEN, "width": 32, "routing_layers": 2, "layers": 4,+ "heads": 4, "feedforward": 64}+VISION = {"depth": 1, "hidden_size": 32, "num_heads": 2, "intermediate_size": 64,+ "patch_size": 16, "spatial_merge_size": 2, "temporal_patch_size": 2,+ "in_channels": 3, "out_hidden_size": HIDDEN, "num_position_embeddings": 64}++# The release's added tokens, in its order (ids 248044..248076 there).+ADDED = [("<|endoftext|>", True), ("<|im_start|>", True), ("<|im_end|>", True),+ ("<|object_ref_start|>", True), ("<|object_ref_end|>", True), ("<|box_start|>", True),+ ("<|box_end|>", True), ("<|quad_start|>", True), ("<|quad_end|>", True),+ ("<|vision_start|>", True), ("<|vision_end|>", True), ("<|vision_pad|>", True),+ ("<|image_pad|>", True), ("<|video_pad|>", True), ("<tool_call>", False),+ ("</tool_call>", False), ("<|fim_prefix|>", False), ("<|fim_middle|>", False),+ ("<|fim_suffix|>", False), ("<|fim_pad|>", False), ("<|repo_name|>", False),+ ("<|file_sep|>", False), ("<tool_response>", False), ("</tool_response>", False),+ ("<think>", False), ("</think>", False), ("<|audio_start|>", True),+ ("<|audio_end|>", True), ("<tts_pad>", True), ("<tts_text_bos>", True),+ ("<tts_text_eod>", True), ("<tts_text_bos_single>", True), ("<|audio_pad|>", True)]++PRETOKENIZE = (r"(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+"+ r"[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+")++TOKENIZER_CONFIG = {+ "add_prefix_space": False, "audio_bos_token": "<|audio_start|>",+ "audio_eos_token": "<|audio_end|>", "audio_token": "<|audio_pad|>", "backend": "tokenizers",+ "bos_token": None, "clean_up_tokenization_spaces": False, "eos_token": "<|im_end|>",+ "errors": "replace", "image_token": "<|image_pad|>", "model_max_length": 262144,+ "pad_token": "<|endoftext|>", "split_special_tokens": False,+ "tokenizer_class": "Qwen2Tokenizer", "unk_token": None, "video_token": "<|video_pad|>",+ "vision_bos_token": "<|vision_start|>", "vision_eos_token": "<|vision_end|>"}++# What the merges are learned from: the prompt the reference renders, the JSON of+# options, and text in a few scripts, so a rendered record is a few hundred tokens.+CORPUS = """+Read the complete state and schema. Decide every field jointly. Each answer must be exactly one of that field's allowed options.+STATE: SCHEMA FIELDS: FIELD ID: TYPE: INSTRUCTION: ALLOWED OPTIONS: OPTION END FIELD JOINT SCHEMA DECISIONS:+{"description":"The proposition is true or the answer is yes.","option_id":"true"}+{"description":"The proposition is false or the answer is no.","option_id":"false"}+choice score noul option_id description criteria instructions state+Which department should handle this request? How urgent is this request? Is the invoice overdue?+Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan.+Our checkout started returning errors and orders are blocked. The payment provider is down.+billing technical sales other payments invoices refunds bugs outages errors pricing contracts+not urgent soon blocking critical deadline the user threatens to leave the customer is angry+{"invoice":{"currency":"USD","status":"overdue","total":1250.0,"vendor":"Acme"}}+{"role":"user","content":"I cannot log in to my account since yesterday."}+Buongiorno, la fattura è sbagliata. Grüße aus München. ευχαριστώ πολύ. 我们的账户被锁了。+"""+++def bytes_to_unicode():+ bs = (list(range(ord("!"), ord("~") + 1)) + list(range(ord("\xa1"), ord("\xac") + 1)) ++ list(range(ord("\xae"), ord("\xff") + 1)))+ cs = bs[:]+ n = 0+ for b in range(256):+ if b not in bs:+ bs.append(b)+ cs.append(256 + n)+ n += 1+ return dict(zip(bs, [chr(c) for c in cs]))+++def train_bpe(corpus, merges):+ """Plain BPE over word pieces, ties broken by the pair's text: the same merges+ on every platform. The pieces only have to be plausible; the tokenizer then+ splits with the release's own regex."""+ byte_map = bytes_to_unicode()+ words = {}+ for piece in re.findall(r" ?\w+| ?[^\s\w]+|\s+", corpus):+ symbols = tuple(byte_map[b] for b in piece.encode("utf-8"))+ words[symbols] = words.get(symbols, 0) + 1+ learned = []+ for _ in range(merges):+ counts = {}+ for symbols, freq in words.items():+ for pair in zip(symbols, symbols[1:]):+ counts[pair] = counts.get(pair, 0) + freq+ if not counts:+ break+ best = min(counts, key=lambda pair: (-counts[pair], pair))+ if counts[best] < 2:+ break+ learned.append(best)+ merged = {}+ for symbols, freq in words.items():+ out, i = [], 0+ while i < len(symbols):+ if i + 1 < len(symbols) and (symbols[i], symbols[i + 1]) == best:+ out.append(symbols[i] + symbols[i + 1])+ i += 2+ else:+ out.append(symbols[i])+ i += 1+ merged[tuple(out)] = merged.get(tuple(out), 0) + freq+ words = merged+ return byte_map, learned+++def build_tokenizer():+ byte_map, merges = train_bpe(CORPUS, MERGES)+ vocab = {}+ for b in range(256):+ vocab[byte_map[b]] = len(vocab)+ for left, right in merges:+ if left + right not in vocab:+ vocab[left + right] = len(vocab)+ added = []+ for content, special in ADDED:+ added.append({"id": len(vocab) + len(added), "content": content, "single_word": False,+ "lstrip": False, "rstrip": False, "normalized": False, "special": special})+ if added[-1]["id"] >= VOCAB:+ raise SystemExit(f"tokenizer needs {added[-1]['id'] + 1} ids, the model has {VOCAB}")+ tokenizer = {+ "version": "1.0", "truncation": None, "padding": None, "added_tokens": added,+ "normalizer": {"type": "NFC"},+ "pre_tokenizer": {"type": "Sequence", "pretokenizers": [+ {"type": "Split", "pattern": {"Regex": PRETOKENIZE}, "behavior": "Isolated",+ "invert": False},+ {"type": "ByteLevel", "add_prefix_space": False, "trim_offsets": True,+ "use_regex": False}]},+ "post_processor": {"type": "ByteLevel", "add_prefix_space": False, "trim_offsets": False,+ "use_regex": False},+ "decoder": {"type": "ByteLevel", "add_prefix_space": True, "trim_offsets": True,+ "use_regex": True},+ "model": {"type": "BPE", "dropout": None, "unk_token": None,+ "continuing_subword_prefix": "", "end_of_word_suffix": "", "fuse_unk": False,+ "byte_fallback": False, "ignore_merges": False,+ "vocab": vocab, "merges": [[left, right] for left, right in merges]},+ }+ return tokenizer, {entry["content"]: entry["id"] for entry in added}+++def model_config(ids):+ layer_types = ["full_attention" if i % 4 == 3 else "linear_attention" for i in range(LAYERS)]+ text = {+ "attention_bias": False, "attention_dropout": 0.0, "attn_output_gate": True,+ "bos_token_id": ids["<|endoftext|>"], "dtype": "float16",+ "eos_token_id": ids["<|endoftext|>"], "full_attention_interval": 4,+ "head_dim": HEAD_DIM, "hidden_act": "silu", "hidden_size": HIDDEN,+ "initializer_range": 0.02, "intermediate_size": INTER, "layer_types": layer_types,+ "linear_conv_kernel_dim": 4, "linear_key_head_dim": DN_HEAD_DIM,+ "linear_num_key_heads": DN_KEY_HEADS, "linear_num_value_heads": DN_VALUE_HEADS,+ "linear_value_head_dim": DN_HEAD_DIM, "mamba_ssm_dtype": "float32",+ "max_position_embeddings": 4096, "model_type": "qwen3_5_text",+ "mtp_num_hidden_layers": 0, "mtp_use_dedicated_embeddings": False,+ "num_attention_heads": Q_HEADS, "num_hidden_layers": LAYERS,+ "num_key_value_heads": KV_HEADS, "output_gate_type": "swish", "pad_token_id": None,+ "partial_rotary_factor": 0.25, "rms_norm_eps": 1e-06,+ # head_dim 32 x 0.25 = 8 rotary dims, four frequencies: [2, 1, 1] puts one on+ # every axis, as the release's [11, 11, 10] spreads its 32+ "rope_parameters": {"mrope_interleaved": True, "mrope_section": [2, 1, 1],+ "partial_rotary_factor": 0.25, "rope_theta": 10000000,+ "rope_type": "default"},+ "tie_word_embeddings": False, "use_cache": True, "vocab_size": VOCAB,+ }+ vision = dict(VISION, deepstack_visual_indexes=[], dtype="float16",+ hidden_act="gelu_pytorch_tanh", initializer_range=0.02,+ model_type="qwen3_5_vision")+ return {"architectures": ["Qwen3_5ForConditionalGeneration"], "dtype": "float16",+ "image_token_id": ids["<|image_pad|>"], "language_model_only": False,+ "model_type": "qwen3_5", "text_config": text, "tie_word_embeddings": False,+ "transformers_version": "5.10.2", "video_token_id": ids["<|video_pad|>"],+ "vision_config": vision, "vision_end_token_id": ids["<|vision_end|>"],+ "vision_start_token_id": ids["<|vision_start|>"]}+++def build_backbone(rng):+ d, tensors = HIDDEN, {}++ def normal(shape, scale):+ return (rng.standard_normal(shape) * scale).astype(np.float32)++ def put(name, array):+ tensors[name] = array.astype(np.float16)++ lm = "model.language_model."+ put(lm + "embed_tokens.weight", normal((VOCAB, d), 1.0))+ for i in range(LAYERS):+ p = f"{lm}layers.{i}."+ put(p + "input_layernorm.weight", normal(d, 0.1)) # applied as 1 + w+ put(p + "post_attention_layernorm.weight", normal(d, 0.1))+ if i % 4 == 3:+ q = Q_HEADS * HEAD_DIM+ put(p + "self_attn.q_proj.weight", normal((2 * q, d), 1.0 / np.sqrt(d))) # + output gate+ put(p + "self_attn.k_proj.weight", normal((KV_HEADS * HEAD_DIM, d), 1.0 / np.sqrt(d)))+ put(p + "self_attn.v_proj.weight", normal((KV_HEADS * HEAD_DIM, d), 1.0 / np.sqrt(d)))+ put(p + "self_attn.o_proj.weight", normal((d, q), 0.5 / np.sqrt(q)))+ put(p + "self_attn.q_norm.weight", normal(HEAD_DIM, 0.1))+ put(p + "self_attn.k_norm.weight", normal(HEAD_DIM, 0.1))+ else:+ key, value = DN_KEY_HEADS * DN_HEAD_DIM, DN_VALUE_HEADS * DN_HEAD_DIM+ conv = 2 * key + value+ put(p + "linear_attn.in_proj_qkv.weight", normal((conv, d), 1.0 / np.sqrt(d)))+ put(p + "linear_attn.in_proj_z.weight", normal((value, d), 1.0 / np.sqrt(d)))+ put(p + "linear_attn.in_proj_b.weight", normal((DN_VALUE_HEADS, d), 1.0 / np.sqrt(d)))+ put(p + "linear_attn.in_proj_a.weight", normal((DN_VALUE_HEADS, d), 1.0 / np.sqrt(d)))+ put(p + "linear_attn.conv1d.weight", normal((conv, 1, 4), 0.5))+ put(p + "linear_attn.dt_bias", normal(DN_VALUE_HEADS, 0.5))+ put(p + "linear_attn.A_log", np.log(rng.uniform(1.0, 8.0, DN_VALUE_HEADS)).astype(np.float32))+ put(p + "linear_attn.norm.weight", 1.0 + normal(DN_HEAD_DIM, 0.1))+ put(p + "linear_attn.out_proj.weight", normal((d, value), 0.5 / np.sqrt(value)))+ put(p + "mlp.gate_proj.weight", normal((INTER, d), 1.0 / np.sqrt(d)))+ put(p + "mlp.up_proj.weight", normal((INTER, d), 1.0 / np.sqrt(d)))+ put(p + "mlp.down_proj.weight", normal((d, INTER), 0.5 / np.sqrt(INTER)))+ put(lm + "norm.weight", normal(d, 0.1))+ put("lm_head.weight", normal((VOCAB, d), 1.0 / np.sqrt(d)))+ v, vh, vi = "model.visual.", VISION["hidden_size"], VISION["intermediate_size"]+ patch = VISION["in_channels"] * VISION["temporal_patch_size"] * VISION["patch_size"] ** 2+ put(v + "patch_embed.proj.weight", normal((vh, VISION["in_channels"], VISION["temporal_patch_size"],+ VISION["patch_size"], VISION["patch_size"]),+ 1.0 / np.sqrt(patch)))+ put(v + "patch_embed.proj.bias", normal(vh, 0.1))+ put(v + "pos_embed.weight", normal((VISION["num_position_embeddings"], vh), 0.5))+ for i in range(VISION["depth"]):+ b = f"{v}blocks.{i}."+ for norm in ("norm1", "norm2"):+ put(b + norm + ".weight", 1.0 + normal(vh, 0.1))+ put(b + norm + ".bias", normal(vh, 0.1))+ put(b + "attn.qkv.weight", normal((3 * vh, vh), 1.0 / np.sqrt(vh)))+ put(b + "attn.qkv.bias", normal(3 * vh, 0.1))+ put(b + "attn.proj.weight", normal((vh, vh), 1.0 / np.sqrt(vh)))+ put(b + "attn.proj.bias", normal(vh, 0.1))+ put(b + "mlp.linear_fc1.weight", normal((vi, vh), 1.0 / np.sqrt(vh)))+ put(b + "mlp.linear_fc1.bias", normal(vi, 0.1))+ put(b + "mlp.linear_fc2.weight", normal((vh, vi), 1.0 / np.sqrt(vi)))+ put(b + "mlp.linear_fc2.bias", normal(vh, 0.1))+ wide = vh * VISION["spatial_merge_size"] ** 2+ put(v + "merger.norm.weight", 1.0 + normal(vh, 0.1))+ put(v + "merger.norm.bias", normal(vh, 0.1))+ put(v + "merger.linear_fc1.weight", normal((wide, wide), 1.0 / np.sqrt(wide)))+ put(v + "merger.linear_fc1.bias", normal(wide, 0.1))+ put(v + "merger.linear_fc2.weight", normal((HIDDEN, wide), 1.0 / np.sqrt(wide)))+ put(v + "merger.linear_fc2.bias", normal(HIDDEN, 0.1))+ return tensors+++def build_head(rng):+ """JointSchemaHead's state dict, at scales where the prior, the cosine and the+ residual scorer all move the logits by a few units."""+ H, W, F = HEAD["hidden_size"], HEAD["width"], HEAD["feedforward"]+ tensors = {}++ def normal(shape, scale):+ return (rng.standard_normal(shape) * scale).astype(np.float32)++ def put(name, array):+ tensors[name] = np.asarray(array, dtype=np.float32).astype(np.float16)++ def norm(stem, n):+ put(stem + ".weight", 1.0 + normal(n, 0.1))+ put(stem + ".bias", normal(n, 0.1))++ def attention(stem):+ put(stem + ".in_proj_weight", normal((3 * W, W), 1.0 / np.sqrt(W)))+ put(stem + ".in_proj_bias", normal(3 * W, 0.1))+ put(stem + ".out_proj.weight", normal((W, W), 1.0 / np.sqrt(W)))+ put(stem + ".out_proj.bias", normal(W, 0.1))++ norm("hidden_norm", H)+ for name in ("memory_projection", "question_projection", "option_question_projection",+ "global_projection", "option_context_projection", "option_lexical_projection"):+ put(name + ".weight", normal((W, H), 1.0 / np.sqrt(H)))+ put("type_embedding.weight", normal((3, W), 0.5))+ for i in range(HEAD["routing_layers"]):+ stem = f"evidence_layers.{i}."+ norm(stem + "query_norm", W)+ norm(stem + "memory_norm", W)+ attention(stem + "attention")+ norm(stem + "feedforward_norm", W)+ put(stem + "feedforward.0.weight", normal((F, W), 1.0 / np.sqrt(W)))+ put(stem + "feedforward.0.bias", normal(F, 0.1))+ put(stem + "feedforward.3.weight", normal((W, F), 1.0 / np.sqrt(F)))+ put(stem + "feedforward.3.bias", normal(W, 0.1))+ norm("option_summary_norm", W)+ for i in range(HEAD["layers"]):+ stem = f"layers.{i}."+ attention(stem + "self_attn")+ attention(stem + "multihead_attn")+ put(stem + "linear1.weight", normal((F, W), 1.0 / np.sqrt(W)))+ put(stem + "linear1.bias", normal(F, 0.1))+ put(stem + "linear2.weight", normal((W, F), 1.0 / np.sqrt(F)))+ put(stem + "linear2.bias", normal(W, 0.1))+ for n in ("norm1", "norm2", "norm3"):+ norm(stem + n, W)+ norm("field_norm", W)+ norm("option_norm", W)+ put("residual_scorer.0.weight", normal((W, 4 * W), 1.0 / np.sqrt(4 * W)))+ put("residual_scorer.0.bias", normal(W, 0.1))+ put("residual_scorer.3.weight", normal((1, W), 3.0 / np.sqrt(W)))+ put("residual_scorer.3.bias", normal(1, 0.1))+ put("prior_logit_scale", np.array(np.log(6.0)))+ put("joint_logit_scale", np.array(np.log(4.0)))+ put("residual_gate", np.array(0.5))+ return tensors+++def write_safetensors(path, tensors):+ header, offset = {}, 0+ for name, array in tensors.items():+ dtype = {"float16": "F16", "float32": "F32"}[array.dtype.name]+ header[name] = {"dtype": dtype, "shape": list(array.shape),+ "data_offsets": [offset, offset + array.nbytes]}+ offset += array.nbytes+ header["__metadata__"] = {"format": "pt"}+ blob = json.dumps(header, separators=(",", ":")).encode()+ blob += b" " * ((-len(blob)) % 8)+ with open(path, "wb") as handle:+ handle.write(struct.pack("<Q", len(blob)))+ handle.write(blob)+ for array in tensors.values():+ handle.write(np.ascontiguousarray(array).view(np.uint8).tobytes())+++def write_json(path, value):+ path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")+++def main():+ parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])+ parser.add_argument("--output", default="./clef_tiny")+ args = parser.parse_args()+ out = Path(args.output)+ out.mkdir(parents=True, exist_ok=True)+ tokenizer, ids = build_tokenizer()+ write_json(out / "tokenizer.json", tokenizer)+ write_json(out / "tokenizer_config.json", TOKENIZER_CONFIG)+ write_json(out / "config.json", model_config(ids))+ write_json(out / "joint_head_config.json", HEAD)+ rng = np.random.default_rng(SEED)+ write_safetensors(out / "model.safetensors", build_backbone(rng))+ write_safetensors(out / "joint_head.safetensors", build_head(rng))+ print(f"wrote {out}: {len(tokenizer['model']['vocab'])} vocab entries, "+ f"{len(tokenizer['model']['merges'])} merges, {len(ids)} added tokens", file=sys.stderr)+ return 0+++if __name__ == "__main__":+ sys.exit(main())