fund_rfid_data/watch_match.sh
Florian Herzog 991715ab76 Add LLM role-check grounding + labelled training-set pipeline
- llm_extract.py: match mode now window-parallel with retrieval pre-filter,
  claim dedup, retry, and enable_thinking=false (vLLM) -> ~36x faster per call;
  n_failed_windows/ok flags so an interrupted run never records bogus 0s.
- build_rdf_dataset.py:
  - gold now includes the share-class level (hasShareClass/ticker/className)
  - grounding modes alias|llm|name|context|none (--grounding); llm reads the
    role-check verdicts from match_all.jsonl
  - label stage: per-triple extractable + per-sample FULL/PARTIAL/NONE
  - trainset stage: combines GROUNDED triples with focused TEXT EXCERPTS cut
    around the actual provider statement (evidence), not the multi-MB book
  - split --src to split trainset.jsonl (trust-level, no leakage)
- helper scripts: watch_match.sh, resume_match.sh (crash/sleep-safe resume),
  finalize_dataset.sh
- final dataset: 335/335 trusts, 85% text<->gold agreement, 334 samples,
  10,689 grounded triples, train/val/test 264/35/35

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 13:52:50 +02:00

67 lines
2.8 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# ------------------------------------------------------------------
# watch_match.sh — Fortschritt des LLM-Match-Laufs ueberwachen
#
# bash watch_match.sh -> Dashboard, aktualisiert alle 15s (Strg-C beendet)
# bash watch_match.sh live -> rohes Log live mitlaufen (tail -f)
# bash watch_match.sh once -> einmaliger Stand, dann zurueck zur Shell
#
# Beendet nur die ANSICHT, nicht den Match-Lauf (der laeuft im Hintergrund).
# ------------------------------------------------------------------
LOG="/private/tmp/claude-501/-Users-florianherzog-development-AISE-Admin-Thesis--Florian-Code/745ff40e-0ecf-4430-886c-33fbc724df69/tasks/bfe2v693w.output"
OUT="data/rdf_poc/match_remaining.jsonl"
TOTAL=256
SERVER="http://silicon.fhgr.ch:7080/v1/models"
show_once () {
local done last errs srv tg tt
done=$(wc -l < "$OUT" 2>/dev/null | tr -d ' '); done=${done:-0}
last=$(grep -oE '\[[0-9]+/'"$TOTAL"'\]' "$LOG" 2>/dev/null | tail -1)
errs=$(grep -cE 'error|ERROR|Traceback' "$LOG" 2>/dev/null | tr -d ' ')
# Server erreichbar?
# 2 Versuche mit grosszuegigem Timeout: unter Last antwortet /v1/models
# langsamer, ein kurzes Timeout meldet faelschlich "nicht erreichbar".
if curl -s -m 20 "$SERVER" >/dev/null 2>&1 || curl -s -m 20 "$SERVER" >/dev/null 2>&1; then
srv="OK"; else srv="NICHT erreichbar (oder ausgelastet)"; fi
# bisherige Uebereinstimmung aus den fertigen Samples
read tg tt < <(python3 - "$OUT" <<'PY' 2>/dev/null
import json,sys
g=t=0
try:
for l in open(sys.argv[1]):
r=json.loads(l)
for x in r.get("triples",[]):
t+=1; g+=1 if x.get("llm_grounded") else 0
except FileNotFoundError: pass
print(g,t)
PY
)
tg=${tg:-0}; tt=${tt:-0}
local pct=0; [ "$tt" -gt 0 ] && pct=$((100*tg/tt))
local dpct=$((100*done/TOTAL))
printf "\n LLM-Match-Lauf\n"
printf " ------------------------------------------\n"
printf " Fortschritt : %d / %d Trusts (%d%%) letzte Logzeile: %s\n" "$done" "$TOTAL" "$dpct" "${last:-}"
printf " Tripel : %d von %d belegt (%d%% Uebereinstimmung bisher)\n" "$tg" "$tt" "$pct"
printf " Fehler/Log : %s\n" "${errs:-0}"
printf " vLLM-Server : %s\n" "$srv"
printf " ------------------------------------------\n"
}
case "${1:-dash}" in
live) echo "Live-Log (Strg-C beendet die Ansicht):"; exec tail -f "$LOG" ;;
once) show_once ;;
*)
echo "Dashboard aktualisiert alle 15s (Strg-C beendet die Ansicht, nicht den Lauf)"
while true; do
clear 2>/dev/null
show_once
done=$(wc -l < "$OUT" 2>/dev/null | tr -d ' ')
if grep -q "matched .* samples" "$LOG" 2>/dev/null; then
echo " FERTIG. $(grep 'matched .* samples' "$LOG" | tail -1)"
break
fi
sleep 15
done ;;
esac