Skip to content

Commit 87a69dc

Browse files
committed
feat: add script for retrain the citation models
1 parent e49d0ee commit 87a69dc

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
# Distributed training script for the citation GROBID model with multiple architectures
3+
# Uses sbatch for parallel job submission to fully exploit the cluster
4+
#
5+
# This script trains the citation model with the following architectures:
6+
# - BidLSTM_CRF
7+
# - BidLSTM_CRF_FEATURES
8+
# - BidLSTM_ChainCRF
9+
# - BidLSTM_ChainCRF_FEATURES
10+
11+
set -e
12+
13+
# Parallelization settings
14+
MAX_PARALLEL_JOBS=${MAX_PARALLEL_JOBS:-4}
15+
WAIT_INTERVAL=${WAIT_INTERVAL:-30}
16+
17+
# Common SLURM configuration
18+
SBATCH_OPTS="--container-mounts=/netscratch:/netscratch,$HOME:$HOME \
19+
--container-workdir=/netscratch/lfoppiano/delft/delft_tf2.17.1-updated \
20+
--container-image=/netscratch/lfoppiano/enroot/tensorflow-2.17.2-gpu-delft-updated.sqsh \
21+
--mem=100G \
22+
-p V100-32GB,RTX3090,RTXA6000 \
23+
--gpus=1 \
24+
--nodes=1 \
25+
--time=3-00:00"
26+
27+
PYTHON_CMD=".venv/bin/python -m delft.applications.grobidTagger"
28+
29+
# Architectures to train
30+
ARCHITECTURES=(
31+
"BidLSTM_CRF"
32+
"BidLSTM_CRF_FEATURES"
33+
"BidLSTM_ChainCRF"
34+
"BidLSTM_ChainCRF_FEATURES"
35+
)
36+
37+
MODEL="citation"
38+
39+
# Log directory for job outputs
40+
LOG_DIR="${HOME}/slurm_logs/train_citation_$(date +%Y%m%d_%H%M%S)"
41+
mkdir -p "$LOG_DIR"
42+
43+
# Track submitted job IDs
44+
declare -a JOB_IDS
45+
46+
# Function to submit a training job
47+
submit_job() {
48+
local architecture=$1
49+
local experiment_id=$2
50+
51+
local job_name="train_${MODEL}_${architecture}"
52+
local log_file="${LOG_DIR}/${job_name}_%j.log"
53+
54+
echo ">>> Submitting experiment $experiment_id: $job_name"
55+
56+
job_id=$(sbatch $SBATCH_OPTS \
57+
--job-name="$job_name" \
58+
--output="$log_file" \
59+
--error="$log_file" \
60+
--wrap="$PYTHON_CMD $MODEL train --architecture $architecture --num-workers 6 --max-sequence-length 3000" 2>&1 | grep -oP '\d+')
61+
62+
if [[ -n "$job_id" ]]; then
63+
JOB_IDS+=("$job_id")
64+
echo " Submitted job ID: $job_id"
65+
else
66+
echo " Warning: Failed to submit job for $job_name"
67+
fi
68+
}
69+
70+
# Main submission loop
71+
total_experiments=${#ARCHITECTURES[@]}
72+
73+
echo "==========================================="
74+
echo "Starting distributed training of citation model"
75+
echo "Total experiments: $total_experiments"
76+
echo "Max parallel jobs: $MAX_PARALLEL_JOBS"
77+
echo "Log directory: $LOG_DIR"
78+
echo "==========================================="
79+
echo ""
80+
81+
experiment_count=0
82+
83+
for arch in "${ARCHITECTURES[@]}"; do
84+
experiment_count=$((experiment_count + 1))
85+
submit_job "$arch" "$experiment_count"
86+
done
87+
88+
echo ""
89+
echo "==========================================="
90+
echo "All $total_experiments experiments submitted!"
91+
echo "Job IDs: ${JOB_IDS[*]}"
92+
echo "Monitor with: squeue -u \$USER"
93+
echo "Logs in: $LOG_DIR"
94+
echo "==========================================="

0 commit comments

Comments
 (0)