Views
No views yet

| Ovis MLLMs | ViT | LLM | Training Datasets | Code | Model Weights |
|---|---|---|---|---|---|
| Ovis1.5-Llama3-8B | Siglip-400M | Llama3-8B-Instruct | Huggingface | Github | Huggingface |
| Ovis1.5-Gemma2-9B | Siglip-400M | Gemma2-9B-It | Huggingface | Github | Huggingface |
| MiniCPM-Llama3-V2.5 | GLM-4V-9B | Ovis1.5-Llama3-8B | Ovis1.5-Gemma2-9B | |
|---|---|---|---|---|
| Open Weights | ✅ | ✅ | ✅ | ✅ |
| Open Datasets | ❌ | ❌ | ✅ | ✅ |
| MMTBench-VAL | 57.6 | 48.8 | 60.7 | 62.7 |
| MMBench-EN-V1.1 | 74 | 68.7 | 78.2 | 78.0 |
| MMBench-CN-V1.1 | 70.1 | 67.1 | 75.2 | 75.1 |
| MMStar | 51.8 | 54.8 | 57.2 | 58.7 |
| MMMU-Val | 45.8 | 46.9 | 48.6 | 49.8 |
| MathVista-Mini | 54.3 | 51.1 | 62.4 | 65.7 |
| HallusionBenchAvg | 42.4 | 45 | 44.5 | 48.0 |
| AI2D | 78.4 | 71.2 | 82.5 | 84.7 |
| OCRBench | 725 | 776 | 743 | 756 |
| MMVet | 52.8 | 58 | 52.2 | 56.5 |
| RealWorldQA | 63.5 | 66 | 64.6 | 66.9 |
| CharXiv Reasoning | 24.9 | - | 28.2 | 28.4 |
| CharXiv Descriptive | 59.3 | - | 60.2 | 62.6 |
pip install torch==2.1.0 transformers==4.42.4 pillow==10.3.01import torch
2from PIL import Image
3from transformers import AutoModelForCausalLM
4
5# load model
6model = AutoModelForCausalLM.from_pretrained("AIDC-AI/Ovis1.5-Llama3-8B",
7 torch_dtype=torch.bfloat16,
8 multimodal_max_length=8192,
9 trust_remote_code=True).cuda()
10text_tokenizer = model.get_text_tokenizer()
11visual_tokenizer = model.get_visual_tokenizer()
12conversation_formatter = model.get_conversation_formatter()
13
14# enter image path and prompt
15image_path = input("Enter image path: ")
16image = Image.open(image_path)
17text = input("Enter prompt: ")
18query = f'<image>\n{text}'
19prompt, input_ids = conversation_formatter.format_query(query)
20input_ids = torch.unsqueeze(input_ids, dim=0).to(device=model.device)
21attention_mask = torch.ne(input_ids, text_tokenizer.pad_token_id).to(device=model.device)
22pixel_values = [visual_tokenizer.preprocess_image(image).to(
23 dtype=visual_tokenizer.dtype, device=visual_tokenizer.device)]
24
25# generate output
26with torch.inference_mode():
27 gen_kwargs = dict(
28 max_new_tokens=1024,
29 do_sample=False,
30 top_p=None,
31 top_k=None,
32 temperature=None,
33 repetition_penalty=None,
34 eos_token_id=model.generation_config.eos_token_id,
35 pad_token_id=text_tokenizer.pad_token_id,
36 use_cache=True
37 )
38 output_ids = model.generate(input_ids, pixel_values=pixel_values, attention_mask=attention_mask, **gen_kwargs)[0]
39 output = text_tokenizer.decode(output_ids, skip_special_tokens=True)
40 print(f'Output: {output}')@article{lu2024ovis,
title={Ovis: Structural Embedding Alignment for Multimodal Large Language Model},
author={Shiyin Lu and Yang Li and Qing-Guo Chen and Zhao Xu and Weihua Luo and Kaifu Zhang and Han-Jia Ye},
year={2024},
journal={arXiv:2405.20797}
}