Introduction
SAIL-VL is a state-of-the-art vision-language model (VLM) developed by the Bytedance Douyin Content Team. The goal of SAIL-VL is to develope a high-performance vision language model that facilitates deployment on mobile devices and ensures accessibility and affordability for a broad audience. Through careful tuning of data and training recipes, SAIL-VL demonstrates that even a small VLM can benefit significantly from data scaling. Our model outperforms Qwen2-VL, InternVL2 and even recent SoTA models of comparable sizes. Details and stronger models are comming soon~
In a word, SAIL-VL is a foundational VLM for vision-language applications. Welcome to explore its capabilities and feel free to contact us for any questions or opportunities.
News๐๐๐
- 2024-12-25: ๐ We ranked the 1st in OpenCompass Multi-modal Leaderboard among models of 2B parameters.
Model Card
Model Architecture:
Architecture | ViT | LLM | Adapter | Token Merge | Resolution |
---|---|---|---|---|---|
๐คSAIL-VL-2B | ๐คInternViT-300M | ๐คQwen2.5-1.5B | 2-layer MLP | 2x2 | 448x448xN |
Training Recipes Overview:
Sail-VL benefits from high-quality data and carefully curated training recipes. We find the data quality, quantity and the design of curriculum training pipeline are crucial for model performance. With the proper design and data, the model's capacity scales effectively with data expansion at all stages, leading to enhanced performance. More details will be released soon.
Evaluation
SAIL-VL not only outperforms the Qwen2-VL and InternVL2 series of models of comparable size, but is also competitive compared with recently released SoTAs, Aquila and InternVL-2.5.
Performace Overview:
The result is evaluated by our team with a VLMEvalKit variant.
Detail Evaluations:
Benchmark | InternVL-2 | Qwen2-VL | Aquila-VL-2B | InternVL-2.5 | SAIL-VL-2B |
---|---|---|---|---|---|
OpenCompassAvg | 55.94 | 57.36 | 60.35 | 61.42 | 62.67 |
Total Avg | 60.93 | 63.04 | 62.76 | 65.77 | 66.27 |
GeneralQA Avg | 58.04 | 59.75 | 62.39 | 62.96 | 63.79 |
OCR Avg | 74.50 | 75.80 | 71.78 | 76.80 | 78.19 |
MMBench_DEV_CN_V11 | 69.2 | 69.5 | 73.61 | 71.44 | 72.06 |
MMBench_DEV_EN_V11 | 71.36 | 71.28 | 75.93 | 74.61 | 76.63 |
MathVista_MINI | 47.5 | 48.2 | 59.3 | 52 | 63.1 |
MMStar | 49.87 | 46.67 | 55 | 53.4 | 56.73 |
MMMU_VAL | 33.56 | 38.89 | 41.11 | 42 | 42.67 |
MMVet | 40.83 | 48.3 | 43.85 | 61.38 | 46.88 |
HallusionBench | 38.57 | 41.42 | 42.09 | 42.79 | 45.03 |
AI2D_TEST | 74.22 | 73.35 | 75 | 74.9 | 77.69 |
OCRBench | 78.3 | 78.6 | 77.2 | 80.2 | 83.2 |
RealWorldQA | 57.25 | 62.61 | 63.92 | 61.05 | 63.14 |
InfoVQA_VAL | 57.82 | 63.64 | 48.14 | 61.85 | 62.01 |
ChartQA_TEST | 76.96 | 74.16 | 79.76 | 79.44 | 82.96 |
LLaVA_Bench | 52.8 | 57.8 | 54 | 57.5 | 53.5 |
MME | 66.98 | 69.55 | 64.74 | 75.25 | 71.51 |
DocVQA_VAL | 86.23 | 85.38 | 74.31 | 87.67 | 86.06 |
TextVQA_VAL | 73.48 | 79.66 | 76.27 | 76.76 | 77.21 |
Details for average performance section:
OpenCompass-Avg includes public avaliable validation sets from OpenCompass: AI2D_TEST, HallusionBench, MMBench_DEV_CN_V11, MMBench_DEV_EN_V11, MME, MMMU_DEV_VAL, MMStar, MMVet, MathVista_MINI, evaluated by our team.
GeneralQA-Avg includes MMBench_DEV_CN_V11, MMBench_DEV_EN_V11, MME, MMMU, MMStar and RealWorldQA.
OCR-Avg includes AI2D_TEST, InfoVQA_VAL, ChartQA_TEST, DocVQA_VAL, OCRBench, TextVQA_VAL.
Demo Cases
We visualize some of examples from LLaVA-Bench to show the capabilities of our model. Our model is able to give detail and complex answer for a variety of questions.
How to Use
The basic usage and dynamic crop strategy of SAIL-VL follows InternVL2, you can easily switch Intern-VL series of models to our model. Here is a simple example of using our model:
Requirements:
pip3 install einops transformers timm
Code:
import numpy as np
import torch
import torchvision.transforms as T
from PIL import Image
from torchvision.transforms.functional import InterpolationMode
from transformers import AutoModel, AutoTokenizer
IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)
def build_transform(input_size):
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
transform = T.Compose([
T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
T.ToTensor(),
T.Normalize(mean=MEAN, std=STD)
])
return transform
def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
best_ratio_diff = float('inf')
best_ratio = (1, 1)
area = width * height
for ratio in target_ratios:
target_aspect_ratio = ratio[0] / ratio[1]
ratio_diff = abs(aspect_ratio - target_aspect_ratio)
if ratio_diff < best_ratio_diff:
best_ratio_diff = ratio_diff
best_ratio = ratio
elif ratio_diff == best_ratio_diff:
if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
best_ratio = ratio
return best_ratio
def dynamic_preprocess(image, min_num=1, max_num=10, image_size=448, use_thumbnail=False):
orig_width, orig_height = image.size
aspect_ratio = orig_width / orig_height
# calculate the existing image aspect ratio
target_ratios = set(
(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
i * j <= max_num and i * j >= min_num)
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
# find the closest aspect ratio to the target
target_aspect_ratio = find_closest_aspect_ratio(
aspect_ratio, target_ratios, orig_width, orig_height, image_size)
# calculate the target width and height
target_width = image_size * target_aspect_ratio[0]
target_height = image_size * target_aspect_ratio[1]
blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
# resize the image
resized_img = image.resize((target_width, target_height))
processed_images = []
for i in range(blocks):
box = (
(i % (target_width // image_size)) * image_size,
(i // (target_width // image_size)) * image_size,
((i % (target_width // image_size)) + 1) * image_size,
((i // (target_width // image_size)) + 1) * image_size
)
# split the image
split_img = resized_img.crop(box)
processed_images.append(split_img)
assert len(processed_images) == blocks
if use_thumbnail and len(processed_images) != 1:
thumbnail_img = image.resize((image_size, image_size))
processed_images.append(thumbnail_img)
return processed_images
def load_image(image_file, input_size=448, max_num=10):
image = Image.open(image_file).convert('RGB')
transform = build_transform(input_size=input_size)
images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
pixel_values = [transform(image) for image in images]
pixel_values = torch.stack(pixel_values)
return pixel_values
path = "BytedanceDouyinContent/SAIL-VL-2B"
model = AutoModel.from_pretrained(
path,
torch_dtype=torch.bfloat16,
trust_remote_code=True).eval().cuda()
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
# set the max number of tiles in `max_num`
pixel_values = load_image('./test.png', max_num=10).to(torch.bfloat16).cuda()
generation_config = dict(max_new_tokens=1024, do_sample=True)
# pure-text conversation
question = 'Hello, who are you?'
response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)
print(f'User: {question} Assistant: {response}')
question = 'Can you tell me a story?'
response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
print(f'User: {question} Assistant: {response}')
# single-image single-round conversation
question = '<image> Please describe the image shortly.'
response = model.chat(tokenizer, pixel_values, question, generation_config)
print(f'User: {question} Assistant: {response}')
# single-image multi-round conversation
question = '<image> Please describe the image in detail.'
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
print(f'User: {question} Assistant: {response}')
question = 'Please write a poem according to the image.'
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
print(f'User: {question} Assistant: {response}')
Acknowledge
Our model is built upon numerous outstanding open-source projects, and we are grateful for their contributions. We extend special thanks to the InternVL team and Qwen team for their great base models, and to the BAAI team (Infinity-MM) for their generous release of data.
Citation
@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}
}
License
This project is licensed under Apache License 2.0.
Contact
If you have any question, please feel free to contact us: [email protected]
- Downloads last month
- 153