Update README.md
Browse files
README.md
CHANGED
@@ -19,8 +19,9 @@ tags:
|
|
19 |
|
20 |
[![github](https://img.shields.io/badge/GitHub-TinyLLaVA-blue)](https://github.com/DLCV-BUAA/TinyLLaVABench) [![arXiv](https://img.shields.io/badge/Arxiv-2402.14289-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2402.14289) [![License](https://img.shields.io/badge/License-Apache%202.0-yellow)](https://github.com/PKU-YuanGroup/MoE-LLaVA/blob/main/LICENSE)
|
21 |
|
22 |
-
|
23 |
## 🎉 News
|
|
|
|
|
24 |
* **[2024.02.25]** Update evaluation scripts and docs!
|
25 |
* **[2024.02.25]** Data descriptions out. Release TinyLLaVA-1.5B and TinyLLaVA-2.0B!
|
26 |
* **[2024.02.24]** Example code on inference and model loading added!
|
@@ -31,7 +32,8 @@ tags:
|
|
31 |
|
32 |
## ⌛ TODO
|
33 |
- [ ] Add support for Ollama and llama.cpp.
|
34 |
-
- [
|
|
|
35 |
- [x] Model Zoo descriptions.
|
36 |
- [x] Examples and inference.
|
37 |
- [x] Release code for training.
|
@@ -44,22 +46,17 @@ tags:
|
|
44 |
|
45 |
- Our best model, TinyLLaVA-3.1B, achieves better overall performance against existing 7B models such as LLaVA-1.5 and Qwen-VL.
|
46 |
|
47 |
-
##
|
48 |
-
### Legacy Model
|
49 |
-
- [tiny-llava-hf](https://huggingface.co/bczhou/tiny-llava-v1-hf)
|
50 |
-
|
51 |
-
### Pretrained Models
|
52 |
-
- [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B)
|
53 |
-
- [TinyLLaVA-2.0B](https://huggingface.co/bczhou/TinyLLaVA-2.0B)
|
54 |
-
- [TinyLLaVA-1.5B](https://huggingface.co/bczhou/TinyLLaVA-1.5B)
|
55 |
-
|
56 |
-
### Model Details
|
57 |
-
| Name | LLM | Checkpoint | LLaVA-Bench-Wild | MME | MMBench | MM-Vet | SQA-image | VQA-v2 | GQA | TextVQA |
|
58 |
-
|---------------|-------------------|------------------------------------------------|------------------|----------|---------|--------|-----------|--------|-------|---------|
|
59 |
-
| TinyLLaVA-3.1B | Phi-2 | [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B) | 75.8 | 1464.9 | 66.9 | 32.0 | 69.1 | 79.9 | 62.0 | 59.1 |
|
60 |
-
| TinyLLaVA-2.0B | StableLM-2-1.6B | [TinyLLaVA-2.0B](https://huggingface.co/bczhou/TinyLLaVA-2.0B) | 66.4 | 1433.8 | 63.3 | 32.6 | 64.7 | 78.9 | 61.9 | 56.4 |
|
61 |
-
| TinyLLaVA-1.5B | TinyLlama | [TinyLLaVA-1.5B](https://huggingface.co/bczhou/TinyLLaVA-1.5B) | 60.8 | 1276.5 | 55.2 | 25.8 | 60.3 | 76.9 | 60.3 | 51.7 |
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
|
65 |
## 🔧 Requirements and Installation
|
@@ -85,7 +82,7 @@ pip install -e .
|
|
85 |
pip install -e ".[train]"
|
86 |
pip install flash-attn --no-build-isolation
|
87 |
```
|
88 |
-
### Upgrade to latest code base
|
89 |
|
90 |
```Shell
|
91 |
git pull
|
@@ -95,6 +92,41 @@ pip install -e .
|
|
95 |
# pip install flash-attn --no-build-isolation --no-cache-dir
|
96 |
```
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
## 🔧 Quick Start
|
100 |
|
@@ -151,7 +183,7 @@ eval_model(args)
|
|
151 |
### Important
|
152 |
We use different `conv_mode` for different models. Replace the `conv_mode` in `args` according to this table:
|
153 |
| model | conv_mode |
|
154 |
-
|
155 |
| TinyLLaVA-3.1B | phi |
|
156 |
| TinyLLaVA-2.0B | phi |
|
157 |
| TinyLLaVA-1.5B | v1 |
|
@@ -161,6 +193,115 @@ To ensure the reproducibility, we evaluate the models with greedy decoding.
|
|
161 |
|
162 |
See [Evaluation.md](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/docs/Evaluation.md)
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
## ✏ Citation
|
166 |
|
@@ -176,3 +317,8 @@ If you find our paper and code useful in your research, please consider giving a
|
|
176 |
primaryClass={cs.LG}
|
177 |
}
|
178 |
```
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
[![github](https://img.shields.io/badge/GitHub-TinyLLaVA-blue)](https://github.com/DLCV-BUAA/TinyLLaVABench) [![arXiv](https://img.shields.io/badge/Arxiv-2402.14289-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2402.14289) [![License](https://img.shields.io/badge/License-Apache%202.0-yellow)](https://github.com/PKU-YuanGroup/MoE-LLaVA/blob/main/LICENSE)
|
21 |
|
|
|
22 |
## 🎉 News
|
23 |
+
* **[2024.03.10]** base recipe out!
|
24 |
+
* **[2024.03.10]** Finetune scripts out!
|
25 |
* **[2024.02.25]** Update evaluation scripts and docs!
|
26 |
* **[2024.02.25]** Data descriptions out. Release TinyLLaVA-1.5B and TinyLLaVA-2.0B!
|
27 |
* **[2024.02.24]** Example code on inference and model loading added!
|
|
|
32 |
|
33 |
## ⌛ TODO
|
34 |
- [ ] Add support for Ollama and llama.cpp.
|
35 |
+
- [x] Developers' guide / How to build demo locally.
|
36 |
+
- [x] Training and custom finetuning docs.
|
37 |
- [x] Model Zoo descriptions.
|
38 |
- [x] Examples and inference.
|
39 |
- [x] Release code for training.
|
|
|
46 |
|
47 |
- Our best model, TinyLLaVA-3.1B, achieves better overall performance against existing 7B models such as LLaVA-1.5 and Qwen-VL.
|
48 |
|
49 |
+
## Contents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
- [Install](#x1f527-requirements-and-installation)
|
52 |
+
- [Model Zoo](#x1f433-model-zoo)
|
53 |
+
- [Demo](#Demo)
|
54 |
+
- [Quick Start](#x1f527-quick-start)
|
55 |
+
- [Run Inference](#x1f527-run-inference)
|
56 |
+
- [Evaluation](#evaluation)
|
57 |
+
- [Data](#data-preparation)
|
58 |
+
- [Train](#train)
|
59 |
+
- [Custom Finetune](#custom-finetune)
|
60 |
|
61 |
|
62 |
## 🔧 Requirements and Installation
|
|
|
82 |
pip install -e ".[train]"
|
83 |
pip install flash-attn --no-build-isolation
|
84 |
```
|
85 |
+
### Upgrade to the latest code base
|
86 |
|
87 |
```Shell
|
88 |
git pull
|
|
|
92 |
# pip install flash-attn --no-build-isolation --no-cache-dir
|
93 |
```
|
94 |
|
95 |
+
## 🐳 Model Zoo
|
96 |
+
### Legacy Model
|
97 |
+
- [tiny-llava-hf](https://huggingface.co/bczhou/tiny-llava-v1-hf)
|
98 |
+
|
99 |
+
### Pretrained Models
|
100 |
+
- [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B)
|
101 |
+
- [TinyLLaVA-2.0B](https://huggingface.co/bczhou/TinyLLaVA-2.0B)
|
102 |
+
- [TinyLLaVA-1.5B](https://huggingface.co/bczhou/TinyLLaVA-1.5B)
|
103 |
+
|
104 |
+
### Model Details
|
105 |
+
| Name | LLM | Checkpoint | LLaVA-Bench-Wild | MME | MMBench | MM-Vet | SQA-image | VQA-v2 | GQA | TextVQA |
|
106 |
+
|---------------|-------------------|------------------------------------------------|------------------|----------|---------|--------|-----------|--------|-------|---------|
|
107 |
+
| TinyLLaVA-3.1B | Phi-2 | [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B) | 75.8 | 1464.9 | 66.9 | 32.0 | 69.1 | 79.9 | 62.0 | 59.1 |
|
108 |
+
| TinyLLaVA-2.0B | StableLM-2-1.6B | [TinyLLaVA-2.0B](https://huggingface.co/bczhou/TinyLLaVA-2.0B) | 66.4 | 1433.8 | 63.3 | 32.6 | 64.7 | 78.9 | 61.9 | 56.4 |
|
109 |
+
| TinyLLaVA-1.5B | TinyLlama | [TinyLLaVA-1.5B](https://huggingface.co/bczhou/TinyLLaVA-1.5B) | 60.8 | 1276.5 | 55.2 | 25.8 | 60.3 | 76.9 | 60.3 | 51.7 |
|
110 |
+
|
111 |
+
|
112 |
+
## Demo
|
113 |
+
|
114 |
+
### Gradio Web Demo
|
115 |
+
|
116 |
+
Launch a local web demo by running:
|
117 |
+
```shell
|
118 |
+
python tinyllava/serve/app.py --model-path bczhou/TinyLLaVA-3.1B --model-name TinyLLaVA-3.1B
|
119 |
+
```
|
120 |
+
|
121 |
+
### CLI Inference
|
122 |
+
|
123 |
+
We also support running inference with CLI. To use our model, run:
|
124 |
+
```shell
|
125 |
+
python -m tinyllava.serve.cli \
|
126 |
+
--model-path bczhou/TinyLLaVA-3.1B \
|
127 |
+
--image-file "./tinyllava/serve/examples/extreme_ironing.jpg"
|
128 |
+
```
|
129 |
+
|
130 |
|
131 |
## 🔧 Quick Start
|
132 |
|
|
|
183 |
### Important
|
184 |
We use different `conv_mode` for different models. Replace the `conv_mode` in `args` according to this table:
|
185 |
| model | conv_mode |
|
186 |
+
|---------------- |----------- |
|
187 |
| TinyLLaVA-3.1B | phi |
|
188 |
| TinyLLaVA-2.0B | phi |
|
189 |
| TinyLLaVA-1.5B | v1 |
|
|
|
193 |
|
194 |
See [Evaluation.md](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/docs/Evaluation.md)
|
195 |
|
196 |
+
## Data Preparation
|
197 |
+
|
198 |
+
In our paper, we used two different datasets: the [LLaVA dataset](https://github.com/haotian-liu/LLaVA?tab=readme-ov-file#pretrain-feature-alignment) and the [ShareGPT4V dataset](https://github.com/InternLM/InternLM-XComposer/blob/main/projects/ShareGPT4V/docs/Data.md), and compared their differences. In this section, we provide information on data preparation.
|
199 |
+
|
200 |
+
### Pretraining Images
|
201 |
+
* LLaVA: The pretraining images of LLaVA is from the 558K subset of the LAION-CC-SBU dataset.
|
202 |
+
* ShareGPT4V: The pretraining images of ShareGPT4V is a mixture of 558K LAION-CC-SBU subset, SAM dataset, and COCO dataset.
|
203 |
+
|
204 |
+
### Pretraining Annotations
|
205 |
+
* LLaVA: The pretraining annotations of LLaVA are [here](https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain).
|
206 |
+
* ShareGPT4V: The pretraining annotations of ShareGPT4V are [here](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/share-captioner_coco_lcs_sam_1246k_1107.json).
|
207 |
+
|
208 |
+
|
209 |
+
### SFT Images & Annotations
|
210 |
+
The majority of the two SFT datasets are the same, with the exception that the 23K detailed description data in LLaVA-1.5-SFT being replaced with detailed captions randomly sampled from the [100K ShareGPT4V data](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/sharegpt4v_instruct_gpt4-vision_cap100k.json).
|
211 |
+
|
212 |
+
### Download data
|
213 |
+
|
214 |
+
1. Download relevant images
|
215 |
+
|
216 |
+
- LAION-CC-SBU-558K: [images.zip](https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain/blob/main/images.zip)
|
217 |
+
- COCO: This dataset is from the [COCO2017 challenge](https://cocodataset.org/). Download: [train2017](http://images.cocodataset.org/zips/train2017.zip)
|
218 |
+
- WebData: This dataset is curated by the [ShareGPT4V project](https://github.com/InternLM/InternLM-XComposer/tree/main/projects/ShareGPT4V). Download: [images](https://drive.google.com/drive/folders/1tCUQ-sq6vdshZVkF0ZeF3K4eztkXJgax?usp=sharing). Only for academic usage.
|
219 |
+
- SAM: This dataset is collected by [Meta](https://ai.meta.com/datasets/segment-anything-downloads/). Download: [images](https://ai.meta.com/datasets/segment-anything-downloads/). We only use 000000~000050.tar for now. If you just want to use ShareGPT4V for SFT, you can quickly download 9K images from [here](https://drive.google.com/file/d/1dKumdOKSXtV7lIXdrG7jsIK_z2vZv2gs/view?usp=drive_link).
|
220 |
+
- GQA: [GQA project page](https://cs.stanford.edu/people/dorarad/gqa/about.html). Download: [images](https://downloads.cs.stanford.edu/nlp/data/gqa/images.zip)
|
221 |
+
- OCR-VQA: [OCR-VQA project page](https://ocr-vqa.github.io/). Download: [download script](https://drive.google.com/drive/folders/1_GYPY5UkUy7HIcR0zq3ZCFgeZN7BAfm_?usp=sharing). We save all files as `.jpg`
|
222 |
+
- TextVQA: [TextVQA project page](https://textvqa.org/). Download: [trainvalimages](https://dl.fbaipublicfiles.com/textvqa/images/train_val_images.zip)
|
223 |
+
- VisualGenome: [VisualGenome project page](https://homes.cs.washington.edu/~ranjay/visualgenome/index.html). Download: [part1](https://cs.stanford.edu/people/rak248/VG_100K_2/images.zip), [part2](https://cs.stanford.edu/people/rak248/VG_100K_2/images2.zip)
|
224 |
+
|
225 |
+
|
226 |
+
2. Download relevant annotations
|
227 |
+
|
228 |
+
- LLaVA's pretraining annotations: [blip_laion_cc_sbu_558k.json](https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain)
|
229 |
+
- LLaVA's SFT annotations: [llava_v1_5_mix665k.json](https://huggingface.co/datasets/liuhaotian/LLaVA-Instruct-150K/blob/main/llava_v1_5_mix665k.json)
|
230 |
+
- ShareGPT4V's pretraining annotations: [share-captioner_coco_lcs_sam_1246k_1107.json](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/share-captioner_coco_lcs_sam_1246k_1107.json)
|
231 |
+
- ShareGPT4V's SFT annotations: [sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json](https://huggingface.co/datasets/Lin-Chen/ShareGPT4V/blob/main/sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json)
|
232 |
+
|
233 |
+
|
234 |
+
### Organize Data
|
235 |
+
|
236 |
+
Organize the image files and annotation files as follows in `path/to/your/data`:
|
237 |
+
|
238 |
+
```none
|
239 |
+
data
|
240 |
+
βββ llava
|
241 |
+
β βββ llava_pretrain
|
242 |
+
β β βββ images
|
243 |
+
β β βββ blip_laion_cc_sbu_558k.json
|
244 |
+
βββ coco
|
245 |
+
β βββ train2017
|
246 |
+
βββ sam
|
247 |
+
β βββ images
|
248 |
+
βββ gqa
|
249 |
+
β βββ images
|
250 |
+
βββ ocr_vqa
|
251 |
+
β βββ images
|
252 |
+
βββ textvqa
|
253 |
+
β βββ train_images
|
254 |
+
βββ vg
|
255 |
+
β βββ VG_100K
|
256 |
+
β βββ VG_100K_2
|
257 |
+
βββ share_textvqa
|
258 |
+
β βββ images
|
259 |
+
βββ web-celebrity
|
260 |
+
β βββ images
|
261 |
+
βββ web-landmark
|
262 |
+
β βββ images
|
263 |
+
βββ wikiart
|
264 |
+
β βββ images
|
265 |
+
βββ text_files
|
266 |
+
β βββ llava_v1_5_mix665k.json
|
267 |
+
β βββ share-captioner_coco_lcs_sam_1246k_1107.json
|
268 |
+
β βββ sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json
|
269 |
+
```
|
270 |
+
|
271 |
+
## Train
|
272 |
+
|
273 |
+
**This section we describe the base recipe.**
|
274 |
+
### Hyperparameters
|
275 |
+
Both hyperparameters used in pretraining and finetuning are provided below.
|
276 |
+
|
277 |
+
1. Pretraining
|
278 |
+
|
279 |
+
| Hyperparameter | Global Batch Size | Learning rate | Epochs | Max length | Weight decay |
|
280 |
+
|----------------| ---: | ---: | ---: |-----------:| ---: |
|
281 |
+
| TinyLLaVA-3.1B | 256 | 1e-3 | 1 | 3072 | 0 |
|
282 |
+
|
283 |
+
2. Finetuning
|
284 |
+
|
285 |
+
| Hyperparameter | Global Batch Size | Learning rate | Epochs | Max length | Weight decay |
|
286 |
+
|----------------| ---: | ---: | ---: |-----------:| ---: |
|
287 |
+
| TinyLLaVA-3.1B | 128 | 2e-5 | 1 | 3072 | 0 |
|
288 |
+
|
289 |
+
### Pretrain
|
290 |
+
|
291 |
+
**Replace paths to your paths**
|
292 |
+
|
293 |
+
Training script with DeepSpeed ZeRO-2: [`pretrain.sh`](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/scripts/tiny_llava/pretrain.sh).
|
294 |
+
|
295 |
+
### Finetune
|
296 |
+
|
297 |
+
**Replace paths to your paths**
|
298 |
+
|
299 |
+
Training script with DeepSpeed ZeRO-3: [`finetune.sh`](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/main/scripts/tiny_llava/finetune.sh).
|
300 |
+
|
301 |
+
## Custom-Finetune
|
302 |
+
|
303 |
+
Check out our custom finetune using LoRA [here](https://github.com/DLCV-BUAA/TinyLLaVABench/blob/dev/docs/CUTOM_FINETUNE.md).
|
304 |
+
|
305 |
|
306 |
## ✏ Citation
|
307 |
|
|
|
317 |
primaryClass={cs.LG}
|
318 |
}
|
319 |
```
|
320 |
+
|
321 |
+
|
322 |
+
## β€οΈ Community efforts
|
323 |
+
* Our codebase is built upon the [LLaVA](https://github.com/haotian-liu/LLaVA) project. Great work!
|
324 |
+
* Our project uses data from the [ShareGPT4V](https://github.com/InternLM/InternLM-XComposer/tree/main/projects/ShareGPT4V) project. Great work!
|