來源:魔搭社區
Valley2是一種新穎的多模態大型語言模型,旨在通過可擴展的視覺-語言設計增強各個領域的性能,并拓展電子商務和短視頻場景的實際應用邊界。Valley2在電子商務和短視頻領域中實現了最先進的性能。它引入了如大視覺詞匯、卷積適配器(ConvAdapter)和Eagle模塊等創新,提高了處理多樣化真實世界輸入的靈活性,同時增強了訓練和推理效率。
模型鏈接:
https://www.modelscope.cn/models/bytedance-research/Valley-Eagle-7B
代碼鏈接:
https://github.com/bytedance/Valley
論文鏈接:
https://arxiv.org/abs/2501.05901
01
模型架構
采用了Qwen2.5作為其LLM主干,SigLIP-384作為視覺編碼器,并結合MLP層和卷積進行高效的特征轉換。
projector:采用了一個帶有大型隱藏層MLP的projector,用輕量級的ConvAdapter替換了之前的PixelShuffle方法。
Eagle模塊 :通過添加額外的視覺編碼器以減少失真并確保兼容極端輸入,從而擴展令牌表示。
數據
02
數據和訓練方式
數據
Valley2的數據由三個部分組成:
OneVision風格的數據用于每個階段的多模態大型模型訓練。
針對電子商務和短視頻領域的數據和評估。
構建用于復雜問題解決的鏈式思維(CoT)數據。
訓練
訓練過程包括四個階段:文本-視覺對齊、高質量知識學習、指令微調以及鏈式思維后訓練。
03
實驗結果
Valley2在多個公開基準測試中表現優異,特別是在MMBench、MMStar、MathVista等多個基準上得分較高。此外,在Ecom-VQA基準測試中,Valley2也超越了其他相同規模的模型。
cot-post train 前后對比:
04
模型效果
05
模型推理
下載模型代碼
!git clone https://github.com/bytedance/Valley.git
%cd Valley
模型推理
from valley_eagle_chat import ValleyEagleChat
from modelscope import snapshot_download
import urllib.request
# 需要把模型文件中的config.json的eagle_vision_tower和mm_vision_tower改為本地路徑
model_dir = snapshot_download("bytedance-research/Valley-Eagle-7B")
!modelscope download --model=Qwen/Qwen2-VL-7B-Instruct --local_dir=./Qwen2-VL-7B-Instruct
!modelscope download --model=AI-ModelScope/siglip-so400m-patch14-384 --local_dir=./siglip-so400m-patch14-384
model = ValleyEagleChat(
model_path=model_dir,
padding_side = 'left',
)
url = 'http://p16-goveng-va.ibyteimg.com/tos-maliva-i-wtmo38ne4c-us/4870400481414052507~tplv-wtmo38ne4c-jpeg.jpeg'
img = urllib.request.urlopen(url=url, timeout=5).read()
request = {
"chat_history": [
{'role': 'system', 'content': 'You are Valley, developed by ByteDance. Your are a helpfull Assistant.'},
{'role': 'user', 'content': 'Describe the given image.'},
],
"images": [img],
}
result = model(request)
print(f"\n>>> Assistant:\n")
print(result)
from valley_eagle_chat import ValleyEagleChat
import decord
import requests
import numpy as np
from torchvision import transforms
model = ValleyEagleChat(
model_path=model_dir,
padding_side = 'left',
)
url = 'https://videos.pexels.com/video-files/29641276/12753127_1920_1080_25fps.mp4'
video_file = './video.mp4'
response = requests.get(url)
if response.status_code == 200:
with open("video.mp4", "wb") as f:
f.write(response.content)
else:
print("download error!")
exit(1)
video_reader = decord.VideoReader(video_file)
decord.bridge.set_bridge("torch")
video = video_reader.get_batch(
np.linspace(0, len(video_reader) - 1, 8).astype(np.int_)
).byte()
print([transforms.ToPILImage()(image.permute(2, 0, 1)).convert("RGB") for image in video])
request = {
"chat_history": [
{'role': 'system', 'content': 'You are Valley, developed by ByteDance. Your are a helpfull Assistant.'},
{'role': 'user', 'content': 'Describe the given video.'},
],
"images": [transforms.ToPILImage()(image.permute(2, 0, 1)).convert("RGB") for image in video],
}
result = model(request)
print(f"\n>>> Assistant:\n")
print(result)
顯存占用:
06
未來工作
計劃發布包含文本、圖像、視頻和音頻模態的全能模型,并引入基于Valley的多模態嵌入訓練方法,以支持下游檢索和探測應用。
總之,Valley2代表了多模態大型語言模型的一個重要進展,展示了如何通過改進結構、數據集構建及訓練策略來提升模型性能。
特別聲明:以上內容(如有圖片或視頻亦包括在內)為自媒體平臺“網易號”用戶上傳并發布,本平臺僅提供信息存儲服務。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.