Views
No views yet
| Model | Parameters | Context Length | CoT Support | Best For |
|---|---|---|---|---|
| Qianfan-VL-3B | 3B | 32k | ❌ | Edge deployment, real-time OCR |
| Qianfan-VL-8B | 8B | 32k | ✅ | Server-side general scenarios, fine-tuning |
| Qianfan-VL-70B | 70B | 32k | ✅ | Complex reasoning, data synthesis |
| Benchmark | Qianfan-VL-3B | Qianfan-VL-8B | Qianfan-VL-70B | InternVL-3-8B | InternVL-3-78B | Qwen2.5-VL-7B | Qwen2.5-VL-72B |
|---|---|---|---|---|---|---|---|
| A-Bench_VAL | 75.65 | 75.72 | 78.1 | 75.86 | 75.86 | 76.49 | 79.22 |
| CCBench | 66.86 | 70.39 | 80.98 | 77.84 | 70.78 | 57.65 | 73.73 |
| SEEDBench_IMG | 76.55 | 78.02 | 79.13 | 77.0 | 77.52 | 76.98 | 78.34 |
| SEEDBench2_Plus | 67.59 | 70.97 | 73.17 | 69.52 | 68.47 | 70.93 | 73.25 |
| MMVet | 48.17 | 53.21 | 67.34 | 80.28 | 78.9 | 70.64 | 75.69 |
| MMMU_VAL | 46.44 | 47.11 | 58.33 | 56.11 | 60.78 | 51.0 | 65.78 |
| ScienceQA_TEST | 95.19 | 97.62 | 98.76 | 97.97 | 97.17 | 85.47 | 92.51 |
| ScienceQA_VAL | 93.85 | 97.62 | 98.81 | 97.81 | 95.14 | 83.59 | 91.32 |
| MMT-Bench_VAL | 62.23 | 63.22 | 71.06 | 65.17 | 63.67 | 61.4 | 69.49 |
| MTVQA_TEST | 26.5 | 30.14 | 32.18 | 30.3 | 27.62 | 29.08 | 31.48 |
| BLINK | 49.97 | 56.81 | 59.44 | 55.87 | 51.87 | 54.55 | 63.02 |
| MMStar | 57.93 | 64.07 | 69.47 | 68.4 | 66.07 | 61.53 | 66.0 |
| RealWorldQA | 65.75 | 70.59 | 71.63 | 71.11 | 74.25 | 69.28 | 73.86 |
| Q-Bench1_VAL | 73.51 | 75.25 | 77.46 | 75.99 | 77.99 | 78.1 | 79.93 |
| POPE | 85.08 | 86.06 | 88.97 | 90.59 | 88.87 | 85.97 | 83.35 |
| RefCOCO (Avg) | 85.94 | 89.37 | 91.01 | 89.65 | 91.40 | 86.56 | 90.25 |
| Benchmark | Qianfan-VL-3B | Qianfan-VL-8B | Qianfan-VL-70B | InternVL-3-8B | InternVL-3-78B | Qwen2.5-VL-3B | Qwen2.5-VL-7B | Qwen2.5-VL-72B |
|---|---|---|---|---|---|---|---|---|
| OCRBench | 831 | 854 | 873 | 881 | 847 | 810 | 883 | 874 |
| AI2D_TEST | 81.38 | 85.07 | 87.23 | 85.07 | 83.55 | 77.07 | 80.472 | 83.84 |
| OCRVQA_TEST | 66.15 | 68.98 | 74.06 | 39.03 | 35.58 | 69.24 | 71.02 | 66.8 |
| TextVQA_VAL | 80.11 | 82.13 | 84.48 | 82.15 | 83.52 | 79.09 | 84.962 | 83.26 |
| DocVQA_VAL | 90.85 | 93.54 | 94.75 | 92.04 | 83.82 | 92.71 | 94.91 | 95.75 |
| ChartQA_TEST | 81.79 | 87.72 | 89.6 | 85.76 | 82.04 | 83.4 | 86.68 | 87.16 |
| Benchmark | Qianfan-VL-8B | Qianfan-VL-70B | InternVL-3-8B | InternVL-3-78B | Qwen2.5-VL-7B | Qwen2.5-VL-72B |
|---|---|---|---|---|---|---|
| Mathvista-mini | 69.19 | 78.6 | 69.5 | 70.1 | 67.2 | 73.9 |
| Mathvision | 32.82 | 50.29 | 29.61 | 34.8 | 25.95 | 39.34 |
| Mathverse | 48.4 | 61.04 | 43.68 | 49.26 | 44.21 | 55.18 |
| ChartQA Pro | 50.43 | 52 | 37.32 | 44.43 | 43.73 | 45.3 |
| HallusionBench | 51.72 | 54.52 | 49.2 | 40.2 | 47.9 | 49.9 |
| InHouse Dataset A | 59.87 | 71.78 | 40.64 | 41.47 | 45.58 | 57.2 |
| InHouse Dataset B | 61.33 | 75.6 | 36.25 | 42.65 | 30.62 | 59.68 |
pip install transformers accelerate torch torchvision pillow einops 1import torch
2import torchvision.transforms as T
3from torchvision.transforms.functional import InterpolationMode
4from transformers import AutoModel, AutoTokenizer
5from PIL import Image
6
7IMAGENET_MEAN = (0.485, 0.456, 0.406)
8IMAGENET_STD = (0.229, 0.224, 0.225)
9
10def build_transform(input_size):
11 MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
12 transform = T.Compose([
13 T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
14 T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
15 T.ToTensor(),
16 T.Normalize(mean=MEAN, std=STD)
17 ])
18 return transform
19
20def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
21 best_ratio_diff = float('inf')
22 best_ratio = (1, 1)
23 area = width * height
24 for ratio in target_ratios:
25 target_aspect_ratio = ratio[0] / ratio[1]
26 ratio_diff = abs(aspect_ratio - target_aspect_ratio)
27 if ratio_diff < best_ratio_diff:
28 best_ratio_diff = ratio_diff
29 best_ratio = ratio
30 elif ratio_diff == best_ratio_diff:
31 if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
32 best_ratio = ratio
33 return best_ratio
34
35def dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False):
36 orig_width, orig_height = image.size
37 aspect_ratio = orig_width / orig_height
38
39 # calculate the existing image aspect ratio
40 target_ratios = set(
41 (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
42 i * j <= max_num and i * j >= min_num)
43 target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
44
45 # find the closest aspect ratio to the target
46 target_aspect_ratio = find_closest_aspect_ratio(
47 aspect_ratio, target_ratios, orig_width, orig_height, image_size)
48
49 # calculate the target width and height
50 target_width = image_size * target_aspect_ratio[0]
51 target_height = image_size * target_aspect_ratio[1]
52 blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
53
54 # resize the image
55 resized_img = image.resize((target_width, target_height))
56 processed_images = []
57 for i in range(blocks):
58 box = (
59 (i % (target_width // image_size)) * image_size,
60 (i // (target_width // image_size)) * image_size,
61 ((i % (target_width // image_size)) + 1) * image_size,
62 ((i // (target_width // image_size)) + 1) * image_size
63 )
64 # split the image
65 split_img = resized_img.crop(box)
66 processed_images.append(split_img)
67 assert len(processed_images) == blocks
68 if use_thumbnail and len(processed_images) != 1:
69 thumbnail_img = image.resize((image_size, image_size))
70 processed_images.append(thumbnail_img)
71 return processed_images
72
73def load_image(image_file, input_size=448, max_num=12):
74 image = Image.open(image_file).convert('RGB')
75 transform = build_transform(input_size=input_size)
76 images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
77 pixel_values = [transform(image) for image in images]
78 pixel_values = torch.stack(pixel_values)
79 return pixel_values
80
81# Load model
82MODEL_PATH = "baidu/Qianfan-VL-8B" # or Qianfan-VL-3B, Qianfan-VL-70B
83model = AutoModel.from_pretrained(
84 MODEL_PATH,
85 torch_dtype=torch.bfloat16,
86 trust_remote_code=True,
87 device_map="auto"
88).eval()
89tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
90
91# Load and process image
92pixel_values = load_image("./example/scene_ocr.png").to(torch.bfloat16)
93
94# Inference
95prompt = "<image>请识别图中所有文字"
96with torch.no_grad():
97 response = model.chat(
98 tokenizer,
99 pixel_values=pixel_values,
100 question=prompt,
101 generation_config={"max_new_tokens": 512},
102 verbose=False
103 )
104print(response)1docker run -d --name qianfan-vl \
2 --gpus all \
3 -v /path/to/Qianfan-VL-8B:/model \
4 -p 8000:8000 \
5 --ipc=host \
6 vllm/vllm-openai:latest \
7 --model /model \
8 --served-model-name qianfan-vl \
9 --trust-remote-code \
10 --hf-overrides '{"architectures":["InternVLChatModel"],"model_type":"internvl_chat"}'1curl 'http://127.0.0.1:8000/v1/chat/completions' \
2 --header 'Content-Type: application/json' \
3 --data '{
4 "model": "qianfan-vl",
5 "messages": [
6 {
7 "role": "user",
8 "content": [
9 {
10 "type": "image_url",
11 "image_url": {
12 "url": "https://qianfan-public-demo.bj.bcebos.com/qianfan-vl/2509/images/scene_ocr.png"
13 }
14 },
15 {
16 "type": "text",
17 "text": "<image>请识别图中所有文字"
18 }
19 ]
20 }
21 ]
22 }'1from openai import OpenAI
2
3client = OpenAI(
4 api_key="EMPTY",
5 base_url="http://127.0.0.1:8000/v1"
6)
7
8response = client.chat.completions.create(
9 model="qianfan-vl",
10 messages=[
11 {
12 "role": "user",
13 "content": [
14 {
15 "type": "image_url",
16 "image_url": {"url": "https://qianfan-public-demo.bj.bcebos.com/qianfan-vl/2509/images/scene_ocr.png"}
17 },
18 {
19 "type": "text",
20 "text": "<image>请描述这张图片"
21 }
22 ]
23 }
24 ],
25 max_tokens=512
26)
27print(response.choices[0].message.content)1@misc{qianfan-vl-2025,
2 title={Qianfan-VL: Domain-Enhanced Universal Vision-Language Models},
3 author={Qianfan Team},
4 year={2025},
5 publisher={Baidu}
6}