v2-zeroshot driver
Browse files- v2-zeroshot/src/run.sh +50 -0
v2-zeroshot/src/run.sh
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Driver: build + audit (CPU) alongside a GPU smoke test, then train 3 stages, then the pinned MTEB eval.
|
| 3 |
+
# Every phase writes a marker, so a rerun resumes after the last finished phase.
|
| 4 |
+
set -uo pipefail
|
| 5 |
+
W=/workspace; M=$W/markers; mkdir -p $M $W/out
|
| 6 |
+
export PATH="$HOME/.local/bin:$PATH" HF_HOME=$W/.cache/huggingface UV_LINK_MODE=copy WANDB_PROJECT=code-embed
|
| 7 |
+
cd $W/code
|
| 8 |
+
note() {
|
| 9 |
+
echo "{\"note\": \"$1\", \"time\": \"$(date -u +%H:%M:%S)\"}" > $W/out/progress.json
|
| 10 |
+
cp -f $W/*.log $W/out/ 2>/dev/null
|
| 11 |
+
uv run --no-sync python -c "
|
| 12 |
+
from huggingface_hub import HfApi
|
| 13 |
+
HfApi().upload_folder(folder_path='$W/out', repo_id='divakantpandey/code-embed-v3-src', path_in_repo='v2-zeroshot/run',
|
| 14 |
+
allow_patterns=['*.json','*.log'], commit_message='v2-zeroshot: $1')" >/dev/null 2>&1 || echo "upload failed: $1"
|
| 15 |
+
}
|
| 16 |
+
fail() { note "FAILED $1"; exit 1; }
|
| 17 |
+
note "booted"
|
| 18 |
+
[ -x $W/evenv/bin/python ] || ( uv venv -q -p 3.12 $W/evenv && uv pip install -q -p $W/evenv "torch==2.6.0" "mteb==2.26.17" "sentence-transformers==6.2.0" "transformers==5.20.2" > $W/evenv.log 2>&1 ) &
|
| 19 |
+
EVENV=$!
|
| 20 |
+
if [ ! -f $M/data ]; then
|
| 21 |
+
( uv run --no-sync python $W/train_v2zs.py --smoke --out $W/out > $W/smoke.log 2>&1 && touch $M/smoke ) &
|
| 22 |
+
SMOKE=$!
|
| 23 |
+
uv run --no-sync ce3 build-data $W/v2_zeroshot.yaml > $W/build.log 2>&1 || fail build
|
| 24 |
+
note "built"
|
| 25 |
+
wait $SMOKE; [ -f $M/smoke ] || fail smoke
|
| 26 |
+
grep "SMOKE OK" $W/smoke.log > $W/out/smoke.txt
|
| 27 |
+
note "smoke ok"
|
| 28 |
+
uv run --no-sync ce3 audit $W/data/v2_zeroshot --no-external > $W/audit.log 2>&1 || fail audit
|
| 29 |
+
cp $W/data/v2_zeroshot/contamination_report.json $W/data/v2_zeroshot/manifest.json $W/out/ 2>/dev/null
|
| 30 |
+
touch $M/data; note "audited"
|
| 31 |
+
fi
|
| 32 |
+
if [ ! -f $M/train ]; then
|
| 33 |
+
uv run --no-sync python $W/train_v2zs.py --out $W/out >> $W/train.log 2>&1 || fail train
|
| 34 |
+
touch $M/train; note "trained"
|
| 35 |
+
fi
|
| 36 |
+
if [ ! -f $M/upload ]; then
|
| 37 |
+
uv run --no-sync python -c "
|
| 38 |
+
from huggingface_hub import HfApi
|
| 39 |
+
api = HfApi(); r = 'divakantpandey/code-embed-v2-zeroshot'
|
| 40 |
+
api.create_repo(r, private=True, exist_ok=True)
|
| 41 |
+
api.upload_folder(folder_path='$W/out/stage3', repo_id=r, commit_message='Zero-shot retrain of the code-embed-v2 recipe')" || fail upload
|
| 42 |
+
touch $M/upload; note "model uploaded"
|
| 43 |
+
fi
|
| 44 |
+
wait $EVENV
|
| 45 |
+
if [ ! -f $M/eval ]; then
|
| 46 |
+
note "eval started"
|
| 47 |
+
$W/evenv/bin/python $W/eval_v2zs.py $W/out/stage3 >> $W/eval.log 2>&1 || fail eval
|
| 48 |
+
touch $M/eval
|
| 49 |
+
fi
|
| 50 |
+
note "all done"
|