模型简介
模型特点
模型能力
使用案例
🚀 LLM - jp - 3 VILA 14B
本仓库提供了一个由日本国立情报学研究所的大语言模型研发中心开发的大型视觉语言模型(VLM)。该模型能够处理图像和文本信息,为图像理解和文本生成等任务提供支持。
🚀 快速开始
环境要求
Python 版本:3.10.12
安装步骤
-
克隆仓库并安装依赖库。
```bash git clone git@github.com:llm-jp/llm-jp-VILA.git cd llm-jp-VILA ``` ```bash python3 -m venv venv source venv/bin/activate ``` ```bash pip install --upgrade pip wget https://github.com/Dao-AILab/flash-attention/releases/download/v2.4.2/flash_attn-2.4.2+cu118torch2.0cxx11abiFALSE-cp310-cp310-linux_x86_64.whl pip install flash_attn-2.4.2+cu118torch2.0cxx11abiFALSE-cp310-cp310-linux_x86_64.whl pip install -e . pip install -e ".[train]" ``` ```bash pip install git+https://github.com/huggingface/transformers@v4.36.2 cp -rv ./llava/train/transformers_replace/* ./venv/lib/python3.10/site-packages/transformers/ ``` -
运行 Python 脚本。你可以将
image_path
和query
替换为你自己的内容。```python import argparse from io import BytesIOimport requests import torch from PIL import Image
from llava.constants import IMAGE_TOKEN_INDEX from llava.conversation import conv_templates from llava.mm_utils import (get_model_name_from_path, process_images, tokenizer_image_token) from llava.model.builder import load_pretrained_model from llava.utils import disable_torch_init
def load_image(image_file): if image_file.startswith("http") or image_file.startswith("https"): response = requests.get(image_file) image = Image.open(BytesIO(response.content)).convert("RGB") else: image = Image.open(image_file).convert("RGB") return image
def load_images(image_files): out = [] for image_file in image_files: image = load_image(image_file) out.append(image) return out
disable_torch_init()
model_checkpoint_path = "llm-jp/llm-jp-3-vila-14b" model_name = get_model_name_from_path(model_checkpoint_path) tokenizer, model, image_processor, context_len = load_pretrained_model(model_checkpoint_path, model_name)
image_path = "path/to/image" image_files = [ image_path ] images = load_images(image_files)
query = "
\nこの画像について説明してください。" conv_mode = "llmjp_v3" conv = conv_templates[conv_mode].copy() conv.append_message(conv.roles[0], query) conv.append_message(conv.roles[1], None) prompt = conv.get_prompt()
images_tensor = process_images(images, image_processor, model.config).to(model.device, dtype=torch.float16) input_ids = tokenizer_image_token(prompt, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).cuda()
with torch.inference_mode(): output_ids = model.generate( input_ids, images=[ images_tensor, ], do_sample=False, num_beams=1, max_new_tokens=256, use_cache=True, )
outputs = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0] print(outputs)
</details>
✨ 主要特性
模型架构
属性 | 详情 |
---|---|
模型类型 | 大型视觉语言模型(VLM) |
视觉编码器 | siglip - so400m - patch14 - 384,参数数量 428M |
投影器 | 2 层 MLP,参数数量 32M |
大语言模型 | llm - jp - 3 - 13b - instruct,参数数量 13B |
训练数据
模型分三个阶段进行训练:
阶段 0
用于调整投影器参数的数据集:
语言 | 数据集 | 图像数量 |
---|---|---|
日语 | Japanese image text pairs | 558K |
英语 | LLaVA - Pretrain | 558K |
阶段 1
用于调整投影器和大语言模型参数的数据集:
语言 | 数据集 | 图像数量 |
---|---|---|
日语 | Japanese image text pairs | 6M |
日语 | Japanese interleaved data | 6M |
英语 | coyo(子集) | 6M |
英语 | mmc4 - core(子集) | 6M |
阶段 2
用于调整投影器和大语言模型参数的数据集:
语言 | 数据集 | 图像数量 |
---|---|---|
日语 | llava - instruct - ja | 156K |
日语 | japanese - photos - conv | 12K |
日语 | ja - vg - vqa | 99K |
日语 | synthdog - ja(子集) | 102K |
英语 | LLaVA | 158K |
英语 | VQAv2 | 53K |
英语 | GQA | 46K |
英语 | OCRVQA | 80K |
英语 | TextVQA | 22K |
评估结果
使用 Heron Bench、JA - VLM - Bench - In - the - Wild 和 JA - VG - VQA500 对模型进行评估,使用 gpt - 4o - 2024 - 05 - 13
作为大语言模型评判器。
Heron Bench
模型 | 大语言模型评判得分(%) |
---|---|
Japanese InstructBLIP Alpha | 14.0 |
Japanese Stable VLM | 24.2 |
Llama - 3 - EvoVLM - JP - v2 | 39.3 |
LLaVA - CALM2 - SigLIP | 43.3 |
llm - jp - 3 - vila - 14b(本模型) | 57.2 |
GPT - 4o | 87.6 |
JA - VLM - Bench - In - the - Wild
模型 | ROUGE - L | 大语言模型评判得分(/5.0) |
---|---|---|
Japanese InstructBLIP Alpha | 20.8 | 2.42 |
Japanese Stable VLM | 23.3 | 2.47 |
Llama - 3 - EvoVLM - JP - v2 | 41.4 | 2.92 |
LLaVA - CALM2 - SigLIP | 47.2 | 3.15 |
llm - jp - 3 - vila - 14b(本模型) | 52.3 | 3.69 |
GPT - 4o | 37.6 | 3.85 |
JA - VG - VQA500
模型 | ROUGE - L | 大语言模型评判得分(/5.0) |
---|---|---|
Japanese InstructBLIP Alpha | -- | -- |
Japanese Stable VLM | -- | -- |
Llama - 3 - EvoVLM - JP - v2 | 23.5 | 2.96 |
LLaVA - CALM2 - SigLIP | 17.4 | 3.21 |
llm - jp - 3 - vila - 14b(本模型) | 16.2 | 3.62 |
GPT - 4o | 12.1 | 3.58 |
🔧 技术细节
本模型处于研发的早期阶段,其输出尚未完全符合社会规范、道德标准和法律法规。在使用时,需要注意模型可能存在的风险和局限性。
📄 许可证
本模型的权重遵循 Apache 许可证 2.0 版 发布。此外,由于模型使用了由 OpenAI GPT - 4 生成的合成数据,模型使用者必须遵守 OpenAI 使用条款。
额外说明
关于 synthdog - ja 数据集的许可证,数据集中没有明确的许可声明。我们曾尝试联系 “OCR - free Document Understanding Transformer” 的主要通讯作者进行澄清,但未收到回复。
基于以下考虑:
- 在该数据集上训练的 donut - base 模型遵循 MIT 许可证发布。
- 数据集中使用的维基百科文章遵循 CC - BY - SA 许可证。
我们认为 synthdog - ja 数据集很可能遵循 CC - BY - SA 许可证,并在此假设下进行了训练。








