BAAI / Emu2-Chat

huggingface.co
Total runs: 135
24-hour runs: 3
7-day runs: 1
30-day runs: -876
Model's Last Updated: December 21 2023
text-generation

Introduction of Emu2-Chat

Model Details of Emu2-Chat

Emu2-Chat

Paper | 🤗HF Demo | Demo | Project Page | Github

Model Weights
Model name Weight
Emu2 🤗 HF link
Emu2-Chat 🤗 HF link
Emu2-Gen 🤗 HF link
Inference (Huggingface Version)
Single GPU
from PIL import Image
import requests
import torch 
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("BAAI/Emu2-Chat")

model = AutoModelForCausalLM.from_pretrained(
    "BAAI/Emu2-Chat",
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True).to('cuda').eval()


# `[<IMG_PLH>]` is the image placeholder which will be replaced by image embeddings. 
# the number of `[<IMG_PLH>]` should be equal to the number of input images

query = '[<IMG_PLH>]Describe the image in details:' 
image = Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/blue_black_1_top_left.jpg?raw=true',stream=True).raw).convert('RGB')


inputs = model.build_input_ids(
    text=[query],
    tokenizer=tokenizer,
    image=[image]
)

with torch.no_grad():
     outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        image=inputs["image"].to(torch.bfloat16),
        max_new_tokens=64,
        length_penalty=-1)

output_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)

Interleaved image and text

from PIL import Image
import requests
import torch 
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("BAAI/Emu2-Chat")

model = AutoModelForCausalLM.from_pretrained(
    "BAAI/Emu2-Chat",
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True).to('cuda').eval()

# `[<IMG_PLH>]` is the image placeholder which will be replaced by image embeddings. 
# the number of `[<IMG_PLH>]` should be equal to the number of input images

query = "[<IMG_PLH>][red, white, 3, bottom left].[<IMG_PLH>][yellow, white, 2, top left].[<IMG_PLH>][green, black, 4, bottom right][<IMG_PLH>]"

images = [
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/red_white_3_bottom_left.jpg?raw=true',stream=True).raw).convert('RGB'),
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/yellow_white_2_top_right.jpg?raw=true',stream=True).raw).convert('RGB'),
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/green_black_4_bottom_right.jpg?raw=true',stream=True).raw).convert('RGB'),
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/blue_black_1_top_left.jpg?raw=true',stream=True).raw).convert('RGB'),
]

inputs = model.build_input_ids(
    text=[query],
    tokenizer=tokenizer,
    image=images

)

with torch.no_grad():
     outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        image=inputs["image"].to(torch.bfloat16),
        max_new_tokens=64,
        length_penalty=-1)

output_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)
Multi GPU
from PIL import Image 
import requests
import torch 
from transformers import AutoModelForCausalLM, AutoTokenizer
from accelerate import init_empty_weights, infer_auto_device_map, load_checkpoint_and_dispatch

tokenizer = AutoTokenizer.from_pretrained("BAAI/Emu2-Chat")

with init_empty_weights():
     model = AutoModelForCausalLM.from_pretrained(
        "BAAI/Emu2-Chat",
        torch_dtype=torch.bfloat16,
        low_cpu_mem_usage=True,
        trust_remote_code=True)  

device_map = infer_auto_device_map(model, max_memory={0:'38GiB',1:'38GiB',}, no_split_module_classes=['Block','LlamaDecoderLayer'])  
# input and output logits should be on same device
device_map["model.decoder.lm.lm_head"] = 0

model = load_checkpoint_and_dispatch(
    model, 
    'local/path/to/hf/version/Emu2-Chat/model',
    device_map=device_map).eval()

# `[<IMG_PLH>]` is the image placeholder which will be replaced by image embeddings. 
# the number of `[<IMG_PLH>]` should be equal to the number of input images

query = '[<IMG_PLH>]Describe the image in details:' 
image = Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/blue_black_1_top_left.jpg?raw=true',stream=True).raw).convert('RGB')

inputs = model.build_input_ids(
    text=[query],
    tokenizer=tokenizer,
    image=[image]

)

with torch.no_grad():
     outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        image=inputs["image"].to(torch.bfloat16),
        max_new_tokens=64,
        length_penalty=-1)

output_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)

Interleaved image and text

from PIL import Image 
import requests
import torch 
from transformers import AutoModelForCausalLM, AutoTokenizer
from accelerate import init_empty_weights, infer_auto_device_map, load_checkpoint_and_dispatch

tokenizer = AutoTokenizer.from_pretrained("BAAI/Emu2-Chat")

with init_empty_weights():
     model = AutoModelForCausalLM.from_pretrained(
        "BAAI/Emu2-Chat",
        torch_dtype=torch.bfloat16,
        low_cpu_mem_usage=True,
        trust_remote_code=True)  

device_map = infer_auto_device_map(model, max_memory={0:'38GiB',1:'38GiB',}, no_split_module_classes=['Block','LlamaDecoderLayer'])  
# input and output logits should be on same device
device_map["model.decoder.lm.lm_head"] = 0

model = load_checkpoint_and_dispatch(
    model, 
    'local/path/to/hf/version/Emu2-Chat/model',
    device_map=device_map).eval()

# `[<IMG_PLH>]` is the image placeholder which will be replaced by image embeddings. 
# the number of `[<IMG_PLH>]` should be equal to the number of input images
query = "[<IMG_PLH>][red, white, 3, bottom left].[<IMG_PLH>][yellow, white, 2, top left].[<IMG_PLH>][green, black, 4, bottom right][<IMG_PLH>]"

images = [
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/red_white_3_bottom_left.jpg?raw=true',stream=True).raw).convert('RGB'),
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/yellow_white_2_top_right.jpg?raw=true',stream=True).raw).convert('RGB'),
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/green_black_4_bottom_right.jpg?raw=true',stream=True).raw).convert('RGB'),
    Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/blue_black_1_top_left.jpg?raw=true',stream=True).raw).convert('RGB'),
]

inputs = model.build_input_ids(
    text=[query],
    tokenizer=tokenizer,
    image=images

)

with torch.no_grad():
     outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        image=inputs["image"].to(torch.bfloat16),
        max_new_tokens=64,
        length_penalty=-1)

output_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)
Quantization

Check quantization guidance at transformers

from PIL import Image 
import requests
import torch 
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("BAAI/Emu2-Chat")

model = AutoModelForCausalLM.from_pretrained(
    "BAAI/Emu2-Chat",
    load_in_4bit=True,
    trust_remote_code=True, 
    bnb_4bit_compute_dtype=torch.float16).eval()

query = '[<IMG_PLH>]Describe the image in details:' 
image = Image.open(requests.get('https://github.com/baaivision/Emu/Emu2/examples/blue_black_1_top_left.jpg?raw=true',stream=True).raw).convert('RGB')

inputs = model.build_input_ids(
    text=[query],
    tokenizer=tokenizer,
    image=[image]

)

with torch.no_grad():
     outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        image=inputs["image"].to(torch.float16), # should be torch.float16
        max_new_tokens=64,
        length_penalty=-1)

output_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)
Citation

If you find Emu2 useful for your research and applications, please consider starring this repository and citing:

@article{Emu2,
    title={Generative Multimodal Models are In-Context Learners}, 
    author={Quan Sun and Yufeng Cui and Xiaosong Zhang and Fan Zhang and Qiying Yu and Zhengxiong Luo and Yueze Wang and Yongming Rao and Jingjing Liu and Tiejun Huang and Xinlong Wang},
    publisher={arXiv preprint arXiv:2312.13286},
    year={2023},
}

Runs of BAAI Emu2-Chat on huggingface.co

135
Total runs
3
24-hour runs
0
3-day runs
1
7-day runs
-876
30-day runs

More Information About Emu2-Chat huggingface.co Model

Emu2-Chat huggingface.co

Emu2-Chat huggingface.co is an AI model on huggingface.co that provides Emu2-Chat's model effect (), which can be used instantly with this BAAI Emu2-Chat model. huggingface.co supports a free trial of the Emu2-Chat model, and also provides paid use of the Emu2-Chat. Support call Emu2-Chat model through api, including Node.js, Python, http.

Emu2-Chat huggingface.co Url

https://huggingface.co/BAAI/Emu2-Chat

BAAI Emu2-Chat online free

Emu2-Chat huggingface.co is an online trial and call api platform, which integrates Emu2-Chat's modeling effects, including api services, and provides a free online trial of Emu2-Chat, you can try Emu2-Chat online for free by clicking the link below.

BAAI Emu2-Chat online free url in huggingface.co:

https://huggingface.co/BAAI/Emu2-Chat

Emu2-Chat install

Emu2-Chat is an open source model from GitHub that offers a free installation service, and any user can find Emu2-Chat on GitHub to install. At the same time, huggingface.co provides the effect of Emu2-Chat install, users can directly use Emu2-Chat installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

Emu2-Chat install url in huggingface.co:

https://huggingface.co/BAAI/Emu2-Chat

Url of Emu2-Chat

Emu2-Chat huggingface.co Url

Provider of Emu2-Chat huggingface.co

BAAI
ORGANIZATIONS

Other API from BAAI

huggingface.co

Total runs: 64.6M
Run Growth: -2.5M
Growth Rate: -3.89%
Updated:February 22 2024
huggingface.co

Total runs: 37.8M
Run Growth: 5.6M
Growth Rate: 14.76%
Updated:July 03 2024
huggingface.co

Total runs: 10.7M
Run Growth: 658.2K
Growth Rate: 6.16%
Updated:February 21 2024
huggingface.co

Total runs: 2.2M
Run Growth: 1.7M
Growth Rate: 77.73%
Updated:April 17 2024
huggingface.co

Total runs: 799.8K
Run Growth: -706.1K
Growth Rate: -88.29%
Updated:October 12 2023
huggingface.co

Total runs: 246.7K
Run Growth: -1.3M
Growth Rate: -507.77%
Updated:December 13 2023
huggingface.co

Total runs: 68.1K
Run Growth: 10.0K
Growth Rate: 14.70%
Updated:July 13 2026
huggingface.co

Total runs: 60.6K
Run Growth: -109.9K
Growth Rate: -181.17%
Updated:October 12 2023
huggingface.co

Total runs: 49.6K
Run Growth: -42.6K
Growth Rate: -85.91%
Updated:October 12 2023
huggingface.co

Total runs: 45.9K
Run Growth: 20.8K
Growth Rate: 45.23%
Updated:November 14 2023
huggingface.co

Total runs: 37.5K
Run Growth: -23.4K
Growth Rate: -62.50%
Updated:January 15 2025
huggingface.co

Total runs: 36.7K
Run Growth: 13.5K
Growth Rate: 36.92%
Updated:October 12 2023
huggingface.co

Total runs: 16.0K
Run Growth: 3.1K
Growth Rate: 19.41%
Updated:April 16 2025
huggingface.co

Total runs: 11.6K
Run Growth: -13.6K
Growth Rate: -116.76%
Updated:October 12 2023
huggingface.co

Total runs: 5.5K
Run Growth: 4.9K
Growth Rate: 89.20%
Updated:April 19 2024
huggingface.co

Total runs: 4.6K
Run Growth: -10.5K
Growth Rate: -231.70%
Updated:May 20 2025
huggingface.co

Total runs: 3.1K
Run Growth: 2.2K
Growth Rate: 69.80%
Updated:September 11 2026
huggingface.co

Total runs: 1.8K
Run Growth: 990
Growth Rate: 54.70%
Updated:December 31 2022
huggingface.co

Total runs: 1.6K
Run Growth: -13.4K
Growth Rate: -855.43%
Updated:January 15 2025
huggingface.co

Total runs: 1.4K
Run Growth: -859
Growth Rate: -59.61%
Updated:April 10 2026
huggingface.co

Total runs: 1.4K
Run Growth: -851
Growth Rate: -61.31%
Updated:April 10 2026
huggingface.co

Total runs: 1.3K
Run Growth: 259
Growth Rate: 20.72%
Updated:September 11 2026
huggingface.co

Total runs: 1.2K
Run Growth: 685
Growth Rate: 56.43%
Updated:October 23 2024
huggingface.co

Total runs: 1.2K
Run Growth: -536
Growth Rate: -46.33%
Updated:November 28 2024
huggingface.co

Total runs: 1.1K
Run Growth: 205
Growth Rate: 16.47%
Updated:February 07 2024
huggingface.co

Total runs: 1.0K
Run Growth: 733
Growth Rate: 70.28%
Updated:October 24 2024
huggingface.co

Total runs: 876
Run Growth: 234
Growth Rate: 26.71%
Updated:May 23 2025
huggingface.co

Total runs: 579
Run Growth: -261
Growth Rate: -45.08%
Updated:July 13 2026
huggingface.co

Total runs: 470
Run Growth: 186
Growth Rate: 39.57%
Updated:April 10 2026
huggingface.co

Total runs: 467
Run Growth: -81
Growth Rate: -17.34%
Updated:July 13 2026
huggingface.co

Total runs: 460
Run Growth: -700
Growth Rate: -152.17%
Updated:April 18 2023
huggingface.co

Total runs: 429
Run Growth: -107
Growth Rate: -24.94%
Updated:October 27 2023
huggingface.co

Total runs: 398
Run Growth: -544
Growth Rate: -136.68%
Updated:August 11 2026
huggingface.co

Total runs: 389
Run Growth: -242
Growth Rate: -62.21%
Updated:December 25 2025
huggingface.co

Total runs: 388
Run Growth: -6
Growth Rate: -1.55%
Updated:August 11 2026
huggingface.co

Total runs: 313
Run Growth: 22
Growth Rate: 7.03%
Updated:July 13 2026
huggingface.co

Total runs: 306
Run Growth: 139
Growth Rate: 45.42%
Updated:July 13 2026
huggingface.co

Total runs: 302
Run Growth: -3.4K
Growth Rate: -1128.48%
Updated:April 10 2026
huggingface.co

Total runs: 290
Run Growth: -77
Growth Rate: -26.01%
Updated:March 07 2024
huggingface.co

Total runs: 286
Run Growth: 218
Growth Rate: 76.22%
Updated:August 18 2026
huggingface.co

Total runs: 285
Run Growth: -602
Growth Rate: -211.23%
Updated:December 25 2025
huggingface.co

Total runs: 279
Run Growth: 60
Growth Rate: 21.51%
Updated:July 13 2026
huggingface.co

Total runs: 279
Run Growth: -11
Growth Rate: -3.94%
Updated:April 10 2026
huggingface.co

Total runs: 254
Run Growth: 10
Growth Rate: 3.94%
Updated:February 11 2025
huggingface.co

Total runs: 213
Run Growth: -70
Growth Rate: -32.86%
Updated:June 06 2025
huggingface.co

Total runs: 213
Run Growth: 37
Growth Rate: 17.37%
Updated:July 13 2026
huggingface.co

Total runs: 210
Run Growth: -145
Growth Rate: -69.05%
Updated:July 17 2026
huggingface.co

Total runs: 209
Run Growth: -82
Growth Rate: -39.23%
Updated:October 23 2024
huggingface.co

Total runs: 202
Run Growth: -65
Growth Rate: -32.18%
Updated:July 13 2026
huggingface.co

Total runs: 185
Run Growth: -102
Growth Rate: -55.14%
Updated:July 13 2026
huggingface.co

Total runs: 181
Run Growth: 34
Growth Rate: 18.78%
Updated:April 02 2024
huggingface.co

Total runs: 179
Run Growth: -166
Growth Rate: -92.74%
Updated:May 13 2024
huggingface.co

Total runs: 176
Run Growth: -38
Growth Rate: -21.59%
Updated:April 10 2026
huggingface.co

Total runs: 167
Run Growth: 89
Growth Rate: 53.29%
Updated:August 23 2023
huggingface.co

Total runs: 166
Run Growth: -30
Growth Rate: -18.07%
Updated:May 13 2024
huggingface.co

Total runs: 165
Run Growth: -31
Growth Rate: -18.79%
Updated:May 13 2024
huggingface.co

Total runs: 165
Run Growth: -36
Growth Rate: -21.82%
Updated:May 31 2024
huggingface.co

Total runs: 160
Run Growth: -1.1K
Growth Rate: -701.88%
Updated:June 24 2024
huggingface.co

Total runs: 153
Run Growth: -44
Growth Rate: -28.76%
Updated:July 13 2026
huggingface.co

Total runs: 147
Run Growth: 147
Growth Rate: 100.00%
Updated:September 05 2026
huggingface.co

Total runs: 144
Run Growth: -94
Growth Rate: -65.28%
Updated:July 13 2026
huggingface.co

Total runs: 137
Run Growth: 34
Growth Rate: 25.19%
Updated:July 02 2024