AaronCIH commited on
Commit
4848a9b
·
verified ·
1 Parent(s): 819ed1c

Upload Project/CIH.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. Project/CIH.md +180 -0
Project/CIH.md ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # conda activate VisRAG
2
+
3
+ # To-Do List
4
+ ========================================================================
5
+ 1. Baseline: clear model to clear, degra, real datasets (Ret -> Gen)
6
+ 2. Training Code: dataloader, synthetic function
7
+
8
+ # Environments
9
+ =========================================================================
10
+ git clone https://github.com/OpenBMB/VisRAG.git
11
+ conda create --name VisRAG python==3.10.8
12
+ conda activate VisRAG
13
+ conda install nvidia/label/cuda-11.8.0::cuda-toolkit
14
+ cd VisRAG
15
+ pip install -r requirements.txt
16
+ pip install -e .
17
+ cd timm_modified
18
+ pip install -e .
19
+ pip skimage
20
+ pip install peft=0.7.1
21
+ cd ..
22
+ % Download & Change cache_dir
23
+ /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/src/openmatch/arguments.py L136.
24
+ % soft link pre-trained models
25
+ ln -s /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/* /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints
26
+
27
+ # Dataset format
28
+ =========================================================================
29
+ qrels: ['query_id', 'corpus_id', 'score']
30
+ * clear: (queries, qrels, corpus)
31
+ openbmb/VisRAG-Ret-Test-PlotQA
32
+ openbmb/VisRAG-Ret-Test-SlideVQA
33
+ openbmb/VisRAG-Ret-Test-InfoVQA
34
+ openbmb/VisRAG-Ret-Test-ArxivQA
35
+ openbmb/VisRAG-Ret-Test-ChartQA
36
+ openbmb/VisRAG-Ret-Test-MP-DocVQA
37
+
38
+ * synthetic-degradation: (corpus) -> !!! please use clear queries and qrels
39
+ openbmb/VisRAG-Ret-Test-PlotQA
40
+ openbmb/VisRAG-Ret-Test-SlideVQA
41
+ openbmb/VisRAG-Ret-Test-InfoVQA
42
+ openbmb/VisRAG-Ret-Test-ArxivQA
43
+ openbmb/VisRAG-Ret-Test-ChartQA
44
+ openbmb/VisRAG-Ret-Test-MP-DocVQA
45
+
46
+ * real-world: (queries, qrels, corpus)
47
+ rweics5cs7/exo7-realworld-db-combined (RVL-CDIP-clear)
48
+ rweics5cs7/exo7-realworld-db-combined-deg (RVL-CDIP-degra)
49
+ rweics5cs7/exo7-realworld-db-combined-deg-fixed (RVL-CDIP-filter)
50
+ rweics5cs7/exo9-realworld-db-combined (MP-DocVQA)
51
+ rweics5cs7/exo10-realworld-db-combined (ArxivQA)
52
+ =========================================================================
53
+
54
+ # Training
55
+ =========================================================================
56
+ 1. Template:
57
+ # MAX_SEQ_LEN, PER_DEV_BATCH_SIZE, GPUS_PER_NODE, SOFTMAX_TEMPERATURE, EPOCH, QUERY_INSTRUCTION, CORPUS_INSTRUCTION, DEEPSPEED, LR, MAPPING, POOLING, ATTENTION, NPASSAGE, GRADCACHE, GRADCACHE_MICRO, PASSAGE_STOP_GRAD, MODEL_PATH, DATASET_PATH, SYNTHETIC_DISTORTION TAG LoRA
58
+ bash scripts/train_retriever/train.sh 2048 32 8 0.02 5 true false config/deepspeed.json 1e-5 true wmean causal 1 true 4 false ./checkpoints/openbmb/VisRAG-Ret all true Robust false
59
+
60
+ bash scripts/train_retriever/train.sh 2048 32 8 0.02 2 true false config/deepspeed.json 1e-5 true wmean causal 1 true 4 false /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/Robust-train-2025-11-09-181056-lr-1e-5-temp-0.02-bsz32-ngpus8-nnodes1-inbatch--nepoch-3-pooling-wmean-attention-causal-qinstruct-true-cinstruct-false-gradcache-true-passage-stopgrad-false-npassage-1/checkpoint-2500 all true RobustRet false
61
+
62
+
63
+ ## Configuration
64
+ ### Model:
65
+ source: /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/
66
+ "SigLIP": "google/SigLIP", "CPM-2B", "VisRAG": "openbmb/VisRAG-Ret"
67
+ ### Data: (try real)
68
+ 1. Datasets: "out_domain", "in_domain", "real", "all", "openbmb/VisRAG-Ret-Train-In-domain-data", "openbmb/VisRAG-Ret-Train-Synthetic-data" or any huggingface data.
69
+ 2. Loader: MAPPING=True, use_mapping_dataset -> MappingMMDRTrainDataset (not use StreamMMDRTrainDataset (only support single dataset))
70
+ * columns = [image, source, query]
71
+ #### -> If you wish to train using your own datasets, remove the `--from_hf_repo` line from the `train.sh` script. Additionally, ensure that your dataset directory contains a `metadata.json` file, which must include a `length` field specifying the total number of samples in the dataset.
72
+
73
+ * src/openmatch/driver/train.py
74
+
75
+
76
+ # Evaluation
77
+ =========================================================================
78
+ ## Ret:
79
+ ====================
80
+ * source /home/work/shared-fi-datasets-01/users/hsiang.chen/.bashrc && conda activate VisRAG && cd /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG
81
+ ### Testing for baseline
82
+ 1. (Clear)
83
+ bash scripts/eval_retriever/eval.sh 512 2048 16 1 wmean causal ArxivQA,ChartQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/VisRAG-Ret 0 ./results/retrieval_clear false
84
+ 2. (Degra)
85
+ bash scripts/eval_retriever/eval_degra.sh 512 2048 16 1 wmean causal ArxivQA,ChartQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/VisRAG-Ret 0 ./results/retrieval_clear false
86
+ 2. (Real-World)
87
+ * exo7-realworld-db-combined-deg (rvl-cdip), exo9-realworld-db-combined (MP-DocVQA), exo10-realworld-db-combined (ArxivQA)
88
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 1 wmean causal exo7-realworld-db-combined-deg,exo9-realworld-db-combined,exo10-realworld-db-combined /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/VisRAG-Ret 0 ./results/retrieval_clear false
89
+
90
+ rweics5cs7/exo7-realworld-db-combined-deg-fixed
91
+
92
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 4 wmean causal exo7-realworld-db-combined-deg /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/VisRAG-Ret 0 ./results/retrieval_clear false
93
+
94
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 4 wmean causal exo7-realworld-db-combined-deg /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/fft_syn 0 ./results/retrieval_fft false
95
+
96
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 4 wmean causal exo7-realworld-db-combined-deg /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/lora 0 ./results/retrieval_lora true
97
+
98
+ ### Testing for SFT
99
+ 1. (clear)
100
+ bash scripts/eval_retriever/eval.sh 512 2048 16 1 wmean causal ArxivQA,ChartQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/fft_syn 0 ./results/retrieval_fft false
101
+ 2. (degra)
102
+ bash scripts/eval_retriever/eval_degra.sh 512 2048 16 1 wmean causal ArxivQA,ChartQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/fft_syn 0 ./results/retrieval_fft false
103
+ 3. (real-world)
104
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 1 wmean causal exo7-realworld-db-combined-deg,exo9-realworld-db-combined,exo10-realworld-db-combined /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/fft_syn 0 ./results/retrieval_fft false
105
+
106
+
107
+
108
+ ### Testing for LoRA
109
+ 1. (clear)
110
+ bash scripts/eval_retriever/eval.sh 512 2048 16 1 wmean causal ArxivQA,ChartQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/lora 0 ./results/retrieval_lora true
111
+ 2. (degra)
112
+ bash scripts/eval_retriever/eval_degra.sh 512 2048 16 1 wmean causal ArxivQA,ChartQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/lora 0 ./results/retrieval_lora true
113
+ 3. (real-world)
114
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 1 wmean causal exo7-realworld-db-combined-deg,exo9-realworld-db-combined,exo10-realworld-db-combined /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/lora 0 ./results/retrieval_lora true
115
+
116
+
117
+ ### Testing for Ours
118
+ 1. (clear)
119
+ bash scripts/eval_retriever/eval.sh 512 2048 16 1 wmean causal ChartQA,ArxivQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/Robust-train-2025-11-09-181056-lr-1e-5-temp-0.02-bsz32-ngpus8-nnodes1-inbatch--nepoch-3-pooling-wmean-attention-causal-qinstruct-true-cinstruct-false-gradcache-true-passage-stopgrad-false-npassage-1/checkpoint-2500 0 ./results/retrieval_robust false
120
+ 2. (degra)
121
+ bash scripts/eval_retriever/eval_degra.sh 512 2048 16 1 wmean causal ChartQA,ArxivQA,MP-DocVQA,InfoVQA,PlotQA,SlideVQA /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/Robust-train-2025-11-09-181056-lr-1e-5-temp-0.02-bsz32-ngpus8-nnodes1-inbatch--nepoch-3-pooling-wmean-attention-causal-qinstruct-true-cinstruct-false-gradcache-true-passage-stopgrad-false-npassage-1/checkpoint-2500 0 ./results/retrieval_robust false
122
+ 3. (real-world)
123
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 1 wmean causal exo7-realworld-db-combined-deg,exo9-realworld-db-combined,exo10-realworld-db-combined /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/Robust-train-2025-11-09-181056-lr-1e-5-temp-0.02-bsz32-ngpus8-nnodes1-inbatch--nepoch-3-pooling-wmean-attention-causal-qinstruct-true-cinstruct-false-gradcache-true-passage-stopgrad-false-npassage-1/checkpoint-2500 0 ./results/retrieval_robust false
124
+
125
+ bash scripts/eval_retriever/eval_real.sh 512 2048 16 1 wmean causal exo7-realworld-db-combined-deg,exo9-realworld-db-combined,exo10-realworld-db-combined /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/checkpoints/Robust-train-2025-11-09-181056-lr-1e-5-temp-0.02-bsz32-ngpus8-nnodes1-inbatch--nepoch-3-pooling-wmean-attention-causal-qinstruct-true-cinstruct-false-gradcache-true-passage-stopgrad-false-npassage-1/checkpoint-2500 0 ./results/retrieval_robust false
126
+
127
+ -> USE /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/stastic_ret.py stastic results.
128
+ ======================
129
+
130
+
131
+ ## Gen: (should run Ret first and get the embedding and reterival results)
132
+ ======================
133
+ 1. (Clear)
134
+ python scripts/generate/generate.py \
135
+ --model_name MiniCPMV2.6 \
136
+ --model_name_or_path /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/MiniCPM-V-2_6 \
137
+ --dataset_name ChartQA \
138
+ --dataset_name_or_path openbmb/VisRAG-Ret-Test-ChartQA \
139
+ --rank 0 \
140
+ --world_size 1 \
141
+ --topk 3 \
142
+ --results_root_dir /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/data/checkpoints/clear \
143
+ --task_type multi_image \
144
+ --concatenate_type horizontal \
145
+ --output_dir /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/data/checkpoints/generate
146
+
147
+ * model_name: ['MiniCPM', 'MiniCPMV2.0', 'MiniCPMV2.6', 'gpt4o']
148
+ * model_name_or_path: /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/MiniCPM-V-2_6
149
+ * dataset_name: ['ArxivQA', 'ChartQA', 'PlotQA', 'MP-DocVQA', 'SlideVQA', 'InfoVQA']
150
+ * dataset_name_or_path:
151
+ * task_type: ['text', 'page_concatenation', 'weighted_selection', 'multi_image']
152
+ * concatenate: ['horizontal', 'vertical']
153
+
154
+ 2. (Ret)
155
+ python scripts/generate/generate.py \
156
+ --model_name MiniCPMV2.6 \
157
+ --model_name_or_path /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/openbmb/MiniCPM-V-2_6 \
158
+ --dataset_name ChartQA \
159
+ --dataset_name_or_path openbmb/VisRAG-Ret-Test-ChartQA \
160
+ --rank 0 \
161
+ --world_size 1 \
162
+ --topk 3 \
163
+ --results_root_dir /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/data/checkpoints/clear \
164
+ --task_type multi_image \
165
+ --concatenate_type horizontal \
166
+ --output_dir /home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/VisRAG/data/checkpoints/generate
167
+
168
+
169
+
170
+ # config
171
+ ====================================================================
172
+ Evaluating: ArxivQA
173
+ This dataset result dir: /data/checkpoints/eval-2025-09-28-182703-maxq-512-maxp-2048-bsz-16-pooling-wmean-attention-causal-gpus-per-node-1/ArxivQA
174
+ CORPUS_PATH: openbmb/VisRAG-Ret-Test-ArxivQA
175
+ QUERY_PATH: openbmb/VisRAG-Ret-Test-ArxivQA
176
+ QRELS_PATH: openbmb/VisRAG-Ret-Test-ArxivQA
177
+ ====================================================================================================
178
+ model_args: ModelArguments(model_name_or_path='/home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo/VisRAG-Ret', target_model_path=None, config_name=None, tokenizer_name=None, processor_name=None, cache_dir='/home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/ModelZoo', untie_encoder=False, feature='last_hidden_state', pooling='wmean', attention='causal', add_linear_head=False, projection_in_dim=768, projection_out_dim=768, dtype='float16', encoder_only=False, pos_token=None, neg_token=None, normalize=True, lora=False, lora_r=32, attn_implementation='sdpa')
179
+
180
+ data_args: DataArguments(train_dir=None, train_path=None, eval_path=None, qrels_path='openbmb/VisRAG-Ret-Test-MP-DocVQA', query_path='openbmb/VisRAG-Ret-Test-MP-DocVQA', corpus_path='openbmb/VisRAG-Ret-Test-MP-DocVQA', data_dir=None, train_n_passages=8, positive_passage_no_shuffle=False, negative_passage_no_shuffle=False, q_max_len=512, p_max_len=2048, query_instruction=True, corpus_instruction=False, data_cache_dir='/home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Robust/Dataset', query_template='Represent this query for retrieving relevant documents: <query>', query_column_names=None, doc_template='<text>', doc_column_names=None, all_markers=None, encode_as_text_pair=False, from_hf_repo=True)