variant support: WISE_ALPHA, EMB_DIR/OUT_PREFIX
Browse files
code/hf_jobs/dense_ft_retrieval.sh
CHANGED
|
@@ -5,6 +5,7 @@
|
|
| 5 |
# and test when encode B (t1,t2,t3) is done; only that split's arrays are downloaded.
|
| 6 |
set -uo pipefail
|
| 7 |
SPLITS=${SPLITS:-train test}; export SPLITS
|
|
|
|
| 8 |
ROOT=/workspace/amlc; mkdir -p $ROOT/hub $ROOT/dense $ROOT/raw; cd $ROOT
|
| 9 |
log(){ echo "[$(date -u +%H:%M:%S) UTC] $*"; }
|
| 10 |
log deps; pip install -q pandas pyarrow polars huggingface_hub 2>&1 | tail -1; nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
|
|
@@ -13,14 +14,14 @@ import os, time
|
|
| 13 |
from huggingface_hub import snapshot_download
|
| 14 |
t=time.time()
|
| 15 |
tabs=[x for sp in os.environ['SPLITS'].split() for x in {'train':['s1','s2','s3'],'test':['t1','t2','t3']}[sp]]
|
| 16 |
-
pats=['code/scripts/dense_retrieval.py']+[f'norm/{x}.parquet' for x in tabs]+[f'
|
| 17 |
print('downloading', pats, flush=True)
|
| 18 |
snapshot_download('Arushhh/amlc-work', repo_type='dataset', local_dir='/workspace/amlc/hub', allow_patterns=pats, token=os.environ.get('HF_TOKEN'), max_workers=16)
|
| 19 |
if 'train' in os.environ['SPLITS'].split():
|
| 20 |
snapshot_download('Anupam-Rawat-IITB/data_', repo_type='dataset', local_dir='/workspace/amlc/raw', allow_patterns=['dataset/train/train_ground_truth.tsv'])
|
| 21 |
print('downloaded', f'{time.time()-t:.0f}s', flush=True)
|
| 22 |
PY
|
| 23 |
-
ln -sfn $ROOT/hub/
|
| 24 |
for sp in $SPLITS; do [ $sp = train ] && T="s1 s2 s3" || T="t1 t2 t3"
|
| 25 |
for x in $T; do for f in $ROOT/hub/emb/e5_full/$x.npy $ROOT/hub/emb/e5_name/$x.npy $ROOT/hub/norm/$x.parquet; do [ -s "$f" ] || { log "FATAL missing $f"; exit 1; }; done; done; done
|
| 26 |
cd $ROOT/hub/code/scripts
|
|
@@ -37,6 +38,6 @@ from huggingface_hub import HfApi
|
|
| 37 |
a=HfApi(token=os.environ.get('HF_TOKEN'))
|
| 38 |
for p in glob.glob('/workspace/amlc/dense/*'):
|
| 39 |
if os.path.isfile(p):
|
| 40 |
-
a.upload_file(path_or_fileobj=p, path_in_repo='
|
| 41 |
PY
|
| 42 |
log "ALL DONE"
|
|
|
|
| 5 |
# and test when encode B (t1,t2,t3) is done; only that split's arrays are downloaded.
|
| 6 |
set -uo pipefail
|
| 7 |
SPLITS=${SPLITS:-train test}; export SPLITS
|
| 8 |
+
EMB_DIR=${EMB_DIR:-emb_ft}; OUT_PREFIX=${OUT_PREFIX:-dense_ft}; export EMB_DIR OUT_PREFIX
|
| 9 |
ROOT=/workspace/amlc; mkdir -p $ROOT/hub $ROOT/dense $ROOT/raw; cd $ROOT
|
| 10 |
log(){ echo "[$(date -u +%H:%M:%S) UTC] $*"; }
|
| 11 |
log deps; pip install -q pandas pyarrow polars huggingface_hub 2>&1 | tail -1; nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
|
|
|
|
| 14 |
from huggingface_hub import snapshot_download
|
| 15 |
t=time.time()
|
| 16 |
tabs=[x for sp in os.environ['SPLITS'].split() for x in {'train':['s1','s2','s3'],'test':['t1','t2','t3']}[sp]]
|
| 17 |
+
pats=['code/scripts/dense_retrieval.py']+[f'norm/{x}.parquet' for x in tabs]+[f"{os.environ['EMB_DIR']}/e5_{v}/{x}{e}" for v in ('full','name') for x in tabs for e in ('.npy','_ids.parquet')]
|
| 18 |
print('downloading', pats, flush=True)
|
| 19 |
snapshot_download('Arushhh/amlc-work', repo_type='dataset', local_dir='/workspace/amlc/hub', allow_patterns=pats, token=os.environ.get('HF_TOKEN'), max_workers=16)
|
| 20 |
if 'train' in os.environ['SPLITS'].split():
|
| 21 |
snapshot_download('Anupam-Rawat-IITB/data_', repo_type='dataset', local_dir='/workspace/amlc/raw', allow_patterns=['dataset/train/train_ground_truth.tsv'])
|
| 22 |
print('downloaded', f'{time.time()-t:.0f}s', flush=True)
|
| 23 |
PY
|
| 24 |
+
ln -sfn $ROOT/hub/$EMB_DIR $ROOT/hub/emb; ls $ROOT/hub/emb/e5_full | head -3; ls $ROOT/hub/norm
|
| 25 |
for sp in $SPLITS; do [ $sp = train ] && T="s1 s2 s3" || T="t1 t2 t3"
|
| 26 |
for x in $T; do for f in $ROOT/hub/emb/e5_full/$x.npy $ROOT/hub/emb/e5_name/$x.npy $ROOT/hub/norm/$x.parquet; do [ -s "$f" ] || { log "FATAL missing $f"; exit 1; }; done; done; done
|
| 27 |
cd $ROOT/hub/code/scripts
|
|
|
|
| 38 |
a=HfApi(token=os.environ.get('HF_TOKEN'))
|
| 39 |
for p in glob.glob('/workspace/amlc/dense/*'):
|
| 40 |
if os.path.isfile(p):
|
| 41 |
+
a.upload_file(path_or_fileobj=p, path_in_repo=os.environ['OUT_PREFIX']+'/'+os.path.basename(p), repo_id='Arushhh/amlc-work', repo_type='dataset', commit_message=os.environ['OUT_PREFIX']+' '+os.path.basename(p)); print('uploaded', p, flush=True)
|
| 42 |
PY
|
| 43 |
log "ALL DONE"
|