在这里插入图片描述

🔥 News

  • 2025.06.26 🌟 我们非常自豪地推出Kwai Keye-VL,这是快手Kwai Keye团队精心打造的前沿多模态大语言模型。作为快手先进技术生态中的核心AI产品,Keye在视频理解、视觉感知和推理任务方面表现卓越,树立了新的性能标杆。我们的团队正在不懈努力突破可能的边界,敬请期待更多令人兴奋的进展!

在这里插入图片描述

快速入门

以下,我们通过简单示例展示如何结合🤗 Transformers使用Kwai Keye-VL。

Kwai Keye-VL的代码已集成至最新版Hugging Face transformers库,建议您通过以下命令从源码构建:

pip install git+https://github.com/huggingface/transformers accelerate

我们提供一套工具包,帮助您像调用API一样更便捷地处理各类视觉输入。包括base64编码、URL链接以及交错排列的图像和视频。您可以通过以下命令进行安装:

# It's highly recommanded to use `[decord]` feature for faster video loading.
pip install "keye-vl-utils[decord]==1.0.0"

如果您未使用Linux系统,可能无法直接从PyPI安装decord。此时可以使用pip install keye-vl-utils命令,该工具包将自动回退至torchvision进行视频处理。但您仍可通过源码安装decord来启用视频加载时的decord支持。

使用🤗 Transformers进行对话

以下代码片段展示如何结合transformers和keye_vl_utils使用对话模型:

继Qwen3之后,我们也提供了软切换机制,允许用户动态控制模型行为。通过在用户提示中添加/think、/no_think或不添加任何指令,即可切换模型的思考模式。

from transformers import AutoModel, AutoTokenizer, AutoProcessor
from keye_vl_utils import process_vision_info# default: Load the model on the available device(s)
model_path = "Kwai-Keye/Keye-VL-8B-Preview"model = AutoModel.from_pretrained(model_path,torch_dtype="auto",device_map="auto",trust_remote_code=True,
)# We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
# model = KeyeForConditionalGeneration.from_pretrained(
#     "Kwai-Keye/Keye-VL-8B-Preview",
#     torch_dtype=torch.bfloat16,
#     attn_implementation="flash_attention_2",
#     device_map="auto",
# )# default processer
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)# The default range for the number of visual tokens per image in the model is 4-16384.
# You can set min_pixels and max_pixels according to your needs, such as a token range of 256-1280, to balance performance and cost.
# min_pixels = 256*28*28
# max_pixels = 1280*28*28
# processor = AutoProcessor.from_pretrained(model_pat, min_pixels=min_pixels, max_pixels=max_pixels, trust_remote_code=True)# Non-Thinking Mode
messages = [{"role": "user","content": [{"type": "image","image": "https://s1-11508.kwimgs.com/kos/nlav11508/mllm_all/ziran_jiafeimao_11.jpg",},{"type": "text", "text": "Describe this image./no_think"},],}
]# Auto-Thinking Mode
messages = [{"role": "user","content": [{"type": "image","image": "https://s1-11508.kwimgs.com/kos/nlav11508/mllm_all/ziran_jiafeimao_11.jpg",},{"type": "text", "text": "Describe this image."},],}
]# Thinking mode
messages = [{"role": "user","content": [{"type": "image","image": "https://s1-11508.kwimgs.com/kos/nlav11508/mllm_all/ziran_jiafeimao_11.jpg",},{"type": "text", "text": "Describe this image./think"},],}
]# Preparation for inference
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(text=[text],images=image_inputs,videos=video_inputs,padding=True,return_tensors="pt",
)
inputs = inputs.to("cuda")# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=1024)
generated_ids_trimmed = [out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)

视频推理

# Messages containing a images list as a video and a text query
messages = [{"role": "user","content": [{"type": "video","video": ["file:///path/to/frame1.jpg","file:///path/to/frame2.jpg","file:///path/to/frame3.jpg","file:///path/to/frame4.jpg",],},{"type": "text", "text": "Describe this video."},],}
]# Messages containing a local video path and a text query
messages = [{"role": "user","content": [{"type": "video","video": "file:///path/to/video1.mp4","max_pixels": 360 * 420,"fps": 1.0,},{"type": "text", "text": "Describe this video."},],}
]# Messages containing a video url and a text query
messages = [{"role": "user","content": [{"type": "video","video": "http://s2-11508.kwimgs.com/kos/nlav11508/MLLM/videos_caption/98312843263.mp4",},{"type": "text", "text": "Describe this video."},],}
]#In Keye-VL, frame rate information is also input into the model to align with absolute time.
# Preparation for inference
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs, video_kwargs = process_vision_info(messages, return_video_kwargs=True)
inputs = processor(text=[text],images=image_inputs,videos=video_inputs,padding=True,return_tensors="pt",**video_kwargs,
)
inputs = inputs.to("cuda")# Inference
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)

批量推理

# Sample messages for batch inference
messages1 = [{"role": "user","content": [{"type": "image", "image": "file:///path/to/image1.jpg"},{"type": "image", "image": "file:///path/to/image2.jpg"},{"type": "text", "text": "What are the common elements in these pictures?"},],}
]
messages2 = [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Who are you?"},
]
# Combine messages for batch processing
messages = [messages1, messages2]# Preparation for batch inference
texts = [processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)for msg in messages
]
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(text=texts,images=image_inputs,videos=video_inputs,padding=True,return_tensors="pt",
)
inputs = inputs.to("cuda")# Batch Inference
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_texts = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_texts)

更多使用提示

对于输入图像,我们支持本地文件、base64编码和URL链接。对于视频,目前仅支持本地文件。

# You can directly insert a local file path, a URL, or a base64-encoded image into the position where you want in the text.
## Local file path
messages = [{"role": "user","content": [{"type": "image", "image": "file:///path/to/your/image.jpg"},{"type": "text", "text": "Describe this image."},],}
]
## Image URL
messages = [{"role": "user","content": [{"type": "image", "image": "http://path/to/your/image.jpg"},{"type": "text", "text": "Describe this image."},],}
]
## Base64 encoded image
messages = [{"role": "user","content": [{"type": "image", "image": "data:image;base64,/9j/..."},{"type": "text", "text": "Describe this image."},],}
]

提升性能的图像分辨率设置

该模型支持多种分辨率输入。默认情况下,它会采用原始分辨率处理输入,但更高的分辨率可提升性能(需消耗更多计算资源)。用户可设置像素的最小值和最大值(如256-1280的token计数范围)来优化配置,从而平衡运行速度与内存占用。

min_pixels = 256 * 28 * 28
max_pixels = 1280 * 28 * 28
processor = AutoProcessor.from_pretrained("Kwai-Keye/Keye-VL-8B-Preview", min_pixels=min_pixels, max_pixels=max_pixels
)

此外,我们提供两种方法对输入模型的图像尺寸进行细粒度控制:

  1. 定义最小像素和最大像素范围:图像将按原比例缩放,确保像素值落在设定区间内。

  2. 指定精确尺寸:直接设置resized_height和resized_width参数。这些数值会自动圆整为28的整数倍。

# min_pixels and max_pixels
messages = [{"role": "user","content": [{"type": "image","image": "file:///path/to/your/image.jpg","resized_height": 280,"resized_width": 420,},{"type": "text", "text": "Describe this image."},],}
]
# resized_height and resized_width
messages = [{"role": "user","content": [{"type": "image","image": "file:///path/to/your/image.jpg","min_pixels": 50176,"max_pixels": 50176,},{"type": "text", "text": "Describe this image."},],}
]

👀 架构与训练策略

在这里插入图片描述
快意-VL模型架构基于Q文3-8B语言模型,整合了从开源SigLIP初始化的视觉编码器。该模型支持原生动态分辨率,通过将每幅图像划分为14x14的补丁序列来保持原始宽高比,随后通过简单的MLP层映射并融合视觉标记。模型采用3D旋转位置编码(RoPE)对文本、图像和视频信息进行统一处理,在位置编码与绝对时间之间建立一对一对应关系,从而确保对视频信息时序变化的精准感知。

🌟 Pre-Train

在这里插入图片描述
快影关键预训练流程,采用四阶段渐进式策略:图文匹配、ViT-LLM对齐、多任务预训练及模型融合退火。

预训练数据:海量、高质量、多样化

  • 多样性:涵盖图文对、视频、纯文本等数据类型,任务类型包括细粒度描述、OCR文本识别、问答、目标定位等。
  • 高质量:采用CLIP评分和视觉语言模型(VLM)判别器进行数据筛选,并利用MinHASH去重技术防止数据泄露。
  • 自建数据集:专门构建高质量内部数据集,尤其在精细描述和中文OCR领域,以弥补开源数据的不足。

训练流程:四阶段渐进式优化
Kwai Keye-VL采用四阶段渐进式训练策略:

  • 阶段0(视觉预训练):持续预训练视觉编码器以适应内部数据分布并支持动态分辨率。
  • 阶段1(跨模态对齐):冻结骨干模型,仅训练MLP以低成本实现鲁棒的图文对齐。
  • 阶段2(多任务预训练):解锁全部参数,全面提升模型的视觉理解能力。
  • 阶段3(退火训练):通过高质量数据微调,进一步提升模型的细粒度理解能力。

最终,Kwai Keye-VL探索同构异构融合技术——对不同数据比例的退火训练模型进行参数平均,在保留多维能力的同时减少模型偏差,从而增强模型的鲁棒性。

📈 实验结果

在这里插入图片描述

  1. Keye-VL-8B凭借强大且先进的感知能力崭露头角,其性能足以与顶尖模型媲美。
  2. Keye-VL-8B在视频理解领域展现出非凡的熟练度。在包括Video-MME、Video-MMMU、TempCompass、LongVideoBench和MMVU在内的一系列权威公共视频基准测试中,该模型的表现明显超越了同规模的其他顶级模型。
  3. 在需要复杂逻辑推理和数学问题求解的评估集(如WeMath、MathVerse和LogicVista)中,Kwai Keye-VL-8B展现出强劲的性能曲线,凸显了其在逻辑推演和解决复杂量化问题方面的高阶能力。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/bicheng/87346.shtml
繁体地址,请注明出处:http://hk.pswp.cn/bicheng/87346.shtml
英文地址,请注明出处:http://en.pswp.cn/bicheng/87346.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Web前端之JavaScript实现图片圆环、圆环元素根据角度指向圆心、translate、rotate

MENU 前言效果HtmlStyleJavaScript 前言 代码段创建了一个由6个WiFi图标组成的圆形排列&#xff0c;每个图标均匀分布在圆周上。 效果 Html 代码 <div class"ring"><div class"item"><img class"img" src"../image/icon/W…

1 Studying《Computer Vision: Algorithms and Applications 2nd Edition》11-15

目录 Chapter 11 Structure from motion and SLAM 11.1 几何内禀校准 11.2 姿态估计 11.3 从运动中获得的双帧结构 11.4 从运动中提取多帧结构 11.5 同步定位与建图&#xff08;SLAM&#xff09; 11.6 额外阅读 Chapter 12 Depth estimation 12.1 极点几何 12.2 稀疏…

phpstudy 可以按照mysql 数据库

phpstudy 可以按照mysql 数据库 PHPStudy&#xff08;小皮面板&#xff09;是一款专为开发者设计的集成环境工具&#xff0c;涵盖服务器配置、开发环境搭建、网站部署等多项功能。以下是其核心用途及优势的详细解析&#xff1a; 一、开发环境快速搭建 一站式集成环境集成Apa…

Python搭建HTTP服务,如何用内网穿透快速远程访问?

Python的内置HTTP服务模块是开发者工具箱中的瑞士军刀&#xff0c;只需一行命令即可启动一个功能完备的Web服务器。无论是前端工程师调试页面、数据科学家共享Jupyter Notebook&#xff0c;还是后端开发者快速验证API原型&#xff0c;Python HTTP服务都能以零配置的方式满足需求…

拨号音识别系统的设计与实现

拨号音识别系统的设计与实现 摘要 本文设计并实现了一个完整的拨号音识别系统&#xff0c;该系统能够自动识别电话号码中的数字。系统基于双音多频(DTMF)技术原理&#xff0c;使用MATLAB开发&#xff0c;包含GUI界面展示处理过程和结果。系统支持从麦克风实时录音或加载音频文…

数据结构-树详解

树简介 树存储和组织具有层级结构的数据&#xff08;例&#xff1a;公司职级&#xff09;&#xff0c;就是一颗倒立生长的树。 属性&#xff1a; 递归n个节点有n-1个连接节点x的深度&#xff1a;节点x到根节点的最长路径节点x的高度&#xff1a;节点x到叶子节点的最长路径 …

【安卓Sensor框架-2】应用注册Sensor 流程

注册传感器的核心流程为如下&#xff1a;应用层调用 SensorManager注册传感器&#xff0c;framework层创建SensorEventQueue对象&#xff08;事件队列&#xff09;&#xff0c;通过JNI调用Native方法nativeEnableSensor()&#xff1b;SensorService服务端createEventQueue()创建…

新版本没有docker-desktop-data分发 | docker desktop 镜像迁移

在新版本的docker desktop中&#xff08;如4.42版本&#xff09;&#xff0c;镜像迁移只需要更改路径即可。如下&#xff1a; 打开docker desktop的设置&#xff08;图1&#xff09;&#xff0c;将图2的原来的地址C:\Users\用户\AppData\Local\Docker\wsl修改为你想要的空文件…

EtherCAT SOEM源码分析 - ec_init

ec_init SOEM主站一切开始的地方始于ec_init, 它是EtherCAT主站初始化的入口。初始化SOEM 主站&#xff0c;并绑定到socket到ifname。 /** Initialise lib in single NIC mode* param[in] ifname Dev name, f.e. "eth0"* return >0 if OK* see ecx_init*/ in…

84、原理解析-SpringApplication创建初始化流程

84、原理解析-SpringApplication初始化流程 # SpringApplication创建初始化流程原理解析 SpringApplication的创建和初始化是Spring Boot应用启动的关键步骤&#xff0c;主要包括以下过程&#xff1a; ## 1. 创建SpringApplication实例 ### 1.1 调用构造函数 - 当调用SpringApp…

【数理逻辑】 选择公理与集值映射

目录 选择公理1. 有限指标集 I I I2. 可数无限指标集 I I I &#xff08;简称为 ACC 或 ACω&#xff09;3. 不可数无限指标集 I I I4. 选择公理的层级与数学应用5. 选择公理的深层意义 集值映射的选择函数1. 选择公理的核心作用2. 不同情况下的依赖性分析3. AC 的必要性证明…

微信小程序使用wx.chooseImage上传图片时进行压缩,并添加时间水印

在微信小程序的开发过程&#xff0c;经常会使用自带的api(wx.chooseImage)进行图片拍照或选择图片进行上传&#xff0c;有时图片太大&#xff0c;造成上传和下载时过慢&#xff0c;现对图片进行压缩后上传&#xff0c;以下是流程和代码 一、小程序的版本选择了3.2.5&#xff0…

RAII简介

&#x1f4e6; 一、技术原理简介&#xff1a;RAII是个“托管狂魔” 想象你有个健忘的朋友&#xff0c;每次借东西都会忘记归还。RAII&#xff08;Resource Acquisition Is Initialization&#xff0c;资源获取即初始化&#xff09;就是C派来的“超级管家”&#xff1a; “你负…

微信小程序入门实例_____打造你的专属单词速记小程序

上次通过天气查询小程序&#xff0c;我们初探了微信小程序开发的世界。这次&#xff0c;咱们再挑战一个有趣又实用的项目 ——“单词速记小程序”。无论是学生党备考&#xff0c;还是上班族提升英语&#xff0c;都能用得上&#xff01;接下来就跟着我&#xff0c;一步一步把它做…

gateway白名单存储nacos,改成存储数据库

前言 很久没写博客了&#xff0c;csdn都开始ai润色了&#xff0c;之前都是看相应框架的源码看了个遍&#xff0c;感觉底层原理都差不多&#xff0c;这阵子着手改造了下gateway中的白名单&#xff0c;之前白名单存储到nacos&#xff0c;要改成存到数据库。里面涉及到浅浅的源码…

ubentu服务器版本安装Dify

Docker 中安装Dify 首先安装Docker 1. 克隆Dify代码仓库 从github克隆 Dify 源代码至要本地环境。 我的ubentu服务器版本&#xff0c;我把源代码下载到 /var/下 在var文件夹下执行 git clone https://github.com/langgenius/dify.git执行成功后&#xff0c;进入Dify源代码的…

Redis分布式锁实战:从入门到生产级方案

目录 一、为什么需要分布式锁&#xff1f; 二、Redis分布式锁核心特性 三、实现方案与代码详解 方案1&#xff1a;基础版 SETNX EXPIRE 原理 代码示例 问题 方案2&#xff1a;Redisson框架&#xff08;生产推荐&#xff09; 核心特性 代码示例 优势 方案3&#xff…

【Redis】StringRedisTemplate 和 RedisTemplate 的区别

StringRedisTemplate 和 RedisTemplate 是 Spring Data Redis 提供的两种用于操作 Redis 的模板类&#xff0c;它们的核心区别在于 序列化方式 和 操作的数据类型。以下是两者的主要区别和使用建议&#xff1a; ✅ 1. 数据类型支持 类名支持的数据类型说明RedisTemplate支持所…

docker-compose快速搭建redis集群

目录结构 redis-cluster/ ├── config/ │ ├── master.conf │ ├── slave1.conf │ └── slave2.conf └── docker-compose.yml配置文件内容 1. config/master.conf # Redis主节点配置 port 6379 bind 0.0.0.0 protected-mode no logfile "redis-mas…

SpringCloud系列(39)--SpringCloud Gateway常用的Route Predicate

前言&#xff1a;在上一节中我们实现了SpringCloud Gateway的动态路由 &#xff0c;而在本节中我们将着重介绍各种Route Predicate的作用。 1、可以到官方文档里查看常用的Route Predicate的种类 https://cloud.spring.io/spring-cloud-static/spring-cloud-gateway/2.2.1.REL…