TIGER-Lab/Mantis-8B-siglip-llama3

Model

33

stars

9

commits

9

repos using this model

1

linked in READMEs

Nov 15, 2024

updated

conversational
endpoints_compatible
image-text-to-text
llama3
llava
lmm
mantis
multimodal
safetensors
siglip
transformers
vlm
Browse cluster: Multimodal LLM Vision Architectures

README

🔥 Mantis (TMLR 2024)

Paper | Website | Github | Models | Demo | Wandb

Mantis

Summary

  • Mantis is an LLaMA-3 based LMM with interleaved text and image as inputs, train on Mantis-Instruct under academic-level resources (i.e. 36 hours on 16xA100-40G).
  • Mantis is trained to have multi-image skills including co-reference, reasoning, comparing, temporal understanding.
  • Mantis reaches the state-of-the-art performance on five multi-image benchmarks (NLVR2, Q-Bench, BLINK, MVBench, Mantis-Eval), and also maintain a strong single-image performance on par with CogVLM and Emu2.

Multi-Image Performance

ModelsSizeFormatNLVR2Q-BenchMantis-EvalBLINKMVBenchAvg
GPT-4V-sequence88.8076.5262.6751.1443.5064.5
Open Source Models
Random--48.9340.2023.0438.0927.3035.5
Kosmos21.6Bmerge49.0035.1030.4137.5021.6234.7
LLaVA-v1.57Bmerge53.8849.3231.3437.1336.0041.5
LLava-V1.67Bmerge58.8854.8045.6239.5540.9048.0
Qwen-VL-Chat7Bmerge58.7245.9039.1731.1742.1543.4
Fuyu8Bmerge51.1049.1527.1936.5930.2038.8
BLIP-213Bmerge59.4251.2049.7739.4531.4046.2
InstructBLIP13Bmerge60.2644.3045.6242.2432.5045.0
CogVLM17Bmerge58.5853.2045.1641.5437.3047.2
OpenFlamingo9Bsequence36.4119.6012.4439.187.9023.1
Otter-Image9Bsequence49.1517.5014.2936.2615.3026.5
Idefics19Bsequence54.6330.6028.1124.6926.4232.9
VideoLLaVA7Bsequence56.4845.7035.9438.9244.3044.3
Emu2-Chat37Bsequence58.1650.0537.7936.2039.7244.4
Vila8Bsequence76.4545.7051.1539.3049.4052.4
Idefics28Bsequence86.8757.0048.8545.1829.6853.5
Mantis-CLIP8Bsequence84.6666.0055.7647.0648.3060.4
Mantis-SIGLIP8Bsequence87.4369.9059.4546.3550.1562.7
Mantis-Flamingo9Bsequence52.9646.8032.7238.0040.8342.3
Mantis-Idefics28Bsequence89.7175.2057.1449.0551.3864.5
$\Delta$ over SOTA--+2.84+18.20+8.30+3.87+1.98+11.0

Single-Image Performance

ModelSizeTextVQAVQAMMBMMMUOKVQASQAMathVistaAvg
OpenFlamingo9B46.358.032.428.751.445.718.640.2
Idefics19B39.368.845.332.550.451.621.144.1
InstructBLIP7B33.675.238.330.645.270.624.445.4
Yi-VL6B44.872.568.439.151.371.729.753.9
Qwen-VL-Chat7B63.878.261.835.956.668.215.554.3
LLaVA-1.57B58.276.664.835.353.470.425.654.9
Emu2-Chat37B66.684.963.636.364.865.330.758.9
CogVLM17B70.482.365.832.164.865.635.059.4
Idefics28B70.479.175.743.053.586.551.465.7
Mantis-CLIP8B56.473.066.038.153.073.831.756.0
Mantis-SigLIP8B59.274.968.740.155.474.934.458.2
Mantis-Idefics28B63.577.675.741.152.681.340.461.7

How to use

Installation

# This only installs minimum packages (torch, transformers, accelerate) for inference, no redundant packages are installed.
pip install git+https://github.com/TIGER-AI-Lab/Mantis.git

Run example inference:

from mantis.models.mllava import chat_mllava
from PIL import Image
import torch


image1 = "image1.jpg"
image2 = "image2.jpg"
images = [Image.open(image1), Image.open(image2)]

# load processor and model
from mantis.models.mllava import MLlavaProcessor, LlavaForConditionalGeneration
processor = MLlavaProcessor.from_pretrained("TIGER-Lab/Mantis-8B-siglip-llama3")
attn_implementation = None # or "flash_attention_2"
model = LlavaForConditionalGeneration.from_pretrained("TIGER-Lab/Mantis-8B-siglip-llama3", device_map="cuda", torch_dtype=torch.bfloat16, attn_implementation=attn_implementation)

generation_kwargs = {
    "max_new_tokens": 1024,
    "num_beams": 1,
    "do_sample": False
}

# chat
text = "Describe the difference of <image> and <image> as much as you can."
response, history = chat_mllava(text, images, model, processor, **generation_kwargs)

print("USER: ", text)
print("ASSISTANT: ", response)

text = "How many wallets are there in image 1 and image 2 respectively?"
response, history = chat_mllava(text, images, model, processor, history=history, **generation_kwargs)

print("USER: ", text)
print("ASSISTANT: ", response)

"""
USER:  Describe the difference of <image> and <image> as much as you can.
ASSISTANT:  The second image has more variety in terms of colors and designs. While the first image only shows two brown leather pouches, the second image features four different pouches in various colors and designs, including a purple one with a gold coin, a red one with a gold coin, a black one with a gold coin, and a brown one with a gold coin. This variety makes the second image more visually interesting and dynamic.
USER:  How many wallets are there in image 1 and image 2 respectively?
ASSISTANT:  There are two wallets in image 1, and four wallets in image 2.
"""

Training

See mantis/train for details

Evaluation

See mantis/benchmark for details

Please cite our paper or give a star to out Github repo if you find this model useful

Citation

@article{Jiang2024MANTISIM,
  title={MANTIS: Interleaved Multi-Image Instruction Tuning},
  author={Dongfu Jiang and Xuan He and Huaye Zeng and Cong Wei and Max W.F. Ku and Qian Liu and Wenhu Chen},
  journal={Transactions on Machine Learning Research},
  year={2024},
  volume={2024},
  url={https://openreview.net/forum?id=skLtdUVaJa}
}

Contributors

DongfuJiang

9 commits

TIGER-Lab/Mantis-8B-siglip-llama3

Model

33

stars

9

commits

9

repos using this model

1

linked in READMEs

Nov 15, 2024

updated

conversational
endpoints_compatible
image-text-to-text
llama3
llava
lmm
mantis
multimodal
safetensors
siglip
transformers
vlm
Browse cluster: Multimodal LLM Vision Architectures

README

🔥 Mantis (TMLR 2024)

Paper | Website | Github | Models | Demo | Wandb

Mantis

Summary

  • Mantis is an LLaMA-3 based LMM with interleaved text and image as inputs, train on Mantis-Instruct under academic-level resources (i.e. 36 hours on 16xA100-40G).
  • Mantis is trained to have multi-image skills including co-reference, reasoning, comparing, temporal understanding.
  • Mantis reaches the state-of-the-art performance on five multi-image benchmarks (NLVR2, Q-Bench, BLINK, MVBench, Mantis-Eval), and also maintain a strong single-image performance on par with CogVLM and Emu2.

Multi-Image Performance

ModelsSizeFormatNLVR2Q-BenchMantis-EvalBLINKMVBenchAvg
GPT-4V-sequence88.8076.5262.6751.1443.5064.5
Open Source Models
Random--48.9340.2023.0438.0927.3035.5
Kosmos21.6Bmerge49.0035.1030.4137.5021.6234.7
LLaVA-v1.57Bmerge53.8849.3231.3437.1336.0041.5
LLava-V1.67Bmerge58.8854.8045.6239.5540.9048.0
Qwen-VL-Chat7Bmerge58.7245.9039.1731.1742.1543.4
Fuyu8Bmerge51.1049.1527.1936.5930.2038.8
BLIP-213Bmerge59.4251.2049.7739.4531.4046.2
InstructBLIP13Bmerge60.2644.3045.6242.2432.5045.0
CogVLM17Bmerge58.5853.2045.1641.5437.3047.2
OpenFlamingo9Bsequence36.4119.6012.4439.187.9023.1
Otter-Image9Bsequence49.1517.5014.2936.2615.3026.5
Idefics19Bsequence54.6330.6028.1124.6926.4232.9
VideoLLaVA7Bsequence56.4845.7035.9438.9244.3044.3
Emu2-Chat37Bsequence58.1650.0537.7936.2039.7244.4
Vila8Bsequence76.4545.7051.1539.3049.4052.4
Idefics28Bsequence86.8757.0048.8545.1829.6853.5
Mantis-CLIP8Bsequence84.6666.0055.7647.0648.3060.4
Mantis-SIGLIP8Bsequence87.4369.9059.4546.3550.1562.7
Mantis-Flamingo9Bsequence52.9646.8032.7238.0040.8342.3
Mantis-Idefics28Bsequence89.7175.2057.1449.0551.3864.5
$\Delta$ over SOTA--+2.84+18.20+8.30+3.87+1.98+11.0

Single-Image Performance

ModelSizeTextVQAVQAMMBMMMUOKVQASQAMathVistaAvg
OpenFlamingo9B46.358.032.428.751.445.718.640.2
Idefics19B39.368.845.332.550.451.621.144.1
InstructBLIP7B33.675.238.330.645.270.624.445.4
Yi-VL6B44.872.568.439.151.371.729.753.9
Qwen-VL-Chat7B63.878.261.835.956.668.215.554.3
LLaVA-1.57B58.276.664.835.353.470.425.654.9
Emu2-Chat37B66.684.963.636.364.865.330.758.9
CogVLM17B70.482.365.832.164.865.635.059.4
Idefics28B70.479.175.743.053.586.551.465.7
Mantis-CLIP8B56.473.066.038.153.073.831.756.0
Mantis-SigLIP8B59.274.968.740.155.474.934.458.2
Mantis-Idefics28B63.577.675.741.152.681.340.461.7

How to use

Installation

# This only installs minimum packages (torch, transformers, accelerate) for inference, no redundant packages are installed.
pip install git+https://github.com/TIGER-AI-Lab/Mantis.git

Run example inference:

from mantis.models.mllava import chat_mllava
from PIL import Image
import torch


image1 = "image1.jpg"
image2 = "image2.jpg"
images = [Image.open(image1), Image.open(image2)]

# load processor and model
from mantis.models.mllava import MLlavaProcessor, LlavaForConditionalGeneration
processor = MLlavaProcessor.from_pretrained("TIGER-Lab/Mantis-8B-siglip-llama3")
attn_implementation = None # or "flash_attention_2"
model = LlavaForConditionalGeneration.from_pretrained("TIGER-Lab/Mantis-8B-siglip-llama3", device_map="cuda", torch_dtype=torch.bfloat16, attn_implementation=attn_implementation)

generation_kwargs = {
    "max_new_tokens": 1024,
    "num_beams": 1,
    "do_sample": False
}

# chat
text = "Describe the difference of <image> and <image> as much as you can."
response, history = chat_mllava(text, images, model, processor, **generation_kwargs)

print("USER: ", text)
print("ASSISTANT: ", response)

text = "How many wallets are there in image 1 and image 2 respectively?"
response, history = chat_mllava(text, images, model, processor, history=history, **generation_kwargs)

print("USER: ", text)
print("ASSISTANT: ", response)

"""
USER:  Describe the difference of <image> and <image> as much as you can.
ASSISTANT:  The second image has more variety in terms of colors and designs. While the first image only shows two brown leather pouches, the second image features four different pouches in various colors and designs, including a purple one with a gold coin, a red one with a gold coin, a black one with a gold coin, and a brown one with a gold coin. This variety makes the second image more visually interesting and dynamic.
USER:  How many wallets are there in image 1 and image 2 respectively?
ASSISTANT:  There are two wallets in image 1, and four wallets in image 2.
"""

Training

See mantis/train for details

Evaluation

See mantis/benchmark for details

Please cite our paper or give a star to out Github repo if you find this model useful

Citation

@article{Jiang2024MANTISIM,
  title={MANTIS: Interleaved Multi-Image Instruction Tuning},
  author={Dongfu Jiang and Xuan He and Huaye Zeng and Cong Wei and Max W.F. Ku and Qian Liu and Wenhu Chen},
  journal={Transactions on Machine Learning Research},
  year={2024},
  volume={2024},
  url={https://openreview.net/forum?id=skLtdUVaJa}
}

Contributors

DongfuJiang

9 commits