Views
No views yet
1# We have developed this implementation with `transformers==4.57.1`. Other versions of transformers may also work, but we have not tested them.
2pip install "transformers[torch]==4.57.1" pillow1from transformers import AutoConfig, AutoModelForImageTextToText, AutoProcessor
2
3MODEL_NAME = "turing-motors/Heron-NVILA-Lite-15B-hf"
4
5# you can use config
6config = AutoConfig.from_pretrained(MODEL_NAME, trust_remote_code=True)
7model = AutoModelForImageTextToText.from_config(config, trust_remote_code=True)
8
9# or directly from_pretrained
10model = AutoModelForImageTextToText.from_pretrained(MODEL_NAME, trust_remote_code=True, device_map="auto")
11
12# load processor
13processor = AutoProcessor.from_pretrained(MODEL_NAME, trust_remote_code=True)
14
15# show chat_template
16print(processor.tokenizer.chat_template)
17
18def generate_content(content: str, images: list | None = None, **kwargs) -> str:
19 conversation = [{"role": "user", "content": content}]
20 text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
21 encoding = processor(text=text, images=images, return_tensors="pt").to(model.device)
22 output = model.generate(**encoding, **kwargs)
23 return processor.decode(output[0, len(encoding["input_ids"][0]):], skip_special_tokens=True)
24
25# examples generate with raw text
26response = generate_content("こんにちは")
27print(response)
28print("---" * 40)
29
30# examples generate with text + image
31from PIL import Image
32import requests
33url = "http://images.cocodataset.org/val2017/000000039769.jpg"
34image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
35response = generate_content("<image>\n画像を説明してください。", images=[image])
36print(response)
37print("---" * 40)
38
39# examples generate using generation_config
40from PIL import Image
41import requests
42from transformers import GenerationConfig
43generation_config = {
44 "max_new_tokens": 512,
45 "temperature": 0.5,
46 "do_sample": True,
47}
48generation_config = GenerationConfig(**generation_config)
49url = "http://images.cocodataset.org/val2017/000000039769.jpg"
50image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
51response = generate_content(
52 "<image>\n画像を説明してください。",
53 images=[image],
54 generation_config=generation_config
55)
56print(response)
57print("---" * 40)
58
59# examples generate with text + image + text + image + text
60from PIL import Image
61import requests
62url_list = [
63 "https://images.unsplash.com/photo-1694831404826-3400c48c188d?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
64 "https://images.unsplash.com/photo-1693240876439-473af88b4ed7?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
65]
66images = [
67 Image.open(requests.get(url, stream=True).raw).convert("RGB") for url in url_list
68]
69response = generate_content("".join([
70 "<image>\n",
71 "これは日本の画像です",
72 "<image>\n",
73 "これはオーストリアの画像です",
74 "各画像の違いを説明して"]), images)
75print(response)
76print("---" * 40)| Stage | Training | Data Sources | Samples |
|---|---|---|---|
| Stage1 | Projector | Japanese image text pairs, LLaVA-Pretrain | 1.1M |
| Stage2 | Projector, LLM | Filtered MOMIJI (CC-MAIN-2024-46, CC-MAIN-2024-51, CC-MAIN-2025-05) | 13M |
| Japanese image text pairs (subset), Japanese interleaved data (subset), mmc4-core (subset), coyo-700m (subset), wikipedia_ja, llava_pretrain_ja, stair_captions | 20M | ||
| Stage3 | Vision Encoder, Projector, LLM | llava-instruct-v1_5-en-subset-358k, llava-instruct-ja, japanese-photos-conv, ja-vg-vqa, synthdog-ja (subset), ai2d, synthdog-en, sherlock | 1.1M |
| Model | LLM Size | Heron-Bench overall LLM (%) | JA-VLM-Bench-In-the-Wild LLM (/5.0) | JA-VG-VQA-500 LLM (/5.0) |
|---|---|---|---|---|
| Heron-NVILA-Lite-1B | 0.5B | 45.9 | 2.92 | 3.16 |
| Heron-NVILA-Lite-2B | 1.5B | 52.8 | 3.52 | 3.50 |
| Heron-NVILA-Lite-15B | 14B | 59.6 | 4.2 | 3.82 |
| LLaVA-CALM2-SigLIP | 7B | 43.3 | 3.15 | 3.21 |
| Llama-3-EvoVLM-JP-v2 | 8B | 39.3 | 2.92 | 2.96 |
| VILA-jp | 13B | 57.2 | 3.69 | 3.62 |
| Asagi-14B | 13B | 55.8 | 3.44 | 3.84 |
| Sarashina2-Vision-14B | 13B | 50.9 | 4.1 | 3.43 |
| Qwen2-VL 7B Instruct | 7B | 55.5 | 3.61 | 3.6 |
| GPT-4o | - | 87.6 | 3.85 | 3.58 |