| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
|
|
| set -e |
|
|
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| OUTPUT_DIR="/data/shared/Qwen/experiments/exp2a_results" |
| SAMPLES=50 |
| SEED=42 |
|
|
| echo "==============================================" |
| echo "Experiment 2-A: Embedding Space Analysis" |
| echo "==============================================" |
| echo "Output directory: $OUTPUT_DIR" |
| echo "Samples per category: $SAMPLES" |
| echo "" |
|
|
| |
| source /root/miniconda3/etc/profile.d/conda.sh |
|
|
| |
| RUN_QWEN=false |
| RUN_NVILA=false |
| RUN_MOLMO=false |
|
|
| if [ $# -eq 0 ]; then |
| RUN_QWEN=true |
| RUN_NVILA=true |
| RUN_MOLMO=true |
| else |
| for arg in "$@"; do |
| case $arg in |
| qwen) RUN_QWEN=true ;; |
| nvila) RUN_NVILA=true ;; |
| molmo) RUN_MOLMO=true ;; |
| *) echo "Unknown model: $arg. Use qwen, nvila, or molmo." ;; |
| esac |
| done |
| fi |
|
|
| |
| if [ "$RUN_QWEN" = true ]; then |
| echo "==============================================" |
| echo "Running Qwen2.5-VL experiments..." |
| echo "==============================================" |
| |
| conda deactivate 2>/dev/null || true |
| conda deactivate 2>/dev/null || true |
| conda deactivate 2>/dev/null || true |
|
|
| |
| /root/miniconda3/bin/python "$SCRIPT_DIR/exp2a_embedding_analysis.py" \ |
| --model_type qwen \ |
| --scales vanilla 80k 400k 800k 2m \ |
| --output_dir "$OUTPUT_DIR" \ |
| --samples_per_category $SAMPLES \ |
| --seed $SEED |
| fi |
|
|
| |
| if [ "$RUN_NVILA" = true ]; then |
| echo "==============================================" |
| echo "Running NVILA experiments..." |
| echo "==============================================" |
| conda activate vila |
|
|
| python "$SCRIPT_DIR/exp2a_embedding_analysis.py" \ |
| --model_type nvila \ |
| --scales vanilla 80k 400k 800k 2m \ |
| --output_dir "$OUTPUT_DIR" \ |
| --samples_per_category $SAMPLES \ |
| --seed $SEED |
|
|
| conda deactivate |
| fi |
|
|
| |
| if [ "$RUN_MOLMO" = true ]; then |
| echo "==============================================" |
| echo "Running Molmo experiments..." |
| echo "==============================================" |
| conda activate molmo |
|
|
| python "$SCRIPT_DIR/exp2a_embedding_analysis.py" \ |
| --model_type molmo \ |
| --scales vanilla 80k 400k 800k \ |
| --output_dir "$OUTPUT_DIR" \ |
| --samples_per_category $SAMPLES \ |
| --seed $SEED |
|
|
| conda deactivate |
| fi |
|
|
| echo "" |
| echo "==============================================" |
| echo "Experiments completed!" |
| echo "Results saved to: $OUTPUT_DIR" |
| echo "==============================================" |
|
|
| |
| /root/miniconda3/bin/python - <<'EOF' |
| import os |
| import pandas as pd |
| import matplotlib.pyplot as plt |
| import numpy as np |
|
|
| output_dir = "/data/shared/Qwen/experiments/exp2a_results" |
|
|
| |
| all_results = [] |
| for model_type in ['qwen', 'nvila', 'molmo']: |
| summary_path = os.path.join(output_dir, model_type, 'results_summary.csv') |
| if os.path.exists(summary_path): |
| df = pd.read_csv(summary_path) |
| all_results.append(df) |
|
|
| if all_results: |
| combined_df = pd.concat(all_results, ignore_index=True) |
| combined_df.to_csv(os.path.join(output_dir, 'all_results_summary.csv'), index=False) |
|
|
| |
| pairs = ['sim_above_far', 'sim_under_close', 'sim_left_right'] |
| pair_labels = ['above-far', 'under-close', 'left-right'] |
|
|
| fig, axes = plt.subplots(1, 3, figsize=(18, 6)) |
|
|
| for ax, (pair, pair_label) in zip(axes, zip(pairs, pair_labels)): |
| for model_type in ['qwen', 'nvila', 'molmo']: |
| model_data = combined_df[combined_df['model'].str.startswith(model_type)] |
| if not model_data.empty: |
| scales = model_data['model'].str.replace(f'{model_type}_', '') |
| values = model_data[pair].values |
| ax.plot(scales, values, marker='o', label=model_type.upper(), linewidth=2) |
|
|
| ax.set_title(f'{pair_label}', fontsize=12, fontweight='bold') |
| ax.set_xlabel('Training Scale') |
| ax.set_ylabel('Cosine Similarity') |
| ax.legend() |
| ax.set_ylim(0, 1) |
| ax.axhline(y=0.5, color='gray', linestyle='--', alpha=0.5) |
| ax.tick_params(axis='x', rotation=45) |
|
|
| plt.suptitle('Spatial Concept Similarity Across Training Scales', fontsize=14, fontweight='bold') |
| plt.tight_layout() |
| plt.savefig(os.path.join(output_dir, 'all_models_comparison.png'), dpi=300, bbox_inches='tight') |
| plt.close() |
|
|
| print(f"\nCombined results saved to {output_dir}/all_results_summary.csv") |
| print(f"Combined plot saved to {output_dir}/all_models_comparison.png") |
| else: |
| print("No results found to combine.") |
| EOF |
|
|