๐ŸŸ Llama-3-EvoVLM-JP-v2

๐Ÿค— Models | ๐Ÿ“š Paper | ๐Ÿ“ Blog | ๐Ÿฆ Twitter

Llama-3-EvoVLM-JP-v2 is an experimental general-purpose Japanese VLM with interleaved text and image as inputs. This model was created using the Evolutionary Model Merge method. Please refer to our report and blog for more details. This model was produced by merging the following models. We are grateful to the developers of the source models.

Usage

Use the code below to get started with the model.

Click to expand

First, you need to install packages for inference using the Mantis. See here.

pip install git+https://github.com/TIGER-AI-Lab/Mantis.git
import requests
from PIL import Image

import torch
from mantis.models.conversation import Conversation, SeparatorStyle
from mantis.models.mllava import chat_mllava, LlavaForConditionalGeneration, MLlavaProcessor
from mantis.models.mllava.utils import conv_templates
from transformers import AutoTokenizer

# 1. Set the system prompt
conv_llama_3_elyza = Conversation(
    system="<|start_header_id|>system<|end_header_id|>\n\nใ‚ใชใŸใฏ่ช ๅฎŸใงๅ„ช็ง€ใชๆ—ฅๆœฌไบบใฎใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚็‰นใซๆŒ‡็คบใŒ็„กใ„ๅ ดๅˆใฏใ€ๅธธใซๆ—ฅๆœฌ่ชžใงๅ›ž็ญ”ใ—ใฆใใ ใ•ใ„ใ€‚",
    roles=("user", "assistant"),
    messages=(),
    offset=0,
    sep_style=SeparatorStyle.LLAMA_3,
    sep="<|eot_id|>",
)
conv_templates["llama_3"] = conv_llama_3_elyza

# 2. Load model
device = "cuda" if torch.cuda.is_available() else "cpu"
model_id = "SakanaAI/Llama-3-EvoVLM-JP-v2"

processor = MLlavaProcessor.from_pretrained("TIGER-Lab/Mantis-8B-siglip-llama3")
processor.tokenizer.pad_token = processor.tokenizer.eos_token

model = LlavaForConditionalGeneration.from_pretrained(model_id, torch_dtype=torch.float16, device_map=device).eval()

# 3. Prepare a generate config
generation_kwargs = {
    "max_new_tokens": 128,
    "num_beams": 1,
    "do_sample": False,
    "no_repeat_ngram_size": 3,
}

# 4. Generate
text = "<image>ใฎไฟกๅทใฏไฝ•่‰ฒใงใ™ใ‹๏ผŸ"
url_list = [
    "https://images.unsplash.com/photo-1694831404826-3400c48c188d?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
    "https://images.unsplash.com/photo-1693240876439-473af88b4ed7?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
]
images = [
   Image.open(requests.get(url_list[0], stream=True).raw).convert("RGB")
]

response, history = chat_mllava(text, images, model, processor, **generation_kwargs)

print(response)
# ไฟกๅทใฎ่‰ฒใฏใ€้’่‰ฒใงใ™ใ€‚

# 5. Multi-turn conversation
text = "ใงใฏใ€<image>ใฎไฟกๅทใฏ๏ผŸ"
images += [
   Image.open(requests.get(url_list[1], stream=True).raw).convert("RGB")
]
response, history = chat_mllava(text, images, model, processor, history=history, **generation_kwargs)

print(response)
# ่ตค่‰ฒ

Model Details

Uses

This model is provided for research and development purposes only and should be considered as an experimental prototype. It is not intended for commercial use or deployment in mission-critical environments. Use of this model is at the user's own risk, and its performance and outcomes are not guaranteed. Sakana AI shall not be liable for any direct, indirect, special, incidental, or consequential damages, or any loss arising from the use of this model, regardless of the results obtained. Users must fully understand the risks associated with the use of this model and use it at their own discretion.

Acknowledgement

We would like to thank the developers of the source models for their contributions and for making their work available.

Citation

@misc{Llama-3-EvoVLM-JP-v2, 
url    = {[https://huggingface.co/SakanaAI/Llama-3-EvoVLM-JP-v2](https://huggingface.co/SakanaAI/Llama-3-EvoVLM-JP-v2)}, 
title  = {Llama-3-EvoVLM-JP-v2}, 
author = {Yuichi, Inoue and Takuya, Akiba and Shing, Makoto}
}
@misc{akiba2024evomodelmerge,
      title         = {Evolutionary Optimization of Model Merging Recipes}, 
      author.       = {Takuya Akiba and Makoto Shing and Yujin Tang and Qi Sun and David Ha},
      year          = {2024},
      eprint        = {2403.13187},
      archivePrefix = {arXiv},
      primaryClass  = {cs.NE}
}
Downloads last month
1,583
Safetensors
Model size
8.48B params
Tensor type
FP16
ยท
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Spaces using SakanaAI/Llama-3-EvoVLM-JP-v2 2