Views
No views yet

| Benchmark | FastVLM-0.5B | FastVLM-1.5B | FastVLM-7B |
|---|---|---|---|
| Ai2D | 68.0 | 77.4 | 83.6 |
| ScienceQA | 85.2 | 94.4 | 96.7 |
| MMMU | 33.9 | 37.8 | 45.4 |
| VQAv2 | 76.3 | 79.1 | 80.8 |
| ChartQA | 76.0 | 80.1 | 85.0 |
| TextVQA | 64.5 | 70.4 | 74.9 |
| InfoVQA | 46.4 | 59.7 | 75.8 |
| DocVQA | 82.5 | 88.3 | 93.2 |
| OCRBench | 63.9 | 70.2 | 73.1 |
| RealWorldQA | 56.1 | 61.2 | 67.2 |
| SeedBench-Img | 71.0 | 74.2 | 75.4 |
huggingface-cli download apple/FastVLM-0.5Bpredict.py from the official repo.1python predict.py --model-path /path/to/checkpoint-dir \
2 --image-file /path/to/image.png \
3 --prompt "Describe the image."trust_remote_code along with the following snippet:1import torch
2from PIL import Image
3from transformers import AutoTokenizer, AutoModelForCausalLM
4
5MID = "apple/FastVLM-0.5B"
6IMAGE_TOKEN_INDEX = -200 # what the model code looks for
7
8# Load
9tok = AutoTokenizer.from_pretrained(MID, trust_remote_code=True)
10model = AutoModelForCausalLM.from_pretrained(
11 MID,
12 torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
13 device_map="auto",
14 trust_remote_code=True,
15)
16
17# Build chat -> render to string (not tokens) so we can place <image> exactly
18messages = [
19 {"role": "user", "content": "<image>\nDescribe this image in detail."}
20]
21rendered = tok.apply_chat_template(
22 messages, add_generation_prompt=True, tokenize=False
23)
24
25pre, post = rendered.split("<image>", 1)
26
27# Tokenize the text *around* the image token (no extra specials!)
28pre_ids = tok(pre, return_tensors="pt", add_special_tokens=False).input_ids
29post_ids = tok(post, return_tensors="pt", add_special_tokens=False).input_ids
30
31# Splice in the IMAGE token id (-200) at the placeholder position
32img_tok = torch.tensor([[IMAGE_TOKEN_INDEX]], dtype=pre_ids.dtype)
33input_ids = torch.cat([pre_ids, img_tok, post_ids], dim=1).to(model.device)
34attention_mask = torch.ones_like(input_ids, device=model.device)
35
36# Preprocess image via the model's own processor
37img = Image.open("test-2.jpg").convert("RGB")
38px = model.get_vision_tower().image_processor(images=img, return_tensors="pt")["pixel_values"]
39px = px.to(model.device, dtype=model.dtype)
40
41# Generate
42with torch.no_grad():
43 out = model.generate(
44 inputs=input_ids,
45 attention_mask=attention_mask,
46 images=px,
47 max_new_tokens=128,
48 )
49
50print(tok.decode(out[0], skip_special_tokens=True))@InProceedings{fastvlm2025,
author = {Pavan Kumar Anasosalu Vasu, Fartash Faghri, Chun-Liang Li, Cem Koc, Nate True, Albert Antony, Gokul Santhanam, James Gabriel, Peter Grasch, Oncel Tuzel, Hadi Pouransari},
title = {FastVLM: Efficient Vision Encoding for Vision Language Models},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2025},
}