lCREEl commited on
Commit
e200e0d
·
verified ·
1 Parent(s): 1d6419c

Add evaluation-only diagnostic for recovery candidate

Browse files
Files changed (1) hide show
  1. training/check_recovery.sh +69 -0
training/check_recovery.sh ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ : "${HF_TOKEN:?기존 Colab의 HF_TOKEN을 설정하세요.}"
4
+ export HF_HUB_DISABLE_XET=1 HF_HUB_DISABLE_TELEMETRY=1 TOKENIZERS_PARALLELISM=false DCT_COMPILE=0
5
+ export PICK_TRAIN_ROOT="${PICK_TRAIN_ROOT:-/content/pick-recovery}"
6
+ PICK_PYTHON="$PICK_TRAIN_ROOT/.venv/bin/python3"
7
+ if [[ ! -x "$PICK_PYTHON" || ! -d "$PICK_TRAIN_ROOT/base-model" ]]; then
8
+ echo '학습을 완료한 기존 Colab 런타임에서 실행하세요. 평가 환경을 찾지 못했습니다.' >&2
9
+ exit 1
10
+ fi
11
+ "$PICK_PYTHON" - <<'PY'
12
+ import hashlib, json, os, shutil
13
+ from pathlib import Path
14
+ from huggingface_hub import HfApi, hf_hub_download
15
+ root=Path(os.environ['PICK_TRAIN_ROOT'])
16
+ repo='lCREEl/pick-v6-recovery'
17
+ revision='7f06104ea66066fae5bedc90e914bdd94e50e0a6'
18
+ assert HfApi().repo_info(repo).private, 'Diagnostic outputs must stay private'
19
+ expected='a723199fce99ca00495f87ad1304e822225af0adc7e9a16dd17916abe0c2a995'
20
+ checkpoint=root/'runs/frozen-head/latest.pt'
21
+ if not checkpoint.exists():
22
+ source=hf_hub_download(repo,'runs/frozen-head/latest.pt',revision=revision)
23
+ checkpoint.parent.mkdir(parents=True,exist_ok=True)
24
+ shutil.copyfile(source,checkpoint)
25
+ with checkpoint.open('rb') as handle:
26
+ assert hashlib.file_digest(handle,'sha256').hexdigest()==expected, 'Unexpected checkpoint'
27
+ manifest=json.loads((root/'base-model-manifest.json').read_text())
28
+ for name, sha in manifest.items():
29
+ with (root/'base-model'/name).open('rb') as handle:
30
+ assert hashlib.file_digest(handle,'sha256').hexdigest()==sha, name
31
+ print('V5와 600단계 후보 해시 검증 완료. 별도 312문항 진단 평가를 시작합니다.',flush=True)
32
+ PY
33
+ "$PICK_PYTHON" "$PICK_TRAIN_ROOT/scripts/run_pilot.py" \
34
+ --export "$PICK_TRAIN_ROOT/base-model" --device cuda --eval-only --confirm \
35
+ --name frozen-head-diagnostic-v5
36
+ "$PICK_PYTHON" "$PICK_TRAIN_ROOT/scripts/run_pilot.py" \
37
+ --export "$PICK_TRAIN_ROOT/base-model" --device cuda --eval-only --confirm \
38
+ --checkpoint "$PICK_TRAIN_ROOT/runs/frozen-head/latest.pt" \
39
+ --name frozen-head-diagnostic-candidate
40
+ "$PICK_PYTHON" - <<'PY'
41
+ import json, os, tempfile
42
+ from pathlib import Path
43
+ from huggingface_hub import HfApi
44
+ root=Path(os.environ['PICK_TRAIN_ROOT'])/'runs'
45
+ names=['frozen-head-diagnostic-v5','frozen-head-diagnostic-candidate']
46
+ base, candidate=[json.loads((root/name/'confirm.json').read_text()) for name in names]
47
+ assert [r['id'] for r in base['records']]==[r['id'] for r in candidate['records']]
48
+ deltas={task:100*(candidate['per_task'][task]['score']-values['score'])
49
+ for task,values in base['per_task'].items()}
50
+ report=dict(status='diagnostic_only',original_development_decision='discard',
51
+ baseline_proxy=base['proxy_score'],candidate_proxy=candidate['proxy_score'],
52
+ delta=candidate['proxy_score']-base['proxy_score'],per_task_delta_points=deltas,
53
+ worst_anchor_delta_points=min(deltas[t] for t in ['banking','clinc','home']),
54
+ public_index=None,
55
+ note='Separate diagnostic after a failed development gate. Does not promote the candidate or change submitted V5.')
56
+ out=root/'frozen-head-diagnostic';out.mkdir(exist_ok=True)
57
+ (out/'summary.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n')
58
+ # Upload only diagnostic JSONs, in one commit. Preserve original decision and checkpoint.
59
+ with tempfile.TemporaryDirectory() as staging:
60
+ for name in names+['frozen-head-diagnostic']:
61
+ target=Path(staging)/name;target.mkdir()
62
+ for path in (root/name).glob('*.json'):
63
+ (target/path.name).write_bytes(path.read_bytes())
64
+ api=HfApi();assert api.repo_info('lCREEl/pick-v6-recovery').private
65
+ api.upload_folder(repo_id='lCREEl/pick-v6-recovery',folder_path=staging,
66
+ path_in_repo='runs',commit_message='Record diagnostic confirmation; preserve development discard')
67
+ print(json.dumps(report,ensure_ascii=False,indent=2),flush=True)
68
+ print('진단 결과 HF 백업 완료. 추가 학습 없이 종료했습니다.',flush=True)
69
+ PY