| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -uo pipefail |
|
|
| cd "$(dirname "$0")/.." |
| ROOT=$(pwd) |
| export BERX_DATA="${BERX_DATA:-/scratch/user4/dai/dataset_unstop/dataset}" |
| export BERX_WORK="${BERX_WORK:-$ROOT/work}" |
| export BERX_EMB="${BERX_EMB:-/scratch/user4/dai/model-3/work/emb}" |
| export BERX_M4="${BERX_M4:-/scratch/user4/dai/model-4/work}" |
| export HF_HOME="${HF_HOME:-/scratch/user4/mtp/cache/huggingface}" |
| export TOKENIZERS_PARALLELISM=false |
| export OMP_NUM_THREADS="${OMP_NUM_THREADS:-8}" |
| export MKL_NUM_THREADS="${MKL_NUM_THREADS:-8}" |
| PYBIN="${PYBIN:-/home/user4/Jyo/DAI/er_pipeline/.venv/bin/python}" |
| |
| |
| |
| |
| PY="$PYBIN -u" |
| N="nice -n 19 ionice -c3" |
| SPLIT="${SPLIT:-test}" |
| L="$BERX_WORK/logs"; mkdir -p "$L" |
| STATUS="$L/status" |
| CE_MODEL="${CE_MODEL:-/scratch/user4/dai/model-3/work/ce_model_A}" |
|
|
| |
| |
| |
| |
| say() { echo "[$(date +%H:%M:%S)] $*" | tee -a "${TRACKLOG:-/dev/null}"; } |
| mark() { printf '%-28s %-9s %s\n' "$1" "$2" "$(date +%H:%M:%S)" >> "$STATUS"; } |
|
|
| |
| step() { |
| local name="$1" out="$2" log="$3"; shift 3 |
| if [ -n "$out" ] && [ -e "$out" ]; then say "SKIP $name (exists: $out)"; mark "$name" SKIP; return 0; fi |
| local try rc |
| for try in 1 2 3; do |
| say "RUN $name (attempt $try)" |
| |
| |
| |
| $N "$@" >> "$L/$log" 2>&1 |
| rc=$? |
| if [ $rc -eq 0 ]; then say "OK $name"; mark "$name" OK; return 0; fi |
| |
| if [ $rc -eq 3 ]; then say "GATE $name returned 3 (declined)"; mark "$name" GATE; return 3; fi |
| say "FAIL $name rc=$rc (see $L/$log)"; sleep 20 |
| done |
| mark "$name" FAILED; return 1 |
| } |
|
|
| "$PYBIN" -c 'import pandas, torch' 2>/dev/null || { echo "PYBIN=$PYBIN unusable"; exit 1; } |
| |
| |
| |
| printf '# ---- session %s TRACKS=%s |
| ' "$(date '+%H:%M:%S')" "${TRACKS:-12}" >> "$STATUS" |
| say "v2 pipeline starting. work=$BERX_WORK" |
|
|
| |
| track1() { |
| step prep_train "$BERX_WORK/prep/train/pool.parquet" t1_prep.log \ |
| $PY scripts/00_prepare.py --split train || return 1 |
| step prep_test "$BERX_WORK/prep/test/pool.parquet" t1_prep.log \ |
| $PY scripts/00_prepare.py --split test || return 1 |
| step m4_tables "$BERX_WORK/m4/test.parquet" t1_m4.log \ |
| $PY scripts/10_build_m4_table.py --split both || return 1 |
| step geo_test "$BERX_WORK/geo/equiv_test.json" t1_geo.log \ |
| $PY scripts/02_france_geo.py --split test --skip-validate || return 1 |
| step geo_train "$BERX_WORK/geo/equiv_train.json" t1_geo.log \ |
| $PY scripts/02_france_geo.py --split train --skip-validate || return 1 |
|
|
| |
| step rescore_fit "$BERX_WORK/rescore/gate.json" t1_fit.log \ |
| $PY scripts/11_rescore.py --mode train |
| local rc=$? |
| if [ $rc -eq 3 ]; then |
| say "GATE A declined: the new features do not beat model-4's own columns on a clean val." |
| say "Keeping the existing submission. Track 2 continues - it adds candidates, not features." |
| return 3 |
| fi |
| [ $rc -ne 0 ] && return 1 |
|
|
| step rescore_apply "$BERX_WORK/output_v2/matching_results.tsv" t1_apply.log \ |
| $PY scripts/11_rescore.py --mode test --bundle "$BERX_WORK/rescore/bundle.joblib" || return 1 |
| say "TRACK 1 COMPLETE - $BERX_WORK/output_v2/matching_results.tsv is shippable." |
| } |
|
|
| |
| track2() { |
| |
| |
| |
| step embed_name_s1 "$BERX_EMB/nameonly/${SPLIT}_s1/matrix.npy" t2_embed.log \ |
| env CUDA_VISIBLE_DEVICES=0 $PY scripts/08_embed.py --split "$SPLIT" \ |
| --view name --side s1 --out-channel nameonly || return 1 |
| step embed_name_pool "$BERX_EMB/nameonly/${SPLIT}_pool/matrix.npy" t2_embed.log \ |
| env CUDA_VISIBLE_DEVICES=0 $PY scripts/08_embed.py --split "$SPLIT" \ |
| --view name --side pool --out-channel nameonly --only-empty-address || return 1 |
| step retr_F4 "$BERX_WORK/retr/${SPLIT}_nameonly_s0of1.parquet" t2_retr.log \ |
| env CUDA_VISIBLE_DEVICES=0 $PY scripts/03_retrieve.py --split "$SPLIT" \ |
| --channel nameonly --k 20 --device cuda:0 || return 1 |
|
|
| |
| |
| step ename "$BERX_WORK/retr/${SPLIT}_ename_s0of1.parquet" t2_ename.log $PY scripts/13_ename.py --split "$SPLIT" --k 5 || return 1 |
|
|
| |
| |
| |
|
|
| step retr_e5small "$BERX_WORK/retr/${SPLIT}_e5_small_s0of1.parquet" t2_retr.log \ |
| env CUDA_VISIBLE_DEVICES=0 $PY scripts/03_retrieve.py --split "$SPLIT" \ |
| --channel e5_small --k 100 --device cuda:0 || return 1 |
|
|
| step new_pairs "$BERX_WORK/shards/${SPLIT}_manifest.json" t2_shard.log \ |
| $PY scripts/12_new_pairs.py --split "$SPLIT" --nshards 4 || return 1 |
| say "TRACK 2: shards ready. Upload them, then start the Colab lanes." |
| } |
|
|
| |
| |
| |
| TRACKS="${TRACKS:-12}" |
| R1=0; R2=0; T1=""; T2="" |
| |
| |
| |
| case "$TRACKS" in *1*) ( TRACKLOG="$L/track1.log"; track1 ) > "$L/track1.out" 2>&1 & T1=$!; echo $T1 > "$L/track1.pid";; esac |
| case "$TRACKS" in *2*) ( TRACKLOG="$L/track2.log"; track2 ) > "$L/track2.out" 2>&1 & T2=$!; echo $T2 > "$L/track2.pid";; esac |
| say "TRACKS=$TRACKS track1 pid=${T1:-skipped} track2 pid=${T2:-skipped}" |
| [ -n "$T1" ] && { wait $T1; R1=$?; rm -f "$L/track1.pid"; } |
| [ -n "$T2" ] && { wait $T2; R2=$?; rm -f "$L/track2.pid"; } |
| say "track1 rc=$R1 track2 rc=$R2" |
| say "status:"; cat "$STATUS" |
|
|