Views
No views yet
uv add "torch==2.8.0" "transformers==4.57.0" "flash-attn==2.8.3" "pillow==11.3.0"1import torch
2from transformers import AutoProcessor, AutoModel
3
4model_id = "llm-jp/Jagle-VL-2.2B-Jagle-FineVision"
5
6# load model
7model = (
8 AutoModel.from_pretrained(
9 model_id,
10 torch_dtype=torch.bfloat16,
11 trust_remote_code=True,
12 use_flash_attn=True,
13 )
14 .eval()
15 .cuda()
16)
17
18processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
19
20
21def generate(messages, max_new_tokens=256, temperature=0.0):
22 inputs = processor.apply_chat_template(
23 messages,
24 tokenize=True,
25 add_generation_prompt=True,
26 return_dict=True,
27 return_tensors="pt",
28 ).to(model.device)
29
30 if "pixel_values" in inputs:
31 inputs["pixel_values"] = inputs["pixel_values"].to(dtype=model.dtype)
32
33 outputs = model.generate(
34 **inputs,
35 max_new_tokens=max_new_tokens,
36 do_sample=temperature > 0,
37 temperature=temperature if temperature > 0 else None,
38 )
39
40 text = processor.decode(outputs[0], skip_special_tokens=False)
41 text = text.replace("<|channel|>final<|message|>", "")
42 text = text.replace("<|return|>", "")
43 text = text.replace(processor.tokenizer.eos_token, "")
44 return text.strip()
45
46
47# -----------------------
48# 1. Text-only
49# -----------------------
50messages = [
51 {
52 "role": "user",
53 "content": [{"type": "text", "text": "富士山について簡潔に説明してください。"}],
54 }
55]
56print(generate(messages))
57# 富士山は、日本最高峰の山で、標高3,776メートルです。静岡県と山梨県にまたがっており、世界遺産にも登録されています。
58
59# -----------------------
60# 2. Single image
61# -----------------------
62messages = [
63 {
64 "role": "user",
65 "content": [
66 {"type": "image", "image": "assets/kaonashi.jpg"},
67 {"type": "text", "text": "このキャラクターの名前は何ですか?"},
68 ],
69 }
70]
71print(generate(messages))
72# カオナシ
73
74# -----------------------
75# 3. Multi-image
76# -----------------------
77messages = [
78 {
79 "role": "user",
80 "content": [
81 {"type": "image", "image": "assets/Shiba_inu.jpg"},
82 {"type": "image", "image": "assets/yesoensis.jpg"},
83 {"type": "text", "text": "それぞれの動物の名前を教えてください。"},
84 ],
85 }
86]
87print(generate(messages))
88# 柴犬と鹿です。
89
90# -----------------------
91# 4. Multi-turn example
92# -----------------------
93messages = [
94 {
95 "role": "user",
96 "content": [
97 {"type": "image", "image": "assets/kaonashi.jpg"},
98 {
99 "type": "text",
100 "text": "このキャラクターが登場する映画のタイトルは何ですか?",
101 },
102 ],
103 },
104 {
105 "role": "assistant",
106 "content": [{"type": "text", "text": "千と千尋の神隠し"}],
107 },
108 {
109 "role": "user",
110 "content": [{"type": "text", "text": "監督は誰ですか?"}],
111 },
112]
113
114print(generate(messages))
115# 宮崎駿1@misc{sugiura2026jaglebuildinglargescalejapanese,
2 title={Jagle: Building a Large-Scale Japanese Multimodal Post-Training Dataset for Vision-Language Models},
3 author={Issa Sugiura and Keito Sasagawa and Keisuke Nakao and Koki Maeda and Ziqi Yin and Zhishen Yang and Shuhei Kurita and Yusuke Oda and Ryoko Tokuhisa and Daisuke Kawahara and Naoaki Okazaki},
4 year={2026},
5 eprint={2604.02048},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2604.02048},
9}