Update README.md
Browse files
README.md
CHANGED
|
@@ -1,43 +1,307 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
datasets:
|
|
|
|
| 4 |
- liuhaotian/LLaVA-Pretrain
|
| 5 |
- liuhaotian/LLaVA-Instruct-150K
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
- zh
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
We present TinyLLaVA, a small vision-language chatbot (1.4B) that reaches comparable performances with contemporary vision language models on common benchmarks, using less parameters.
|
| 14 |
-
TinyLLaVA was trained by finetuning [TinyLlama](https://huggingface.co/PY007/TinyLlama-1.1B-Chat-v0.3) on the [LLaVA-1.5](https://github.com/haotian-liu/LLaVA) dataset, following the training recipe of [LLaVA-1.5](https://github.com/haotian-liu/LLaVA). For more details, please refer to the [LLaVA-1.5 paper](https://arxiv.org/abs/2310.03744).
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
-
##
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
|
|
|
| 32 |
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
#### - Transformers Version
|
| 40 |
-
Make sure to have `transformers >= 4.35.3`.
|
| 41 |
|
| 42 |
#### - Prompt Template
|
| 43 |
The model supports multi-image and multi-prompt generation. When using the model, make sure to follow the correct prompt template (`USER: <image>xxx\nASSISTANT:`), where `<image>` token is a place-holding special token for image embeddings.
|
|
@@ -83,9 +347,6 @@ output = model.generate(**inputs, max_new_tokens=200, do_sample=False)
|
|
| 83 |
print(processor.decode(output[0][2:], skip_special_tokens=True))
|
| 84 |
```
|
| 85 |
|
| 86 |
-
## Contact
|
| 87 |
-
This model was trained by [Baichuan Zhou](https://baichuanzhou.github.io/), from Beihang Univerisity, under the supervision of [Prof. Lei Huang](https://huangleibuaa.github.io/).
|
| 88 |
-
|
| 89 |
## ✏ Citation
|
| 90 |
|
| 91 |
If you find our paper and code useful in your research, please consider giving a star :star: and citation :pencil:.
|
|
@@ -99,4 +360,10 @@ If you find our paper and code useful in your research, please consider giving a
|
|
| 99 |
archivePrefix={arXiv},
|
| 100 |
primaryClass={cs.LG}
|
| 101 |
}
|
| 102 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
datasets:
|
| 4 |
+
- Lin-Chen/ShareGPT4V
|
| 5 |
- liuhaotian/LLaVA-Pretrain
|
| 6 |
- liuhaotian/LLaVA-Instruct-150K
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
- zh
|
| 10 |
+
tags:
|
| 11 |
+
- llava
|
| 12 |
+
- vision-language
|
| 13 |
+
- llm
|
| 14 |
+
- lmm
|
| 15 |
---
|
| 16 |
+
<h2 align="center"> <a href="https://arxiv.org/abs/2402.14289">TinyLLaVA: A Framework of Small-scale Large Multimodal Models</a>
|
| 17 |
|
| 18 |
+
<h5 align="center">
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
[](https://github.com/DLCV-BUAA/TinyLLaVABench) [](https://arxiv.org/abs/2402.14289) [](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!
|
| 28 |
+
* **[2024.02.23]** Evaluation code and scripts released!
|
| 29 |
+
* **[2024.02.21]** Creating the [TinyLLaVABench](https://github.com/DLCV-BUAA/TinyLLavaBench) repository on GitHub!
|
| 30 |
+
* **[2024.02.21]** Our paper: [TinyLLaVA: A Framework of Small-scale Large Multimodal Models](https://arxiv.org/abs/2402.14289) is out!
|
| 31 |
+
* **[2024.01.11]** Our fist model [TinyLLaVA-1.4B](https://huggingface.co/bczhou/tiny-llava-v1-hf) is out!
|
| 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.
|
| 40 |
+
- [x] Add descriptions for evaluation.
|
| 41 |
+
- [x] Add descriptions for data preparation.
|
| 42 |
+
- [x] Release TinyLLaVA-1.5B and TinyLLaVA-2.0B.
|
| 43 |
+
- [x] Release TinyLLaVA-3.1B.
|
| 44 |
+
- [x] Release the evaluation code and weights today(2024.2.23).
|
| 45 |
+
### 🔥 High performance, but with fewer parameters
|
| 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
|
| 63 |
+
|
| 64 |
+
We recommend the requirements as follows.
|
| 65 |
+
|
| 66 |
+
1. Clone this repository and navigate to LLaVA folder
|
| 67 |
+
```bash
|
| 68 |
+
git clone https://github.com/DLCV-BUAA/TinyLLaVABench.git
|
| 69 |
+
cd TinyLLaVABench
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
2. Install Package
|
| 73 |
+
```Shell
|
| 74 |
+
conda create -n tinyllava python=3.10 -y
|
| 75 |
+
conda activate tinyllava
|
| 76 |
+
pip install --upgrade pip # enable PEP 660 support
|
| 77 |
+
pip install -e .
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
3. Install additional packages for training cases
|
| 81 |
+
```Shell
|
| 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
|
| 89 |
+
pip install -e .
|
| 90 |
+
|
| 91 |
+
# if you see some import errors when you upgrade, please try running the command below (without #)
|
| 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 |
+
|
| 133 |
+
<details>
|
| 134 |
+
<summary>Load model</summary>
|
| 135 |
+
|
| 136 |
+
```Python
|
| 137 |
+
from tinyllava.model.builder import load_pretrained_model
|
| 138 |
+
from tinyllava.mm_utils import get_model_name_from_path
|
| 139 |
+
from tinyllava.eval.run_tiny_llava import eval_model
|
| 140 |
+
|
| 141 |
+
model_path = "bczhou/TinyLLaVA-3.1B"
|
| 142 |
+
|
| 143 |
+
tokenizer, model, image_processor, context_len = load_pretrained_model(
|
| 144 |
+
model_path=model_path,
|
| 145 |
+
model_base=None,
|
| 146 |
+
model_name=get_model_name_from_path(model_path)
|
| 147 |
+
)
|
| 148 |
+
```
|
| 149 |
+
</details>
|
| 150 |
+
|
| 151 |
+
## 🔧 Run Inference
|
| 152 |
+
Here's an example of running inference with [TinyLLaVA-3.1B](https://huggingface.co/bczhou/TinyLLaVA-3.1B)
|
| 153 |
+
<details>
|
| 154 |
+
<summary>Run Inference</summary>
|
| 155 |
+
|
| 156 |
+
```Python
|
| 157 |
+
from tinyllava.model.builder import load_pretrained_model
|
| 158 |
+
from tinyllava.mm_utils import get_model_name_from_path
|
| 159 |
+
from tinyllava.eval.run_tiny_llava import eval_model
|
| 160 |
+
|
| 161 |
+
model_path = "bczhou/TinyLLaVA-3.1B"
|
| 162 |
+
prompt = "What are the things I should be cautious about when I visit here?"
|
| 163 |
+
image_file = "https://llava-vl.github.io/static/images/view.jpg"
|
| 164 |
+
|
| 165 |
+
args = type('Args', (), {
|
| 166 |
+
"model_path": model_path,
|
| 167 |
+
"model_base": None,
|
| 168 |
+
"model_name": get_model_name_from_path(model_path),
|
| 169 |
+
"query": prompt,
|
| 170 |
+
"conv_mode": "phi",
|
| 171 |
+
"image_file": image_file,
|
| 172 |
+
"sep": ",",
|
| 173 |
+
"temperature": 0,
|
| 174 |
+
"top_p": None,
|
| 175 |
+
"num_beams": 1,
|
| 176 |
+
"max_new_tokens": 512
|
| 177 |
+
})()
|
| 178 |
+
|
| 179 |
+
eval_model(args)
|
| 180 |
+
```
|
| 181 |
+
</details>
|
| 182 |
+
|
| 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 |
|
| 190 |
+
|
| 191 |
+
## Evaluation
|
| 192 |
+
To ensure the reproducibility, we evaluate the models with greedy decoding.
|
| 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 |
#### - Prompt Template
|
| 307 |
The model supports multi-image and multi-prompt generation. When using the model, make sure to follow the correct prompt template (`USER: <image>xxx\nASSISTANT:`), where `<image>` token is a place-holding special token for image embeddings.
|
|
|
|
| 347 |
print(processor.decode(output[0][2:], skip_special_tokens=True))
|
| 348 |
```
|
| 349 |
|
|
|
|
|
|
|
|
|
|
| 350 |
## ✏ Citation
|
| 351 |
|
| 352 |
If you find our paper and code useful in your research, please consider giving a star :star: and citation :pencil:.
|
|
|
|
| 360 |
archivePrefix={arXiv},
|
| 361 |
primaryClass={cs.LG}
|
| 362 |
}
|
| 363 |
+
```
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
## β€οΈ Community efforts
|
| 367 |
+
* Our codebase is built upon the [LLaVA](https://github.com/haotian-liu/LLaVA) project. Great work!
|
| 368 |
+
* Our project uses data from the [ShareGPT4V](https://github.com/InternLM/InternLM-XComposer/tree/main/projects/ShareGPT4V) project. Great work!
|
| 369 |
+
|