benchang1110
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
# Model Card for Model ID
|
@@ -11,189 +15,101 @@ tags: []
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
<!-- Provide a longer summary of what this model is. -->
|
17 |
-
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
|
20 |
-
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
##
|
|
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
43 |
|
44 |
-
[More Information Needed]
|
45 |
|
46 |
-
### Downstream Use [optional]
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
##
|
|
|
|
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
###
|
|
|
65 |
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
### Training Procedure
|
85 |
-
|
86 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
|
195 |
-
|
|
|
|
|
196 |
|
197 |
-
## Model Card Contact
|
198 |
|
199 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
datasets:
|
4 |
+
- benchang1110/TaiVision-pretrain-1M
|
5 |
+
language:
|
6 |
+
- zh
|
7 |
+
pipeline_tag: image-text-to-text
|
8 |
---
|
9 |
|
10 |
# Model Card for Model ID
|
|
|
15 |
|
16 |
## Model Details
|
17 |
|
18 |
+
## English
|
19 |
+
# TaiVisionLM: The First of Its Kind! 🚀
|
|
|
|
|
|
|
20 |
|
21 |
+
🌟 This is a very fast and small (only 1.2B parameters) visual language model on Hugging Face that responds to Traditional Chinese instructions given an image input! 🌟
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
✨ Developed compatible with the Transformers library, TaiVisionLM is a breeze to load, fine-tune, and use for lightning-fast inferences—all without needing any external libraries! ⚡️
|
24 |
|
25 |
+
Ready to experience the Traditional Chinese visual language model? Let's go! 🖼️🤖
|
26 |
|
|
|
|
|
|
|
27 |
|
28 |
+
## Traditional Chinese
|
29 |
+
# 臺視: 首創獨一無二的視覺語言模型!! 🚀
|
30 |
|
31 |
+
🌟 TaiVisionLM 是一個非常快速且小巧的視覺語言模型(僅有 12 億參數),在 Hugging Face 上可以根據圖像輸入來回應繁體中文指令!🌟
|
32 |
|
33 |
+
✨ TaiVisionLM 與 Transformers 完全相容,易於載入、微調和使用,用於快速推理——不需要任何外部庫!⚡️
|
34 |
|
35 |
+
準備好體驗這個繁體中文視覺語言模型了嗎?讓我們開始吧!🖼️🤖
|
36 |
|
|
|
37 |
|
|
|
38 |
|
39 |
+
---
|
40 |
|
41 |
+
# Model Details
|
42 |
|
43 |
+
## English
|
44 |
+
This model is a multimodal large language model that combines [SigLIP](https://huggingface.co/docs/transformers/en/model_doc/siglip) as its vision encoder with [Tinyllama](https://huggingface.co/benchang1110/Taiwan-tinyllama-v1.0-chat) as its language model. The vision projector connects the two modalities together.
|
45 |
+
Its architecture closely resembles [PaliGemma](https://huggingface.co/docs/transformers/v4.44.0/model_doc/paligemma).
|
46 |
|
47 |
+
Here's the summary of the development process:
|
48 |
|
49 |
+
1) **Unimodal pretraining**
|
50 |
+
- In this stage, instead of pretraining both modalities from scratch, I leverage the image encoder from [google/siglip-base-patch16-224-multilingual](https://huggingface.co/google/siglip-base-patch16-224-multilingual) and the language model trained by ourselves (https://huggingface.co/benchang1110/Taiwan-tinyllama-v1.0-chat).
|
51 |
+
2) **Feature Alignment**
|
52 |
+
- Following the [LLaVA training recipe](https://github.com/haotian-liu/LLaVA?tab=readme-ov-file#train), I train the vision projector using 1B image-text pairs to align visual and textual features.
|
53 |
+
3) **Task Specific Training**
|
54 |
+
- The aligned model undergoes further training for tasks such as short captioning, detailed captioning, and simple visual question answering, using over 1M image-prompt-completion triplets.
|
55 |
+
We will undergo this stage after the dataset is ready!
|
56 |
|
57 |
+
## 中文
|
58 |
+
這個模型是一個多模態的語言模型,結合了 [SigLIP](https://huggingface.co/docs/transformers/en/model_doc/siglip) 作為其視覺編碼器,並使用 [Tinyllama](https://huggingface.co/benchang1110/Taiwan-tinyllama-v1.0-chat) 作為語言模型。視覺投影器將這兩種模態結合在一起。
|
59 |
+
其架構與 [PaliGemma](https://huggingface.co/docs/transformers/v4.44.0/model_doc/paligemma) 非常相似。
|
60 |
|
61 |
+
以下是開發過程的摘要:
|
62 |
|
63 |
+
1) **單模態預訓練**
|
64 |
+
- 在這個階段,我利用了 [google/siglip-base-patch16-224-multilingual](https://huggingface.co/google/siglip-base-patch16-224-multilingual) 的圖像編碼器,以及我們自己訓練的語言模型([Taiwan-tinyllama-v1.0-chat](https://huggingface.co/benchang1110/Taiwan-tinyllama-v1.0-chat))。
|
65 |
+
2) **特徵對齊**
|
66 |
+
- ���據 [LLaVA](https://github.com/haotian-liu/LLaVA?tab=readme-ov-file#train),我使用 10 億個圖文配對數據來訓練視覺投影器,以對齊視覺和文本特徵。
|
67 |
+
3) **任務特定訓練**
|
68 |
+
- 對齊後的模型進行進一步的訓練,針對短描述、詳細描述和簡單視覺問答等任務,使用超過 100 萬組圖像-提示-完成三元組數據進行訓練。我們將在數據集準備好後進行這一階段的訓練!
|
69 |
|
70 |
+
### Model Description
|
71 |
+
<!-- Provide a longer summary of what this model is. -->
|
72 |
|
73 |
+
- **Developed by:** [ucsahin](https://huggingface.co/benchang1110)
|
74 |
+
- **Model type:** [Image-Text-to-Text](https://huggingface.co/tasks/image-text-to-text)
|
75 |
+
- **Language(s) (NLP):** *Turkish*
|
76 |
+
- **License:** *Apache license 2.0*
|
77 |
|
78 |
+
---
|
79 |
|
80 |
## How to Get Started with the Model
|
81 |
|
82 |
+
In Transformers, you can load the model and do inference as follows:
|
83 |
|
84 |
+
**IMPORTANT NOTE:** TaiVisionLM model is not yet integrated natively into the Transformers library. So you need to set ```trust_remote_code=True``` when loading the model. It will download the ```configuration_taivisionlm.py```, ```modeling_taivisionlm.py``` and ```processing_taivisionlm.py``` files from the repo. You can check out the content of these files under the *Files and Versions* tab and pin the specific versions if you have any concerns regarding malicious code.
|
85 |
|
86 |
+
```python
|
87 |
+
from transformers import AutoProcessor, AutoModelForCausalLM, AutoConfig
|
88 |
+
from PIL import Image
|
89 |
+
import requests
|
90 |
+
import torch
|
91 |
|
92 |
+
config = AutoConfig.from_pretrained("benchang1110/TaiVision-base",trust_remote_code=True)
|
93 |
+
processor = AutoProcessor.from_pretrained("benchang1110/TaiVision-base",trust_remote_code=True)
|
94 |
+
model = AutoModelForCausalLM.from_pretrained("benchang1110/TaiVision-base",trust_remote_code=True,torch_dtype=torch.float16,attn_implementation="sdpa").to('cuda')
|
95 |
+
model.eval()
|
96 |
+
url = "https://media.wired.com/photos/598e35fb99d76447c4eb1f28/master/pass/phonepicutres-TA.jpg"
|
97 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
98 |
+
text = "描述圖片"
|
99 |
+
inputs = processor(text=text,images=image, return_tensors="pt",padding=False).to('cuda')
|
100 |
+
outputs = processor.tokenizer.decode(model.generate(**inputs,max_length=512)[0])
|
101 |
+
print(outputs)
|
102 |
+
```
|
103 |
|
104 |
### Training Procedure
|
|
|
105 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
106 |
+
The following training hyperparameters are used in feature alignment and task specific training stages respectively:
|
107 |
|
108 |
+
- **Feature Alignment**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
| Data size | Global Batch Size | Learning Rate | Epochs | Max Length | Weight Decay |
|
111 |
+
|--------------|-------------------|---------------|--------|------------|--------------|
|
112 |
+
| 1B | 16 | 5e-4 | 1 | 2048 | 1e-5 |
|
113 |
|
|
|
114 |
|
115 |
+
We use full-parameter finetuning for the projector and apply LoRA to the language model.
|