Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
+
base_model:
|
| 7 |
+
- InternRobotics/G2VLM-2B-MoT
|
| 8 |
+
datasets:
|
| 9 |
+
- nyu-visionx/VSI-590K
|
| 10 |
+
tags:
|
| 11 |
+
- multimodal
|
| 12 |
+
- spatial-reasoning
|
| 13 |
+
- vsi-bench
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# G2VLM-2B-MoT finetuned on VSI-590K
|
| 17 |
+
|
| 18 |
+
Finetuned weights for [InternRobotics/G2VLM-2B-MoT](https://huggingface.co/InternRobotics/G2VLM-2B-MoT)
|
| 19 |
+
on a balanced video subset of [VSI-590K](https://huggingface.co/datasets/nyu-visionx/VSI-590K),
|
| 20 |
+
trained as a video spatial-reasoning baseline (VSI-Bench style questions).
|
| 21 |
+
|
| 22 |
+
These are **delta checkpoints**: each file holds only the tensors that were finetuned (395 tensors,
|
| 23 |
+
1.78B parameters, fp32) and is loaded on top of the original G2VLM-2B-MoT weights.
|
| 24 |
+
|
| 25 |
+
## Files
|
| 26 |
+
|
| 27 |
+
| Path | Training | Steps | Samples seen |
|
| 28 |
+
|---|---|---|---|
|
| 29 |
+
| `ft2ep_vsi590k_bal/delta_final.safetensors` | 2 epochs over the subset | 3,500 | 28,000 |
|
| 30 |
+
| `ft_vsi590k_bal/delta_final.safetensors` | short run (100 min budget) | 366 | 2,928 |
|
| 31 |
+
|
| 32 |
+
Each folder also has a `train_log.json` with the per-step loss and the training arguments.
|
| 33 |
+
`ft2ep_vsi590k_bal` is the longer run and the one to use by default.
|
| 34 |
+
|
| 35 |
+
## Training setup
|
| 36 |
+
|
| 37 |
+
- **Data:** 14,000 video QA samples from VSI-590K, 2,000 for each of 7 question types
|
| 38 |
+
(`absolute_count`, `absolute_distance_object`, `absolute_size_object`, `absolute_size_room`,
|
| 39 |
+
`relative_distance_object`, `relative_direction_object`, `appearance_order`), drawn from the
|
| 40 |
+
ScanNet, ScanNet++ v2 and ARKitScenes training videos, shuffled with seed 0. No scene overlaps with
|
| 41 |
+
the VSI-Bench test set.
|
| 42 |
+
- **Input:** 16 uniformly sampled frames per video, official `chat_with_recon` layout
|
| 43 |
+
(both the semantic and the geometry branch see the frames).
|
| 44 |
+
- **Trainable parameters:** the semantic (understanding) expert of the language model, including the
|
| 45 |
+
token embeddings and LM head. The geometry expert, DINO encoder, ViT and 3D heads stay frozen.
|
| 46 |
+
- **Optimisation:** AdamW (betas 0.9/0.95, no weight decay), learning rate 2e-5 with cosine decay to
|
| 47 |
+
10%, 50 warmup steps (20 for the short run), effective batch size 8 (2 GPUs x 4 accumulation
|
| 48 |
+
steps), cross-entropy loss on the answer tokens only.
|
| 49 |
+
|
| 50 |
+
## Usage
|
| 51 |
+
|
| 52 |
+
Clone the [G2VLM code](https://github.com/InternRobotics/G2VLM) (tested at commit `a45f2f4`),
|
| 53 |
+
download the base model, then load a delta on top of it:
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
from huggingface_hub import hf_hub_download, snapshot_download
|
| 57 |
+
from safetensors.torch import load_file
|
| 58 |
+
from g2vlm_utils import load_model_and_tokenizer_from_path # from the G2VLM repo
|
| 59 |
+
|
| 60 |
+
base = snapshot_download("InternRobotics/G2VLM-2B-MoT")
|
| 61 |
+
model, tokenizer, new_token_ids, vit_transform, dino_transform = load_model_and_tokenizer_from_path(base)
|
| 62 |
+
|
| 63 |
+
delta = load_file(hf_hub_download("RunyiY/G2VLM", "ft2ep_vsi590k_bal/delta_final.safetensors"))
|
| 64 |
+
msg = model.load_state_dict(delta, strict=False)
|
| 65 |
+
assert not msg.unexpected_keys
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
The delta keys are plain `G2VLM` state-dict names (`language_model.*`), so
|
| 69 |
+
`load_state_dict(..., strict=False)` works on any `G2VLM` instance built from the base config.
|
| 70 |
+
|
| 71 |
+
Inference then follows the official `inference_chat.py`. Prompts used for finetuning are the
|
| 72 |
+
VSI-Bench style ones: the question followed by "Answer with the option's letter from the given
|
| 73 |
+
choices directly." for multiple choice, or "Please answer the question using a single word or
|
| 74 |
+
phrase." for numerical answers.
|
| 75 |
+
|
| 76 |
+
### Patches needed for training
|
| 77 |
+
|
| 78 |
+
Finetuning the released code needed two one-line fixes (not needed for inference):
|
| 79 |
+
|
| 80 |
+
- `modeling/g2vlm/g2vlm.py`, in `G2VLM.forward`: the returned `mse=mse` refers to an undefined
|
| 81 |
+
variable when only the text loss is used; replace with `mse=None`.
|
| 82 |
+
- `modeling/g2vlm/qwen2vl.py`, in `Qwen2VLModel.forward_train`: guard the hidden-state collection
|
| 83 |
+
with `if output_hidden_states and intermediate_layers is not None:`.
|
| 84 |
+
|
| 85 |
+
## License
|
| 86 |
+
|
| 87 |
+
Apache 2.0, following the base model.
|