OpenBMB / OmniLMM

Large Multi-modal Models for Strong Performance and Efficient Deployment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Large multi-modal models for strong performance and efficient deployment

OmniLMM-3B πŸ€— πŸ€– | OmniLMM-12B πŸ€— πŸ€–

OmniLMM is a family of open-source large multimodal models (LMMs) adept at vision & language modeling. The model processes images and text inputs and delivers high-quality text outputs. We release two featured versions of OmniLMM that are targeted at strong performance and efficient deployment:

  • OmniLMM-12B: Leading performance among comparable-sized models on multiple benchmarks.

  • OmniLMM-3B: Frontier end device multi-modal conversation with promising performance.

δΈ­ζ–‡ζ–‡ζ‘£

Contents

OmniLMM-12B

OmniLMM-12B is the most capable version. The model is built based on EVA02-5B and Zephyr-7B-Ξ², connected with a perceiver resampler layer, and trained on multimodal data in a curriculum fashion. The model has three notable features:

  • πŸ”₯ Strong Performance.

    OmniLMM-12B achieves leading performance among models with comparable sizes, surpassing established LMMs on multiple benchmarks (including MME, MMBench, SEED-Bench, etc). The model also endows rich multi-modal world knowledge.

  • πŸ† Trustworthy Behavior.

    LMMs are known for suffering from hallucination, often generating text that is not factually grounded in images (e.g., faithfully describing non-existing objects in images). OmniLMM-12B is the first state-of-the-art open-source LMM aligned via multimodal RLHF for trustworthy behavior (using the recent RLHF-V technique). It ranks #1 among open-source models on MMHal-Bench, and outperforms GPT-4V on Object HalBench.

  • πŸ•Ή Real-time Multimodal Interaction.

    We combine the OmniLMM-12B and GPT-3.5 (text-only) into a real-time multimodal interactive assistant. The assistant accepts video streams from the camera and speech streams from the microphone and emits speech output. While still primary, we find the model can replicate some of the fun cases shown in the Gemini Demo video, without any video edition.

Evaluation

Click to view results on MME, MMBench, MMMU, MMBench, MMHal-Bench, Object HalBench, SeedBench, LLaVA Bench W, MathVista.
Model Size MME MMB dev (en) MMMU val MMHal-Bench Object HalBench SeedBench-I MathVista LLaVA Bench W
GPT-4V† - 1409 75.1 56.8 3.53 / 70.8 86.4 / 92.7 71.6 47.8 93.1
Qwen-VL-Plus† - 1681 66.2 45.2 - - 65.7 36.0 73.7
Yi-VL 6B 6.7B - 68.2 39.1 - - 66.1 28.0 39.9
Qwen-VL-Chat 9.6B 1488 60.6 35.9 2.93 / 59.4 56.2 / 80.0 64.8 33.8 67.7
CogVLM 17.4B 1438 63.7 32.1 2.68 / 52.1 73.6 / 87.4 68.8 34.7 73.9
LLaVA 1.5 13.6B 1531 68.2 36.4 2.71 / 51.0 53.7 / 77.4 68.1 26.4 64.6
OmniLMM-12B 11.6B 1637 71.6 40.7 3.45 / 68.8 90.3 / 95.5 71.1 34.9 72.0
†: Proprietary models

Examples

We combine the OmniLMM-12B and GPT-3.5 (text-only) into a real-time multimodal interactive assistant. Video frames are described in text using OmniLMM-12B, and ChatGPT 3.5 (text-only) is employed to generate response according to the descriptions and user prompts. The demo video is a raw recording without edition.

OmniLMM_video_demo_en.mp4

OmniLMM-3B

OmniLMM-3B (i.e., MiniCPM-V) is an efficient version with promising performance for deployment. The model is built based on SigLip-400M and MiniCPM-2.4B, connected by a perceiver resampler. Notable features of OmniLMM-3B include:

  • ⚑️ High Efficiency.

    OmniLMM-3B can be efficiently deployed on most GPU cards and personal computers, and even on end devices such as mobile phones. In terms of visual encoding, we compress the image representations into 64 tokens via a perceiver resampler, which is significantly fewer than other LMMs based on MLP architecture (typically > 512 tokens). This allows OmniLMM-3B to operate with much less memory cost and higher speed during inference.

  • πŸ”₯ Promising Performance.

    OmniLMM-3B achieves state-of-the-art performance on multiple benchmarks (including MMMU, MME, and MMbech, etc) among models with comparable sizes, surpassing existing LMMs built on Phi-2. It even achieves comparable or better performance than the 9.6B Qwen-VL-Chat.

  • πŸ™Œ Bilingual Support.

    OmniLMM-3B is the first end-deployable LMM supporting bilingual multimodal interaction in English and Chinese. This is achieved by generalizing multimodal capabilities across languages, a technique from the ICLR 2024 spotlight paper.

Evaluation

Model Size Visual Tokens MME MMB dev (en) MMB dev (zh) MMMU val CMMMU val
LLaVA-Phi 3B 576 1335 59.8 - - -
MobileVLM 3B 144 1289 59.6 - - -
Imp-v1 3B 576 1434 66.5 - - -
Qwen-VL-Chat 9.6B 256 1487 60.6 56.7 35.9 30.7
CogVLM 17.4B 1225 1438 63.7 53.8 32.1 -
OmniLMM-3B 3B 64 1452 67.9 65.3 37.2 32.1

Examples

We deploy OmniLLM-3B on end devices. The demo video is the raw screen recording on a OnePlus 9R without edition.

Demo

Click here to try out the Demo of OmniLMM-12B and OmniLMM-3B.

Install

  1. Clone this repository and navigate to the source folder
git clone https://github.com/OpenBMB/OmniLMM.git
cd OmniLMM
  1. Create conda environment
conda create -n OmniLMM python=3.10 -y
conda activate OmniLMM
  1. Install dependencies
pip install -r requirements.txt

Inference

Model Zoo

Model Description Download Link
OmniLMM-12B The most capable version with strong performance. πŸ€—   
OmniLMM-3B The efficient version for end device deployment. πŸ€—   

Multi-turn Conversation

Please refer to the following codes to run OmniLMM.

from chat import OmniLMMChat, img2base64

chat_model = OmniLMMChat('openbmb/OmniLMM-12B') # or 'openbmb/MiniCPM-V'

im_64 = img2base64('./assets/worldmap_ck.jpg')

# First round chat 
msgs = [{"role": "user", "content": "What is interesting about this image?"}]

inputs = {"image": im_64, "question": json.dumps(msgs)}
answer = chat_model.chat(inputs)
print(answer)

# Second round chat 
# pass history context of multi-turn conversation
msgs.append({"role": "assistant", "content": answer})
msgs.append({"role": "user", "content": "Where is China in the image"})

inputs = {"image": im_64, "question": json.dumps(msgs)}
answer = chat_model.chat(inputs)
print(answer)

We can obtain the following results:

"The interesting aspect of this image is the shape of the chicken nuggets on the pan. The nuggets are shaped like the continents of the world, which is an unusual and creative way to present the food. It adds a fun and playful element to the meal, making it more visually appealing and engaging."

"In the image, China is located on the right side of the pan. It is one of the nuggets shaped like the continents of the world, and its placement on the right side of the pan is consistent with its geographical location in the real world"

Inference on Mac

Click to view example, OmniLMM-3B (i.e., MiniCPM-V) can run on Mac with MPS (Apple silicon or AMD GPUs).
# test.py
import torch
from PIL import Image
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True, torch_dtype=torch.bfloat16)
model = model.to(device='mps', dtype=torch.float16)

tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
model.eval()

image = Image.open('./assets/worldmap_ck.jpg').convert('RGB')
question = 'What is interesting about this image?'
msgs = [{'role': 'user', 'content': question}]

answer, context, _ = model.chat(
    image=image,
    msgs=msgs,
    context=None,
    tokenizer=tokenizer,
    sampling=True
)
print(answer)

Run with command:

PYTORCH_ENABLE_MPS_FALLBACK=1 python test.py

Deployment on Mobile Phone

Currently OmniLMM-3B (i.e., MiniCPM-V) can be deployed on mobile phones with Android and Harmony operating systems. πŸš€ Try it out here.

TODO

  • Fine-tuning support
  • Local Web-UI deployment
  • Code release for real-time interactive assistant

Model License

The code in this repo is released according to Apache-2.0

The usage of OmniLMMs' parameters is subject to "General Model License Agreement - Source Notes - Publicity Restrictions - Commercial License"

The parameters are fully open to acedemic research

Please contact cpm@modelbest.cn to obtain a written authorization for commercial uses. Free commercial use is also allowed after registration.

Statement

As LMMs, OmniLMMs generate contents by learning a large mount of multimodal corpora, but it cannot comprehend, express personal opinions or make value judgement. Anything generated by OmniLMMs does not represent the views and positions of the model developers

We will not be liable for any problems arising from the use of OmniLMM open source models, including but not limited to data security issues, risk of public opinion, or any risks and problems arising from the misdirection, misuse, dissemination or misuse of the model.

Institutions

This project is developed by the following institutions:

About

Large Multi-modal Models for Strong Performance and Efficient Deployment

License:Apache License 2.0


Languages

Language:Python 100.0%