Views
No views yet

| Architecture | ViT | LLM | Adapter | Token Merge | Resolution |
|---|---|---|---|---|---|
| 🤗SAIL-VL-1.6-8B | 🤗SAILViT-Huge | 🤗Qwen2.5-7B | 2-layer MLP | 2x2 | 448x448xN |
| 🤗SAIL-VL-1.5-2B | 🤗SAILViT-Huge | 🤗Qwen2.5-1.5B | 2-layer MLP | 2x2 | 448x448xN |
| 🤗SAIL-VL-1.5-8B | 🤗InternViT-300M | 🤗Qwen2.5-7B | 2-layer MLP | 2x2 | 448x448xN |
| 🤗SAIL-VL-2B | 🤗InternViT-300M | 🤗Qwen2.5-1.5B | 2-layer MLP | 2x2 | 448x448xN |
| 🤗SAIL-VL-8B | 🤗InternViT-300M | 🤗Qwen2.5-7B | 2-layer MLP | 2x2 | 448x448xN |

| Benchmark | InternVL-2.5-8B | Qwen2.5-VL-7B | InternVL3-8B | Ovis2-8B | SAIL-VL-1.5-8B | SAIL-VL-1.6-8B |
|---|---|---|---|---|---|---|
| OpenCompassAvg | 68.56 | 70.26 | 73.84 | 72.25 | 72.69 | 74.26 |
| Total Avg | 73.84 | 76.02 | 77.55 | 77.08 | 77.41 | 78.62 |
| GeneralQA Avg | 71.37 | 70.15 | 74.44 | 72.83 | 72.64 | 73.56 |
| OCR Avg | 83.19 | 87.33 | 85.21 | 86.87 | 87.20 | 88.11 |
| MMBench_DEV_V11 * | 86.95 | 86.58 | 89.68 | 88.00 | 87.43 | 88.82 |
| MathVista_MINI | 65.00 | 66.30 | 70.60 | 70.90 | 73.60 | 74.50 |
| MMStar * | 62.93 | 63.93 | 68.60 | 64.07 | 69.40 | 69.47 |
| MMMU_VAL * | 54.33 | 50.33 | 56.78 | 56.44 | 50.44 | 53.11 |
| MMVet | 63.58 | 67.20 | 82.57 | 66.97 | 69.77 | 74.72 |
| HallusionBench | 49.14 | 55.97 | 49.00 | 55.92 | 54.03 | 54.96 |
| AI2D_TEST + | 84.42 | 84.00 | 85.17 | 86.82 | 87.37 | 87.50 |
| OCRBench + | 821 | 878 | 883 | 889 | 895 | 910 |
| RealWorldQA * | 69.28 | 67.71 | 70.59 | 72.81 | 72.42 | 75.42 |
| InfoVQA_VAL + | 75.19 | 82.83 | 75.71 | 80.52 | 79.68 | 80.70 |
| ChartQA_TEST + | 86.28 | 89.52 | 88.00 | 87.44 | 89.32 | 89.08 |
| MME * | 83.38 | 82.21 | 86.55 | 82.84 | 83.52 | 80.97 |
| DocVQA_VAL + | 92.05 | 94.84 | 92.03 | 94.21 | 94.17 | 94.86 |
| TextVQA_VAL + | 79.08 | 85.00 | 82.07 | 83.34 | 83.13 | 85.52 |
pip3 install einops transformers timm1import numpy as np
2import torch
3import torchvision.transforms as T
4from PIL import Image
5from torchvision.transforms.functional import InterpolationMode
6from transformers import AutoModel, AutoTokenizer
7
8IMAGENET_MEAN = (0.485, 0.456, 0.406)
9IMAGENET_STD = (0.229, 0.224, 0.225)
10
11def build_transform(input_size):
12 MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
13 transform = T.Compose([
14 T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
15 T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
16 T.ToTensor(),
17 T.Normalize(mean=MEAN, std=STD)
18 ])
19 return transform
20
21def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
22 best_ratio_diff = float('inf')
23 best_ratio = (1, 1)
24 area = width * height
25 for ratio in target_ratios:
26 target_aspect_ratio = ratio[0] / ratio[1]
27 ratio_diff = abs(aspect_ratio - target_aspect_ratio)
28 if ratio_diff < best_ratio_diff:
29 best_ratio_diff = ratio_diff
30 best_ratio = ratio
31 elif ratio_diff == best_ratio_diff:
32 if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
33 best_ratio = ratio
34 return best_ratio
35
36def dynamic_preprocess(image, min_num=1, max_num=10, image_size=448, use_thumbnail=False):
37 orig_width, orig_height = image.size
38 aspect_ratio = orig_width / orig_height
39
40 # calculate the existing image aspect ratio
41 target_ratios = set(
42 (i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
43 i * j <= max_num and i * j >= min_num)
44 target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
45
46 # find the closest aspect ratio to the target
47 target_aspect_ratio = find_closest_aspect_ratio(
48 aspect_ratio, target_ratios, orig_width, orig_height, image_size)
49
50 # calculate the target width and height
51 target_width = image_size * target_aspect_ratio[0]
52 target_height = image_size * target_aspect_ratio[1]
53 blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
54
55 # resize the image
56 resized_img = image.resize((target_width, target_height))
57 processed_images = []
58 for i in range(blocks):
59 box = (
60 (i % (target_width // image_size)) * image_size,
61 (i // (target_width // image_size)) * image_size,
62 ((i % (target_width // image_size)) + 1) * image_size,
63 ((i // (target_width // image_size)) + 1) * image_size
64 )
65 # split the image
66 split_img = resized_img.crop(box)
67 processed_images.append(split_img)
68 assert len(processed_images) == blocks
69 if use_thumbnail and len(processed_images) != 1:
70 thumbnail_img = image.resize((image_size, image_size))
71 processed_images.append(thumbnail_img)
72 return processed_images
73
74def load_image(image_file, input_size=448, max_num=10):
75 image = Image.open(image_file).convert('RGB')
76 transform = build_transform(input_size=input_size)
77 images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
78 pixel_values = [transform(image) for image in images]
79 pixel_values = torch.stack(pixel_values)
80 return pixel_values
81
82path = "BytedanceDouyinContent/SAIL-VL-1d6-8B"
83model = AutoModel.from_pretrained(
84 path,
85 torch_dtype=torch.bfloat16,
86 trust_remote_code=True).eval().cuda()
87tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
88
89# set the max number of tiles in `max_num`
90pixel_values = load_image('./test.png', max_num=10).to(torch.bfloat16).cuda()
91generation_config = dict(max_new_tokens=1024, do_sample=True)
92
93# pure-text conversation
94question = 'Hello, who are you?'
95response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)
96print(f'User: {question} Assistant: {response}')
97
98question = 'Can you tell me a story?'
99response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
100print(f'User: {question} Assistant: {response}')
101
102# single-image single-round conversation
103question = '<image> Please describe the image shortly.'
104response = model.chat(tokenizer, pixel_values, question, generation_config)
105print(f'User: {question} Assistant: {response}')
106
107# single-image multi-round conversation
108question = '<image> Please describe the image in detail.'
109response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
110print(f'User: {question} Assistant: {response}')
111
112question = 'Please write a poem according to the image.'
113response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
114print(f'User: {question} Assistant: {response}')@article{dong2025scalable,
title={Scalable vision language model training via high quality data curation},
author={Dong, Hongyuan and Kang, Zijian and Yin, Weijie and Liang, Xiao and Feng, Chao and Ran, Jiao},
journal={arXiv preprint arXiv:2501.05952},
year={2025}
}@misc{
sailvl,
title = {SAIL-VL: Scalable Vision Language Model Training with High Quality Data Curation},
url = {https://huggingface.co/BytedanceDouyinContent/SAIL-VL-2B/},
author = {Bytedance Douyin Content Team},
month = {December},
year = {2024}
}{Hongyuan Dong, Zijian Kang, Weijie Yin}, Xiao Liang, Chao Feng, Jiao Ran
{*} Equal Contributions.Zirui Guo, Yan Qiu, Yaling Mou, Ming Jiang, Jingwei SunHuiyu Yu, Lin Dong, Yong Zhang