(
self,
model_id: str,
vision_backbone: DinoSigLIPViTBackbone,
llm_backbone: LLaMa2LLMBackbone,
enable_mixed_precision_training: bool = True,
arch_specifier: str = "gelu-mlp",
**kwargs,
)
| 140 | |
| 141 | class PrismaticVLM(VLM): |
| 142 | def __init__( |
| 143 | self, |
| 144 | model_id: str, |
| 145 | vision_backbone: DinoSigLIPViTBackbone, |
| 146 | llm_backbone: LLaMa2LLMBackbone, |
| 147 | enable_mixed_precision_training: bool = True, |
| 148 | arch_specifier: str = "gelu-mlp", |
| 149 | **kwargs, |
| 150 | ) -> None: |
| 151 | super().__init__( |
| 152 | "prismatic", |
| 153 | model_id, |
| 154 | vision_backbone, |
| 155 | llm_backbone, |
| 156 | enable_mixed_precision_training=enable_mixed_precision_training, |
| 157 | ) |
| 158 | |
| 159 | # Set Weight Initialization Seed for Projector Consistency |
| 160 | torch.manual_seed(vision_backbone.embed_dim) |
| 161 | |
| 162 | # Initialize Projection (Adapter) based on `arch_specifier` |
| 163 | self.arch_specifier = arch_specifier |
| 164 | self.projector = FusedMLPProjector(vision_backbone.embed_dim, llm_backbone.embed_dim) |
| 165 | |
| 166 | # Trackers |
| 167 | self.vision_backbone_requires_grad = False |
| 168 | |
| 169 | # Set Module Keys =>> used in Checkpoint Saving / Model Loading |
| 170 | self.all_module_keys = ["vision_backbone", "llm_backbone", "projector"] |
| 171 | self.trainable_module_keys = [] |
| 172 | |
| 173 | # === Generation Utilities === |
| 174 | # => For computing likelihoods --> get tokens corresponding to "True", "False" and "Yes", "No" |
| 175 | self.string2idx = {} |
| 176 | for trigger_string in ["True", "False", "Yes", "No"] + [chr(ord("A") + i) for i in range(26)]: |
| 177 | token_idx_list = self.llm_backbone.tokenizer.encode(trigger_string, add_special_tokens=False) |
| 178 | assert len(token_idx_list) == 1, f'String "{trigger_string}" is tokenized as more than one token!' |
| 179 | self.string2idx[trigger_string] = token_idx_list[0] |
| 180 | |
| 181 | @classmethod |
| 182 | def from_pretrained( |
nothing calls this directly
no test coverage detected