Spaces:
Running on Zero
Running on Zero
| # Path to the Python merging script | |
| PYTHON_SCRIPT="/home/work/AIDAS/MMaDA/merging.py" | |
| # Define the range of alpha values for grid search | |
| ALPHA_VALUES=() | |
| # Optional task-vector scaling factors (set to an empty array to disable) | |
| TASK_VECTOR_SCALES=(0.5 0.6 0.7 0.8 0.9) | |
| MERGE_STRATEGIES=("hf-for-common") | |
| # Ensure there is at least one placeholder iteration even if alpha list is empty | |
| if [ ${#ALPHA_VALUES[@]} -eq 0 ]; then | |
| ALPHA_VALUES=("default") | |
| fi | |
| echo "Starting grid search for model merging..." | |
| echo "Alpha values: ${ALPHA_VALUES[@]}" | |
| echo "Task vector scales: ${TASK_VECTOR_SCALES[@]}" | |
| echo "Merge strategies: ${MERGE_STRATEGIES[@]}" | |
| echo "----------------------------------------" | |
| for alpha in "${ALPHA_VALUES[@]}"; do | |
| for task_scale in "${TASK_VECTOR_SCALES[@]}"; do | |
| for strategy in "${MERGE_STRATEGIES[@]}"; do | |
| task_arg="" | |
| if [ -n "${task_scale}" ]; then | |
| task_arg="--task-vector-scale ${task_scale}" | |
| fi | |
| alpha_arg="" | |
| alpha_label="${alpha}" | |
| if [ "${alpha}" != "default" ] && [ -n "${alpha}" ]; then | |
| alpha_arg="--alpha ${alpha}" | |
| else | |
| alpha_label="(script default)" | |
| fi | |
| # Construct the command based on the current strategy | |
| if [ "${strategy}" == "default" ]; then | |
| command="python ${PYTHON_SCRIPT} ${alpha_arg} ${task_arg}" | |
| description="Strategy: Default (Average Merge)" | |
| elif [ "${strategy}" == "no-merge-vocab" ]; then | |
| command="python ${PYTHON_SCRIPT} ${alpha_arg} --no-merge-vocab ${task_arg}" | |
| description="Strategy: No Vocab Merge" | |
| elif [ "${strategy}" == "hf-for-common" ]; then | |
| command="python ${PYTHON_SCRIPT} ${alpha_arg} --hf-for-common ${task_arg}" | |
| description="Strategy: HF For Common Tokens" | |
| fi | |
| echo "Executing command with alpha=${alpha_label}, task_scale=${task_scale}, ${description}" | |
| echo "Command: ${command}" | |
| ${command} | |
| echo "----------------------------------------" | |
| done | |
| done | |
| done | |
| echo "All grid search runs completed." | |