--- library_name: transformers base_model: DAMO-NLP-SG/VideoLLaMA3-7B tags: - video - token-compression - videollama3 --- # phase1_qbase_internvid (native-res, video-only, 2 epochs) Phase 1 of the qbase video-token compressor curriculum: a learned-query compressor ("qbase") inserted between the frozen SigLIP-NaViT vision encoder and the frozen Qwen2-7B LLM of VideoLLaMA3-7B, trained with caption cross-entropy. > **This repo was re-used.** The repo name previously referred to an older Phase-1 run > (16384-token video budget, 40 % still images, 3 epochs / 3,441 steps); no weights from > that run were ever uploaded here. Everything in this repo is the run described below. This checkpoint needs the custom code in the training repository (`videollama3/model`, `Videollama3Qwen2ForCausalLM` with `token_compressor`); it does not load with stock `transformers` alone. ## What is trained | module | status | |---|---| | vision encoder (SigLIP-NaViT) | frozen | | `token_compressor` (qbase, 170M) | trained | | `mm_projector` (mlp2x_gelu, 17M) | trained | | `<\|compression_start\|>` / `<\|compression_end\|>` embedding rows | trained (all other rows frozen) | | LLM (Qwen2-7B) + `lm_head` | frozen | Warm start: `SamChen567/compressor_pretrain_video_norm` (qbase + projector + the two embedding rows). ## Compressor - `transformer_decoder_flat`: 8 layers, 8 heads, hidden 1152, **K = 64** learned queries (+ sin/cos position encoding); cross-attention onto the segment's encoder tokens with (t, h, w) RoPE. - **Adaptive segmentation** (non-learned): `N = ⌊T/4⌋ + 1` segments per video, a forced cut every 8 frames, remaining cuts at the largest consecutive-frame cosine distance of the per-frame mean encoder feature. Each segment is 1–8 frames. Deterministic top-k (`segment_sample_tau = 0`). - **Option A** (`match_encoder_scale`): output rescaled to the encoder tokens' per-dim mean/std, then a learnable per-channel γ/β. - **Option B** (`distr_loss_weight = 0.05`): CORAL-style distribution-match auxiliary loss (see the note on its effective weight below). ## Input layout seen by the LLM Each segment carries its own time range (`segment_time_marks = True`); the per-frame `Time X.0s:` text of the uncompressed template is removed: ``` <|im_start|>user Time:0s-3s:<|compression_start|>[64]<|compression_end|>Time:4s-4s:<|compression_start|>[64]<|compression_end|> ... {prompt}<|im_end|> <|im_start|>assistant {caption}<|im_end|> ``` Seconds are integers (first / last frame of the segment). Example: a 120 s clip at 1 fps → 31 segments → 1,984 compressed tokens (vs. 35,880 uncompressed at 640×360). Checkpoints trained before 2026-10-12 used one whole-video range instead; build the layout from this checkpoint's `config.json`. ## Data - InternVid clips **< 180 s**, 264,186 samples, **video only** (no still images). - Captions re-generated by **Qwen3-VL-8B-Instruct at 1 fps, native resolution**, with several prompt styles (`baseline_default`, `scene_shift`, `motion_scene`, ...). - One turn per sample: `