Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/docs/native/pi5-8/orchestrator-exam/run_exam.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / docs / native / pi5-8 / orchestrator-exam / run_exam.sh` 58 lines ยท 3552 bytes Raw Blame History 1 #!/bin/bash 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Run the orchestration exam on one GGUF with llama.cpp (greedy, the model's own chat template). 18 # usage: run_exam.sh [splits: "train dev heldout"] [modes: "free constrained"] 19 # env: LLAMA_BIN (llama-server dir, default ~/llama.cpp-build/build/bin) THREADS (default 8) 20 # TEMPLATE (a llama.cpp built-in template name; only for GGUFs that embed none, e.g. zephyr for TinyLlama) 21 # CPU=1 (default) hides the GPU so a busy shared GPU is never touched PORT (default derived from name) 22 # writes results/...jsonl : one record per case with the raw model text. 23 set -u 24 gguf=$1; name=$2; splits=${3:-"train dev heldout"}; modes=${4:-"free constrained"} 25 here=$(cd "$(dirname "$0")" && pwd) 26 bin=${LLAMA_BIN:-$HOME/llama.cpp-build/build/bin} 27 threads=${THREADS:-8} 28 port=${PORT:-$((20000 + $(printf '%s' "$name" | cksum | cut -d' ' -f1) % 20000))} 29 out="$here/results"; mkdir -p "$out" 30 [ "${CPU:-1}" = 1 ] && export CUDA_VISIBLE_DEVICES="" 31 export LD_LIBRARY_PATH="$bin:${LD_LIBRARY_PATH:-}" 32 tmpl=(); [ -n "${TEMPLATE:-}" ] && tmpl=(--chat-template "$TEMPLATE") 33 "$bin/llama-server" -m "$gguf" --port "$port" --host 127.0.0.1 -t "$threads" -c 4096 -ngl 0 --jinja "${tmpl[@]}" \ 34 --no-webui --log-disable >"$out/$name.server.log" 2>&1 & 35 srv=$! 36 trap 'kill $srv 2>/dev/null; wait $srv 2>/dev/null' EXIT 37 until curl -sf "http://127.0.0.1:$port/health" >/dev/null; do 38 kill -0 $srv 2>/dev/null || { echo "server died, see $out/$name.server.log" >&2; exit 1; } 39 sleep 1 40 done 41 sys=$(cat "$here/system_prompt.txt") 42 gram=$(cat "$here/grammar.gbnf") 43 for split in $splits; do 44 for mode in $modes; do 45 f="$out/$name.$split.$mode.jsonl"; : >"$f" 46 grep -v '^#' "$here/cases-$split.psv" | while IFS='|' read -r id cat act text turns; do 47 msgs=$(jq -cn --arg sys "$sys" --arg t "$turns" '[{role:"system",content:$sys}] + ($t|split(" ~~ ")|to_entries|map({role:(if .key%2==0 then "user" else "assistant" end),content:.value}))') 48 body=$(jq -cn --argjson m "$msgs" --arg g "$gram" --arg mode "$mode" \ 49 '{messages:$m,temperature:0,top_k:1,seed:1,max_tokens:96,cache_prompt:true,chat_template_kwargs:{enable_thinking:false}} + (if $mode=="constrained" then {grammar:$g} else {} end)') 50 t0=$(date +%s%N) 51 resp=$(curl -s "http://127.0.0.1:$port/v1/chat/completions" -H 'Content-Type: application/json' -d "$body") 52 ms=$(( ($(date +%s%N) - t0) / `1000000` )) 53 jq -cn --arg id "$id" --arg split "$split" --arg cat "$cat" --arg ea "$act" --arg et "$text" --argjson ms "$ms" --arg resp "$resp" \ 54 '($resp|fromjson? // {}) as $r | {id:$id,split:$split,cat:$cat,exp_action:$ea,exp_text:$et,ms:$ms,finish:($r.choices[0].finish_reason // "error"),raw:($r.choices[0].message.content // ""),ptok:($r.usage.prompt_tokens // 0),ctok:($r.usage.completion_tokens // 0)}' >>"$f" 55 done 56 echo "$name $split $mode: $(wc -l <"$f") cases" >&2 57 done 58 done