vqwen-qformer-pretrain

Foundation checkpoint — not a deployable chat model. Only the Linear projector has been trained. Use this as the starting point for stage-2 instruction tuning. For ready-to-use TikTok sludge classifiers built on top of this foundation, see:

Loads as a stock Blip2ForConditionalGeneration — no trust_remote_code.


Architecture

Image (224×224)
    → EVA-CLIP-G/14         (frozen, from Salesforce/blip2-opt-2.7b)   → (B, 257, 1408)
    → Q-Former 12-layer     (frozen, 32 pretrained query tokens)        → (B, 32, 768)
    → Linear 768 → 2560     (trained — the only delta in this checkpoint)
    → Qwen3-4B              (frozen)

Trainable parameter count: ~2 M (one Linear(768, 2560)). Everything else is loaded unchanged from its base checkpoint.

The vision tower is EVA-CLIP-G/14 (BAAI's EVA-01-CLIP-g/14, accessed through the BLIP-2 bundle); hidden_size = 1408. The 32 in (B, 32, …) is the Q-Former sequence length (learnable query tokens), not a feature dim.

Intended use

  • Serve as the alignment foundation for stage-2 instruction tuning (LoRA on the LLM + continued projector training). The frozen vision+Q-Former features are already aligned to Qwen3's embedding space.
  • Emit short BLIP-style captions for images when prompted in the training-time "plain" format.

This model is not instruction-following. It has never seen chat-formatted supervision; expect caption-like free-form output, not yes/no or structured answers.

Usage

For stage-2 fine-tuning (recommended), load language_projection weights as your starting projector. See the training code at github.com/alpharomercoma/vqwen-qformer (scripts 10b + 14) for a worked example.

For caption-style inference:

import torch
from PIL import Image
from transformers import Blip2ForConditionalGeneration, AutoProcessor

MODEL_ID = "alpharomercoma/vqwen-qformer-pretrain"
model = Blip2ForConditionalGeneration.from_pretrained(MODEL_ID, dtype=torch.bfloat16, device_map="auto")
processor = AutoProcessor.from_pretrained(MODEL_ID)

image = Image.open("image.jpg").convert("RGB")
messages = [{
    "role": "user",
    "content": [
        {"type": "image"},
        {"type": "text", "text": "Describe this image."},
    ],
}]
prompt = processor.tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = processor(text=prompt, images=image, return_tensors="pt").to(model.device)
inputs["pixel_values"] = inputs["pixel_values"].to(dtype=torch.bfloat16)
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Training

  • Dataset: liuhaotian/LLaVA-Pretrain — 558 K BLIP-captioned image–text pairs (LAION / CC / SBU). Plain conversation format: <image> on the human turn, caption on the assistant turn, loss masked on the human side.
  • Hardware: single NVIDIA H200 141 GB, bf16, SDPA attention, fused AdamW, Liger-Kernel.
Global batch size 256 (per_device=128 × grad_accum=2)
Learning rate 1e-4 cosine, warmup 0.03
Weight decay 0.05
Optimizer fused AdamW
Epochs 1 (2,181 steps)
Max sequence length 2,048
Precision bf16

Loss curve: ~7.5 → ~3.58 over 2,181 steps (typical MiniGPT-4 / LLaVA stage-1 trajectory).

Limitations

  • Not instruction-following. Will not reliably follow yes/no prompts.
  • Not domain-specialised. This is the generic alignment checkpoint — pre-any task fine-tuning.
  • Output is short, BLIP-style; not multi-turn.

Citation

@misc{vqwenqformerpretrain,
  author    = {Olata, Marc and Coma, Alpha Romer and Ong, Job Isaac and Sioson, Kristoffer Ian},
  title     = {Visual-Qwen stage-1: feature-alignment foundation},
  year      = {2026},
  publisher = {FEU Institute of Technology}
}

Underlying components / recipe:

  • BLIP-2 (Li et al., 2023, arXiv:2301.12597)
  • EVA-CLIP (Sun et al., 2023, arXiv:2303.15389)
  • Qwen3 (Yang et al., 2025; Qwen Team)
  • Recipe follows MiniGPT-4 (Zhu et al., 2023, arXiv:2304.10592) and LLaVA-1.5 (Liu et al., 2023, arXiv:2310.03744) stage-1 alignment, with a single Linear(768, 2560) projector instead of an MLP (the Q-Former is already a trained adapter).

License

Apache 2.0 for the trained projector. Base models retain original licenses: Salesforce/blip2-opt-2.7b (BSD-3), Qwen/Qwen3-4B (Apache 2.0). Dataset license per liuhaotian/LLaVA-Pretrain.

Downloads last month
1
Safetensors
Model size
5B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for alpharomercoma/vqwen-qformer-pretrain

Finetuned
Qwen/Qwen3-4B
Finetuned
(692)
this model

Dataset used to train alpharomercoma/vqwen-qformer-pretrain

Papers for alpharomercoma/vqwen-qformer-pretrain