M^3IT: A Large-Scale Dataset towards Multi-Modal Multilingual Instruction Tuning
Paper โข 2306.04387 โข Published โข 10
Run MMInstruction/YingVLM on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/MMInstruction/YingVLM. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/MMInstruction/YingVLM on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use MMInstruction/YingVLM with Transformers:
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, VLM
processor = AutoProcessor.from_pretrained("MMInstruction/YingVLM")
model = VLM.from_pretrained("MMInstruction/YingVLM", device_map="auto")YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
We open-sourced the trained checkpoint and infernce code of YING-VLM at huggingface, which is trained on M3IT dataset.
Please install the following packages:
Infernce example:
from transformers import AutoProcessor, AutoTokenizer
from PIL import Image
import torch
from modelingYING import VLMForConditionalGeneration
# set device
device="cuda:0"
# set prompt template
prompt_template = """
<human>:
{instruction}
{input}
<bot>:
"""
# load processor and tokenizer
processor = AutoProcessor.from_pretrained("MMInstruction/YingVLM")
tokenizer = AutoTokenizer.from_pretrained("MMInstruction/YingVLM") # ziya is not available right now
# load model
model = VLMForConditionalGeneration.from_pretrained("MMInstruction/YingVLM")
model.to(device,dtype=torch.float16)
# prepare input
image = Image.open("./imgs/night_house.jpeg")
instruction = "Scrutinize the given image and answer the connected question."
input = "What is the color of the couch?"
prompt = prompt_template.format(instruction=instruction, input=input)
# inference
inputs = processor(images=image, return_tensors="pt").to(device, torch.float16)
text_inputs = tokenizer(prompt, return_tensors="pt")
inputs.update(text_inputs)
generated_ids = model.generate(**{k: v.to(device) for k, v in inputs.items()}, img_num=1, max_new_tokens=128, do_sample=False)
generated_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0].split("\n")[0] # \n is the end token
print(generated_text)
# The couch in the living room is green.
If you find our work useful, please kindly cite
@article{li2023m3it,
title={M$^3$IT: A Large-Scale Dataset towards Multi-Modal Multilingual Instruction Tuning},
author={Lei Li and Yuwei Yin and Shicheng Li and Liang Chen and Peiyi Wang and Shuhuai Ren and Mukai Li and Yazheng Yang and Jingjing Xu and Xu Sun and Lingpeng Kong and Qi Liu},
journal={arXiv preprint arXiv:2306.04387},
year={2023}
}