Views
No views yet
Imp-v1.5-3B-Phi2 is a strong lightweight LMMs with only 3B parameters, which is build upon Phi-2 (2.7B) and a powerful visual encoder SigLIP (0.4B), and trained on 1M mixed dataset.Imp-v1.5-3B-Phi2 significantly outperforms the counterparts of similar model sizes, and even achieves slightly better performance than the strong LLaVA-7B model on various multimodal benchmarks.1pip install transformers # latest version is ok, but we recommend v4.37.0
2pip install -q pillow accelerate einops1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from PIL import Image
4
5torch.set_default_device("cuda")
6
7#Create model
8model = AutoModelForCausalLM.from_pretrained(
9 "MILVLG/Imp-v1.5-3B-Phi2/",
10 torch_dtype=torch.float16,
11 device_map="auto",
12 trust_remote_code=True)
13tokenizer = AutoTokenizer.from_pretrained("MILVLG/Imp-v1.5-3B-Phi2", trust_remote_code=True)
14
15#Set inputs
16text = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\nWhat are the colors of the bus in the image? ASSISTANT:"
17image = Image.open("images/bus.jpg")
18
19input_ids = tokenizer(text, return_tensors='pt').input_ids
20image_tensor = model.image_preprocess(image)
21
22#Generate the answer
23output_ids = model.generate(
24 input_ids,
25 max_new_tokens=100,
26 images=image_tensor,
27 use_cache=True)[0]
28print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())| Models | Size | VQAv2 | GQA | SQA(IMG) | TextVQA | POPE | MME(P) | MMB | MMBCN | MM-Vet |
|---|---|---|---|---|---|---|---|---|---|---|
| LLaVA-v1.5-lora | 7B | 79.1 | 63.0 | 68.4 | 58.2 | 86.4 | 1476.9 | 66.1 | - | 30.2 |
| TinyGPT-V-3B | 3B | - | 38.9 | - | - | - | - | - | - | - |
| LaVA-Phi-3B | 3B | 71.4 | - | 68.4 | 48.6 | 85.0 | 1335.1 | 59.8 | - | 28.9 |
| MobileVLM-3B | 3B | - | 59.0 | 61.0 | 47.5 | 84.9 | 1288.9 | 59.6 | - | - |
| MiniCPM-V-3B | 3B | - | - | - | - | - | 1452.0 | 67.9 | 65.3 | - |
| Bunny-3B | 3B | 79.8 | 62.5 | 70.9 | - | 86.8 | 1488.8 | 68.6 | - | - |
| Imp-v1.5-3B-Phi2 | 3B | 81.2 | 63.5 | 72.8 | 59.8 | 88.9 | 1446.4 | 72.9 | 46.7 | 43.3 |
1@article{imp2024,
2 title={Imp: Highly Capable Large Multimodal Models for Mobile Devices},
3 author={Shao, Zhenwei and Yu, Zhou and Yu, Jun and Ouyang, Xuecheng and Zheng, Lihao and Gai, Zhenbiao and Wang, Mingyang and Ding, Jiajun},
4 journal={arXiv preprint arXiv:2405.12107},
5 year={2024}
6}