Upload config
Browse files- README.md +199 -0
- config.json +53 -0
- configuration_prismatic.py +143 -0
README.md
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
tags: []
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
### Model Description
|
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 |
+
- **Developed by:** [More Information Needed]
|
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 |
+
### Model Sources [optional]
|
29 |
+
|
30 |
+
<!-- Provide the basic links for the model. -->
|
31 |
+
|
32 |
+
- **Repository:** [More Information Needed]
|
33 |
+
- **Paper [optional]:** [More Information Needed]
|
34 |
+
- **Demo [optional]:** [More Information Needed]
|
35 |
+
|
36 |
+
## Uses
|
37 |
+
|
38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
+
|
40 |
+
### Direct Use
|
41 |
+
|
42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
+
|
44 |
+
[More Information Needed]
|
45 |
+
|
46 |
+
### Downstream Use [optional]
|
47 |
+
|
48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
+
|
50 |
+
[More Information Needed]
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
## Bias, Risks, and Limitations
|
59 |
+
|
60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Recommendations
|
65 |
+
|
66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
+
|
68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
+
|
70 |
+
## How to Get Started with the Model
|
71 |
+
|
72 |
+
Use the code below to get started with the model.
|
73 |
+
|
74 |
+
[More Information Needed]
|
75 |
+
|
76 |
+
## Training Details
|
77 |
+
|
78 |
+
### Training Data
|
79 |
+
|
80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
+
|
82 |
+
[More Information Needed]
|
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 |
+
#### Preprocessing [optional]
|
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 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
## Model Card Contact
|
198 |
+
|
199 |
+
[More Information Needed]
|
config.json
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"arch_specifier": "no-align+fused-gelu-mlp",
|
3 |
+
"architectures": [
|
4 |
+
"PrismaticForConditionalGeneration"
|
5 |
+
],
|
6 |
+
"auto_map": {
|
7 |
+
"AutoConfig": "configuration_prismatic.PrismaticConfig"
|
8 |
+
},
|
9 |
+
"hf_llm_id": "meta-llama/Llama-3.2-1B",
|
10 |
+
"image_resize_strategy": "letterbox",
|
11 |
+
"image_sizes": [
|
12 |
+
224,
|
13 |
+
224
|
14 |
+
],
|
15 |
+
"llm_backbone_id": "llama3.2-1b",
|
16 |
+
"llm_max_length": 2048,
|
17 |
+
"model_type": "prismatic",
|
18 |
+
"output_projector_states": false,
|
19 |
+
"pad_to_multiple_of": 64,
|
20 |
+
"pad_token_id": 128256,
|
21 |
+
"text_config": {
|
22 |
+
"architectures": [
|
23 |
+
"LlamaForCausalLM"
|
24 |
+
],
|
25 |
+
"bos_token_id": 128000,
|
26 |
+
"eos_token_id": 128001,
|
27 |
+
"head_dim": 64,
|
28 |
+
"hidden_size": 2048,
|
29 |
+
"intermediate_size": 8192,
|
30 |
+
"max_position_embeddings": 131072,
|
31 |
+
"model_type": "llama",
|
32 |
+
"num_hidden_layers": 16,
|
33 |
+
"num_key_value_heads": 8,
|
34 |
+
"pad_token_id": 128256,
|
35 |
+
"rms_norm_eps": 1e-05,
|
36 |
+
"rope_theta": 500000.0,
|
37 |
+
"tie_word_embeddings": true,
|
38 |
+
"torch_dtype": "bfloat16",
|
39 |
+
"vocab_size": 128320
|
40 |
+
},
|
41 |
+
"timm_model_ids": [
|
42 |
+
"vit_large_patch14_reg4_dinov2.lvd142m",
|
43 |
+
"vit_so400m_patch14_siglip_224"
|
44 |
+
],
|
45 |
+
"timm_override_act_layers": [
|
46 |
+
null,
|
47 |
+
null
|
48 |
+
],
|
49 |
+
"torch_dtype": "bfloat16",
|
50 |
+
"transformers_version": "4.45.1",
|
51 |
+
"use_fused_vision_backbone": true,
|
52 |
+
"vision_backbone_id": "dinosiglip-vit-so-224px"
|
53 |
+
}
|
configuration_prismatic.py
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
configuration_prismatic.py
|
3 |
+
|
4 |
+
HuggingFace-style configuration definition for Prismatic VLMs, inheriting from `transformers.PretrainedConfig`.
|
5 |
+
Default configuration specifies `siglip-224px+7b`.
|
6 |
+
"""
|
7 |
+
|
8 |
+
from typing import Any, Dict, List, Optional
|
9 |
+
|
10 |
+
from transformers import PretrainedConfig
|
11 |
+
from transformers.models.auto import CONFIG_MAPPING
|
12 |
+
|
13 |
+
# === Utilities for Mapping Prismatic names to HF names ===
|
14 |
+
# fmt: off
|
15 |
+
VISION_BACKBONE_TO_RESOLUTION: Dict[str, List[int]] = {
|
16 |
+
"clip-vit-l": [224], "siglip-vit-so400m": [224], "dinov2-vit-l": [224], "in1k-vit-l": [224],
|
17 |
+
|
18 |
+
"clip-vit-l-336px": [336],
|
19 |
+
"siglip-vit-so400m-384px": [384],
|
20 |
+
|
21 |
+
"dinoclip-vit-l-336px": [336, 336],
|
22 |
+
"dinosiglip-vit-so-224px": [224, 224],
|
23 |
+
"dinosiglip-vit-so-384px": [384, 384],
|
24 |
+
}
|
25 |
+
VISION_BACKBONE_TO_TIMM_ID: Dict[str, List[str]] = {
|
26 |
+
"clip-vit-l": ["vit_large_patch14_clip_224.openai"],
|
27 |
+
"clip-vit-l-336px": ["vit_large_patch14_clip_336.openai"],
|
28 |
+
|
29 |
+
"dinov2-vit-l": ["vit_large_patch14_reg4_dinov2.lvd142m"],
|
30 |
+
"in1k-vit-l": ["vit_large_patch16_224.augreg_in21k_ft_in1k"],
|
31 |
+
|
32 |
+
"siglip-vit-so400m": ["vit_so400m_patch14_siglip_224"],
|
33 |
+
"siglip-vit-so400m-384px": ["vit_so400m_patch14_siglip_384"],
|
34 |
+
|
35 |
+
"dinoclip-vit-l-336px": ["vit_large_patch14_reg4_dinov2.lvd142m", "vit_large_patch14_clip_336.openai"],
|
36 |
+
"dinosiglip-vit-so-224px": ["vit_large_patch14_reg4_dinov2.lvd142m", "vit_so400m_patch14_siglip_224"],
|
37 |
+
"dinosiglip-vit-so-384px": ["vit_large_patch14_reg4_dinov2.lvd142m", "vit_so400m_patch14_siglip_384"],
|
38 |
+
}
|
39 |
+
TIMM_OVERRIDE_ACT_LAYER: Dict[str, List[Optional[str]]] = {
|
40 |
+
"clip-vit-l": ["quick_gelu"], "clip-vit-l-336px": ["quick_gelu"],
|
41 |
+
"dinov2-vit-l": [None], "in1k-vit-l": [None],
|
42 |
+
"siglip-vit-so400m": [None], "siglip-vit-so400m-384px": [None],
|
43 |
+
"dinoclip-vit-l-336px": [None, "quick_gelu"],
|
44 |
+
"dinosiglip-vit-so-224px": [None, None], "dinosiglip-vit-so-384px": [None, None]
|
45 |
+
}
|
46 |
+
|
47 |
+
LLM_BACKBONE_TO_HF_PATH = {
|
48 |
+
"llama2-7b-pure": "meta-llama/Llama-2-7b-hf", "llama2-13b-pure": "meta-llama/Llama-2-13b-hf",
|
49 |
+
"llama2-7b-chat": "meta-llama/Llama-2-7b-chat-hf", "llama2-13b-chat": "meta-llama/Llama-2-13b-chat-hf",
|
50 |
+
"llama3.2-1b": "meta-llama/Llama-3.2-1B",
|
51 |
+
|
52 |
+
|
53 |
+
"vicuna-v15-7b": "lmsys/vicuna-7b-v1.5", "vicuna-v15-13b": "lmsys/vicuna-13b-v1.5",
|
54 |
+
|
55 |
+
"mistral-v0.1-7b-pure": "mistralai/Mistral-7B-v0.1",
|
56 |
+
"mistral-v0.1-7b-instruct": "mistralai/Mistral-7B-Instruct-v0.1",
|
57 |
+
|
58 |
+
"phi-2-3b": "microsoft/phi-2",
|
59 |
+
}
|
60 |
+
LLM_BACKBONE_TO_HF_METACLASS = {
|
61 |
+
"llama2-7b-pure": "llama", "llama2-13b-pure": "llama", "llama2-7b-chat": "llama", "llama2-13b-chat": "llama",
|
62 |
+
"vicuna-v15-7b": "llama", "vicuna-v15-13b": "llama",
|
63 |
+
"llama3.2-1b": "llama",
|
64 |
+
|
65 |
+
"mistral-v0.1-7b-pure": "mistral", "mistral-v0.1-7b-instruct": "mistral",
|
66 |
+
|
67 |
+
"phi-2-3b": "phi",
|
68 |
+
}
|
69 |
+
|
70 |
+
VALID_VISION_BACKBONES = set(VISION_BACKBONE_TO_RESOLUTION.keys())
|
71 |
+
VALID_LLM_BACKBONES = set(LLM_BACKBONE_TO_HF_PATH)
|
72 |
+
# fmt: on
|
73 |
+
|
74 |
+
|
75 |
+
class PrismaticConfig(PretrainedConfig):
|
76 |
+
model_type: str = "prismatic"
|
77 |
+
is_composition: bool = False
|
78 |
+
|
79 |
+
def __init__(
|
80 |
+
self,
|
81 |
+
vision_backbone_id: str = "siglip-vit-so400m",
|
82 |
+
llm_backbone_id: str = "vicuna-v15-7b",
|
83 |
+
arch_specifier: str = "no-align+gelu-mlp",
|
84 |
+
use_fused_vision_backbone: Optional[bool] = None,
|
85 |
+
image_resize_strategy: str = "letterbox",
|
86 |
+
text_config: Optional[Dict[str, Any]] = None,
|
87 |
+
llm_max_length: int = 2048,
|
88 |
+
pad_token_id: int = 32000,
|
89 |
+
pad_to_multiple_of: int = 64,
|
90 |
+
output_projector_states: bool = False,
|
91 |
+
**kwargs: str,
|
92 |
+
) -> None:
|
93 |
+
if vision_backbone_id not in VALID_VISION_BACKBONES:
|
94 |
+
raise ValueError(f"Vision backbone `{vision_backbone_id}` not in {VALID_VISION_BACKBONES = }")
|
95 |
+
|
96 |
+
if llm_backbone_id not in VALID_LLM_BACKBONES:
|
97 |
+
raise ValueError(f"LLM backbone `{llm_backbone_id}` not in {VALID_LLM_BACKBONES = }")
|
98 |
+
|
99 |
+
# Set Prismatic Configuration Fields
|
100 |
+
self.vision_backbone_id = vision_backbone_id
|
101 |
+
self.llm_backbone_id = llm_backbone_id
|
102 |
+
self.arch_specifier = arch_specifier
|
103 |
+
self.output_projector_states = output_projector_states
|
104 |
+
|
105 |
+
# [Contract] All vision backbone parameters are lists =>> supports fused backbones with different preprocessing
|
106 |
+
self.use_fused_vision_backbone = (
|
107 |
+
use_fused_vision_backbone
|
108 |
+
if use_fused_vision_backbone is not None
|
109 |
+
else any(self.vision_backbone_id.startswith(v) for v in ["dinoclip", "dinosiglip"])
|
110 |
+
)
|
111 |
+
|
112 |
+
self.timm_model_ids = VISION_BACKBONE_TO_TIMM_ID[self.vision_backbone_id]
|
113 |
+
self.timm_override_act_layers = TIMM_OVERRIDE_ACT_LAYER[self.vision_backbone_id]
|
114 |
+
self.image_sizes = VISION_BACKBONE_TO_RESOLUTION[self.vision_backbone_id]
|
115 |
+
self.image_resize_strategy = image_resize_strategy
|
116 |
+
|
117 |
+
self.hf_llm_id = LLM_BACKBONE_TO_HF_PATH[self.llm_backbone_id]
|
118 |
+
self.llm_max_length = llm_max_length
|
119 |
+
self.pad_token_id, self.pad_to_multiple_of = pad_token_id, pad_to_multiple_of
|
120 |
+
|
121 |
+
# [IMPORTANT] HF Utilities actually look for a `text_config` field... we need to use that specific naming!
|
122 |
+
self.text_config = (
|
123 |
+
CONFIG_MAPPING[LLM_BACKBONE_TO_HF_METACLASS[self.llm_backbone_id]](**text_config)
|
124 |
+
if text_config is not None
|
125 |
+
else CONFIG_MAPPING[LLM_BACKBONE_TO_HF_METACLASS[self.llm_backbone_id]]()
|
126 |
+
)
|
127 |
+
|
128 |
+
# Dispatch **kwargs to super() =>> note that `pad_token_id` collides, so we pass it in here as well...
|
129 |
+
super().__init__(pad_token_id=pad_token_id, **kwargs)
|
130 |
+
|
131 |
+
|
132 |
+
class OpenVLAConfig(PrismaticConfig):
|
133 |
+
model_type: str = "openvla"
|
134 |
+
|
135 |
+
def __init__(
|
136 |
+
self,
|
137 |
+
norm_stats: Optional[Dict[str, Dict[str, Dict[str, Dict[str, List[float]]]]]] = None,
|
138 |
+
n_action_bins: int = 256,
|
139 |
+
**kwargs: str,
|
140 |
+
) -> None:
|
141 |
+
self.norm_stats, self.n_action_bins = norm_stats, n_action_bins
|
142 |
+
|
143 |
+
super().__init__(**kwargs)
|