Eagle2-9B是NVIDIA发布的最新视觉语言模型(VLM),在性能和推理速度之间实现了完美平衡。它基于Qwen2.5-7B-Instruct语言模型和Siglip+ConvNext视觉模型构建,支持多语言和多模态任务。
下载量 944
发布时间 : 1/10/2025
模型介绍
内容详情
替代品
模型简介
Eagle2-9B是一个高性能的开源视觉语言模型,专注于从数据中心视角优化VLM后训练。它通过结合稳健的训练方案和模型设计,在多项基准测试中表现出色。
模型特点
高性能平衡
在8.9B参数规模下实现了性能与推理速度的完美平衡
多模态支持
支持文本、图像和视频输入,处理多种模态信息
长上下文处理
支持长达16K的上下文长度
基准测试领先
在多个视觉语言基准测试中表现优于同类模型
模型能力
图像理解
文本生成
多模态对话
文档问答
图表理解
视频分析
使用案例
文档处理
DocVQA文档问答
从文档图像中提取信息并回答问题
在DocVQA测试集上达到92.6分
视觉问答
TextVQA文本视觉问答
回答关于图像中文本内容的问题
在TextVQA验证集上达到83.0分
图表理解
ChartQA图表问答
理解和回答基于图表数据的问题
在ChartQA测试集上达到86.4分
license: cc-by-nc-4.0 pipeline_tag: image-text-to-text library_name: transformers base_model:
- google/paligemma-3b-mix-448
- Qwen/Qwen2.5-7B-Instruct
- google/siglip-so400m-patch14-384
- timm/convnext_xxlarge.clip_laion2b_soup_ft_in1k base_model_relation: merge language:
- multilingual tags:
- eagle
- VLM
Eagle-2
[📂 GitHub] [📜 Eagle2技术报告] [🗨️ 聊天演示] [🤗 HF演示]
简介
我们非常高兴发布最新的Eagle2系列视觉语言模型。开源视觉语言模型(VLMs)在缩小与专有模型差距方面取得了显著进展。然而,关于数据策略和实现的关键细节往往缺失,限制了可复现性和创新。本项目从数据中心的视角聚焦VLM后训练,分享从零构建有效数据策略的洞见。通过将这些策略与稳健的训练方案和模型设计相结合,我们推出了性能卓越的Eagle2系列VLMs。我们的工作旨在赋能开源社区,通过透明流程开发具有竞争力的VLMs。
本代码库开源了Eagle2-9B,它在性能和推理速度之间实现了完美平衡。
模型库
我们提供以下模型:
模型名称 | 大语言模型 | 视觉模型 | 最大长度 | HF链接 |
---|---|---|---|---|
Eagle2-1B | Qwen2.5-0.5B-Instruct | Siglip | 16K | 🤗链接 |
Eagle2-2B | Qwen2.5-1.5B-Instruct | Siglip | 16K | 🤗链接 |
Eagle2-9B | Qwen2.5-7B-Instruct | Siglip+ConvNext | 16K | 🤗链接 |
基准测试结果
基准测试 | MiniCPM-Llama3-V-2_5 | InternVL-Chat-V1-5 | InternVL2-8B | QwenVL2-7B | Eagle2-9B |
---|---|---|---|---|---|
模型大小 | 8.5B | 25.5B | 8.1B | 8.3B | 8.9B |
DocVQAtest | 84.8 | 90.9 | 91.6 | 94.5 | 92.6 |
ChartQAtest | - | 83.8 | 83.3 | 83.0 | 86.4 |
InfoVQAtest | - | 72.5 | 74.8 | 74.3 | 77.2 |
TextVQAval | 76.6 | 80.6 | 77.4 | 84.3 | 83.0 |
OCRBench | 725 | 724 | 794 | 845 | 868 |
MMEsum | 2024.6 | 2187.8 | 2210.3 | 2326.8 | 2260 |
RealWorldQA | 63.5 | 66.0 | 64.4 | 70.1 | 69.3 |
AI2Dtest | 78.4 | 80.7 | 83.8 | - | 83.9 |
MMMUval | 45.8 | 45.2 / 46.8 | 49.3 / 51.8 | 54.1 | 56.1 |
MMBench_V11test | - | - | 79.5 | 79.4 | 80.6 |
MMVetGPT-4-Turbo | 52.8 | 55.4 | 54.2 | 62.0 | 62.2 |
SEED-Image | 72.3 | 76.0 | 76.2 | - | 77.1 |
HallBenchavg | 42.4 | 49.3 | 45.2 | 50.6 | 49.3 |
MathVistatestmini | 54.3 | 53.5 | 58.3 | 58.2 | 63.8 |
MMstar | - | - | 60.9 | 60.7 | 62.6 |
快速开始
我们提供演示推理脚本帮助您快速使用模型。支持不同输入类型:
- 纯文本输入
- 单张图片输入
- 多张图片输入
- 视频输入
0. 安装依赖
pip install transformers==4.37.2
pip install flash-attn
注意:最新版transformers与模型不兼容。
1. 准备模型工作器
点击展开
"""模型工作器执行模型。
改编自https://github.com/OpenGVLab/InternVL/blob/main/streamlit_demo/model_worker.py
"""
# 在导入transformers前导入torch可能导致`segmentation fault`
from transformers import AutoModel, AutoTokenizer, TextIteratorStreamer, AutoConfig
import argparse
import base64
import json
import os
import decord
import threading
import time
from io import BytesIO
from threading import Thread
import math
import requests
import torch
import torchvision.transforms as T
from PIL import Image
from torchvision.transforms.functional import InterpolationMode
import numpy as np
IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)
SIGLIP_MEAN = (0.5, 0.5, 0.5)
SIGLIP_STD = (0.5, 0.5, 0.5)
def get_seq_frames(total_num_frames, desired_num_frames=-1, stride=-1):
"""计算从视频中提取的帧索引。
参数:
total_num_frames (int): 视频总帧数。
desired_num_frames (int): 期望提取的帧数。
返回:
list: 提取帧的索引列表。
"""
assert desired_num_frames > 0 or stride > 0 and not (desired_num_frames > 0 and stride > 0)
if stride > 0:
return list(range(0, total_num_frames, stride))
# 计算每个段的大小,从中提取一帧
seg_size = float(total_num_frames - 1) / desired_num_frames
seq = []
for i in range(desired_num_frames):
# 计算每个段的起始和结束索引
start = int(np.round(seg_size * i))
end = int(np.round(seg_size * (i + 1)))
# 将段的中间索引添加到列表
seq.append((start + end) // 2)
return seq
def build_video_prompt(meta_list, num_frames, time_position=False):
# 如果time_position为True,使用frame_timestamp
# 1. 传递time_position 2. 使用环境变量TIME_POSITION
time_position = os.environ.get("TIME_POSITION", time_position)
prefix = f"这是一个视频:\n"
for i in range(num_frames):
if time_position:
frame_txt = f"第{i+1}帧采样于{meta_list[i]:.2f}秒: <image>\n"
else:
frame_txt = f"第{i+1}帧: <image>\n"
prefix += frame_txt
return prefix
def load_video(video_path, num_frames=64, frame_cache_root=None):
if isinstance(video_path, str):
video = decord.VideoReader(video_path)
elif isinstance(video_path, dict):
assert False, '不支持输入视频路径为字典'
fps = video.get_avg_fps()
sampled_frames = get_seq_frames(len(video), num_frames)
samepld_timestamps = [i / fps for i in sampled_frames]
frames = video.get_batch(sampled_frames).asnumpy()
images = [Image.fromarray(frame) for frame in frames]
return images, build_video_prompt(samepld_timestamps, len(images), time_position=True)
def load_image(image):
if isinstance(image, str) and os.path.exists(image):
return Image.open(image)
elif isinstance(image, dict):
if 'disk_path' in image:
return Image.open(image['disk_path'])
elif 'base64' in image:
return Image.open(BytesIO(base64.b64decode(image['base64'])))
elif 'url' in image:
response = requests.get(image['url'])
return Image.open(BytesIO(response.content))
elif 'bytes' in image:
return Image.open(BytesIO(image['bytes']))
else:
raise ValueError(f'无效图像: {image}')
else:
raise ValueError(f'无效图像: {image}')
def build_transform(input_size, norm_type='imagenet'):
if norm_type == 'imagenet':
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
elif norm_type == 'siglip':
MEAN, STD = SIGLIP_MEAN, SIGLIP_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_factor = 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)
area_ratio = (ratio[0]*ratio[1]*image_size*image_size)/ area
"""
新面积大于原始图像面积的60%即可。
"""
factor_based_on_area_n_ratio = min((ratio[0]*ratio[1]*image_size*image_size)/ area, 0.6)* \
min(target_aspect_ratio/aspect_ratio, aspect_ratio/target_aspect_ratio)
if factor_based_on_area_n_ratio > best_factor:
best_factor = factor_based_on_area_n_ratio
best_ratio = ratio
return best_ratio
def dynamic_preprocess(image, min_num=1, max_num=6, image_size=448, use_thumbnail=False):
orig_width, orig_height = image.size
aspect_ratio = orig_width / orig_height
# 计算现有图像宽高比
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])
# 找到最接近的目标宽高比
target_aspect_ratio = find_closest_aspect_ratio(
aspect_ratio, target_ratios, orig_width, orig_height, image_size)
# 计算目标宽度和高度
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]
# 调整图像大小
resized_img = image.resize((target_width, target_height))
processed_images = []
for i in range(blocks):
box =
Clip Vit Large Patch14
CLIP是由OpenAI开发的视觉-语言模型,通过对比学习将图像和文本映射到共享的嵌入空间,支持零样本图像分类
图像生成文本
C
openai
44.7M
1,710
Clip Vit Base Patch32
CLIP是由OpenAI开发的多模态模型,能够理解图像和文本之间的关系,支持零样本图像分类任务。
图像生成文本
C
openai
14.0M
666
Siglip So400m Patch14 384
Apache-2.0
SigLIP是基于WebLi数据集预训练的视觉语言模型,采用改进的sigmoid损失函数,优化了图像-文本匹配任务。
图像生成文本
Transformers

S
google
6.1M
526
Clip Vit Base Patch16
CLIP是由OpenAI开发的多模态模型,通过对比学习将图像和文本映射到共享的嵌入空间,实现零样本图像分类能力。
图像生成文本
C
openai
4.6M
119
Blip Image Captioning Base
Bsd-3-clause
BLIP是一个先进的视觉-语言预训练模型,擅长图像描述生成任务,支持条件式和非条件式文本生成。
图像生成文本
Transformers

B
Salesforce
2.8M
688
Blip Image Captioning Large
Bsd-3-clause
BLIP是一个统一的视觉-语言预训练框架,擅长图像描述生成任务,支持条件式和无条件式图像描述生成。
图像生成文本
Transformers

B
Salesforce
2.5M
1,312
Openvla 7b
MIT
OpenVLA 7B是一个基于Open X-Embodiment数据集训练的开源视觉-语言-动作模型,能够根据语言指令和摄像头图像生成机器人动作。
图像生成文本
Transformers

英语
O
openvla
1.7M
108
Llava V1.5 7b
LLaVA 是一款开源多模态聊天机器人,基于 LLaMA/Vicuna 微调,支持图文交互。
图像生成文本
Transformers

L
liuhaotian
1.4M
448
Vit Gpt2 Image Captioning
Apache-2.0
这是一个基于ViT和GPT2架构的图像描述生成模型,能够为输入图像生成自然语言描述。
图像生成文本
Transformers

V
nlpconnect
939.88k
887
Blip2 Opt 2.7b
MIT
BLIP-2是一个视觉语言模型,结合了图像编码器和大型语言模型,用于图像到文本的生成任务。
图像生成文本
Transformers

英语
B
Salesforce
867.78k
359
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers

支持多种语言
L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers

英语
C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统
中文
R
uer
2,694
98
AIbase是一个专注于MCP服务的平台,为AI开发者提供高质量的模型上下文协议服务,助力AI应用开发。
简体中文