🚀 😈 Imp
Imp项目旨在提供一系列高性能且轻量级的大语言多模态模型(LMMs)。该模型在图像识别等多模态任务中表现出色,能有效处理文本与图像的融合,为相关领域的应用提供了强大支持。
🚀 快速开始
安装依赖
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>\nWhat are the colors of the bus in the image?\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())
✨ 主要特性
- 轻量级高性能:
Imp-v1.5-4B-Phi3
仅具有 4B 参数,是一款强大的轻量级大语言多模态模型。它基于 Phi-3 (3.8B) 和强大的视觉编码器 SigLIP (0.4B) 构建,并在100万条混合数据集上进行训练。
- 持续优化:团队将持续改进模型,并发布后续版本以进一步提升模型性能。
📚 详细文档
模型评估
我们在9个常用基准测试上进行了评估,包括5个学术视觉问答(VQA)基准和4个流行的多语言多模态模型(MLLM)基准,以将我们的Imp模型与LLaVA (7B) 以及现有类似模型大小的轻量级大语言多模态模型进行比较。
模型 |
大小 |
VQAv2 |
GQA |
SQA(IMG) |
TextVQA |
POPE |
MME(P) |
MMB |
MMB_CN |
MM-Vet |
Bunny-v1.0-4B |
4B |
81.5 |
63.5 |
75.1 |
- |
86.7 |
1495.2 |
73.5 |
- |
- |
Imp-v1.5-4B-Phi3 |
4B |
81.5 |
63.5 |
78.3 |
60.2 |
86.9 |
1507.7 |
73.3 |
61.1 |
44.6 |
📄 许可证
本项目采用Apache License 2.0许可协议 - 详情请参阅 LICENSE 文件。
🔗 相关链接
📖 引用
如果您在研究中使用了我们的模型或参考了我们的工作,请引用:
@article{imp2024,
title={Imp: Highly Capable Large Multimodal Models for Mobile Devices},
author={Shao, Zhenwei and Yu, Zhou and Yu, Jun and Ouyang, Xuecheng and Zheng, Lihao and Gai, Zhenbiao and Wang, Mingyang and Ding, Jiajun},
journal={arXiv preprint arXiv:2405.12107},
year={2024}
}