license: apache-2.0
pipeline_tag: text-generation
datasets:
- liuhaotian/LLaVA-Pretrain
- liuhaotian/LLaVA-Instruct-150K
😈 小恶魔Imp
[论文] [演示] [Github]
项目介绍
Imp项目致力于打造一系列高性能轻量级多模态大模型。我们的Imp-v1.5-4B-Phi3
是仅含40亿参数的强力轻量级多模态模型,基于Phi-3(38亿参数)框架和高效视觉编码器SigLIP(4亿参数)构建,并通过百万级混合数据集训练而成。
我们现已开源模型权重,并提供了以下运行示例。详细技术报告及配套训练/评估代码即将在GitHub仓库发布。我们将持续优化模型并推出新版本以进一步提升性能:)
使用指南
安装依赖
pip install transformers
pip install -q pillow accelerate einops
可通过以下代码进行模型推理,文本指令格式与LLaVA相似。注意当前示例仅支持GPU运行。
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image
torch.set_default_device("cuda")
model = AutoModelForCausalLM.from_pretrained(
"MILVLG/Imp-v1.5-4B-Phi3/",
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("MILVLG/Imp-v1.5-4B-Phi3", trust_remote_code=True)
text = "<|user|>\n<image>\n图中巴士是什么颜色?\n<|end|>\n<|assistant|>\n"
image = Image.open("images/bus.jpg")
input_ids = tokenizer(text, return_tensors='pt').input_ids
image_tensor = model.image_preprocess(image)
output_ids = model.generate(
input_ids,
max_new_tokens=100,
images=image_tensor,
use_cache=True)[0]
print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())
模型评估
我们在9个常用基准测试上进行了评估,包括5个学术VQA数据集和4个主流MLLM基准,将Imp模型与LLaVA(70亿)及同规模轻量级多模态模型进行对比。
模型 |
参数量 |
VQAv2 |
GQA |
SQA(IMG) |
TextVQA |
POPE |
MME(P) |
MMB |
MMB_CN |
MM-Vet |
Bunny-v1.0-4B |
40亿 |
81.5 |
63.5 |
75.1 |
- |
86.7 |
1495.2 |
73.5 |
- |
- |
Imp-v1.5-4B-Phi3 |
40亿 |
81.5 |
63.5 |
78.3 |
60.2 |
86.9 |
1507.7 |
73.3 |
61.1 |
44.6 |
许可协议
本项目采用Apache License 2.0许可,详见许可证文件。
引用文献
若您使用本模型或参考我们的工作,请引用:
@article{imp2024,
title={Imp: 面向移动设备的高性能大型多模态模型},
author={邵振威, 余舟, 余俊, 欧阳学晨, 郑立豪, 盖振彪, 王明阳, 丁佳骏},
journal={arXiv预印本 arXiv:2405.12107},
year={2024}
}