Chemvlm 26B
ChemVLMは化学分野に特化したマルチモーダル大規模言語モデルで、テキストと画像処理能力を統合しています。
ダウンロード数 53
リリース時間 : 6/6/2024
モデル概要
ChemVLMはChemLLM-20BとInterViT-6Bをファインチューニングしたマルチモーダル大規模言語モデルで、化学分野のマルチモーダル能力を探求し、画像テキストからテキストへのタスクをサポートします。
モデル特徴
マルチモーダル能力
テキストと画像処理能力を統合し、化学分野のマルチモーダルタスクに適しています。
化学分野専用
化学分野に最適化されており、化学関連のテキストや画像コンテンツを理解・生成できます。
大規模モデル
ChemLLM-20BとInterViT-6Bを基にした大規模モデルで、強力な推論・生成能力を備えています。
モデル能力
化学テキスト生成
化学画像分析
マルチモーダル推論
化学知識QA
使用事例
化学研究
化学文献分析
化学文献中のテキストと画像を分析し、キー情報を抽出します。
文献読解効率を向上させ、重要な化学情報を迅速に取得できます。
化学実験レポート生成
実験画像とデータに基づいて詳細な実験レポートを生成します。
実験レポート作成を自動化し、研究者の負担を軽減します。
教育
化学教育支援
化学教材や練習問題を生成し、教師と学生を支援します。
教育効率を向上させ、学生の学習体験を強化します。
🚀 ChemVLM-26B
化学分野におけるマルチモーダル大規模言語モデルの力を探索するモデルです。画像とテキストを入力として、化学関連の情報を生成します。
🚀 クイックスタート
このセクションでは、ChemVLM-26Bの使用方法や関連情報について説明します。
引用情報
論文の引用情報は以下の通りです。 arxiv.org/abs/2408.07246
@inproceedings{li2025chemvlm,
title={Chemvlm: Exploring the power of multimodal large language models in chemistry area},
author={Li, Junxian and Zhang, Di and Wang, Xunzhi and Hao, Zeying and Lei, Jingdi and Tan, Qian and Zhou, Cai and Liu, Wei and Yang, Yaotian and Xiong, Xinrui and others},
booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
volume={39},
number={1},
pages={415--423},
year={2025}
}
更新情報
データセットや学習・評価のコードは、こちらのGitHubリポジトリで公開されています。また、ChemLLM-20BとInterViT-6Bをベースにファインチューニングされています。
モデルの使用方法
transformers
を使用してChemVLM-26Bを実行するサンプルコードを提供しています。また、オンラインデモを利用して、すぐにモデルを体験することもできます。
⚠️ 重要提示
モデルを正常に動作させるためには、
transformers==4.37.2
を使用してください。
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModel
import torch
import torchvision.transforms as T
from PIL import Image
from torchvision.transforms.functional import InterpolationMode
IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)
def build_transform(input_size):
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
transform = T.Compose([
T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
T.ToTensor(),
T.Normalize(mean=MEAN, std=STD)
])
return transform
def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
best_ratio_diff = float('inf')
best_ratio = (1, 1)
area = width * height
for ratio in target_ratios:
target_aspect_ratio = ratio[0] / ratio[1]
ratio_diff = abs(aspect_ratio - target_aspect_ratio)
if ratio_diff < best_ratio_diff:
best_ratio_diff = ratio_diff
best_ratio = ratio
elif ratio_diff == best_ratio_diff:
if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
best_ratio = ratio
return best_ratio
def dynamic_preprocess(image, min_num=1, max_num=6, image_size=448, use_thumbnail=False):
orig_width, orig_height = image.size
aspect_ratio = orig_width / orig_height
# calculate the existing image aspect ratio
target_ratios = set(
(i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
i * j <= max_num and i * j >= min_num)
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
# find the closest aspect ratio to the target
target_aspect_ratio = find_closest_aspect_ratio(
aspect_ratio, target_ratios, orig_width, orig_height, image_size)
# calculate the target width and height
target_width = image_size * target_aspect_ratio[0]
target_height = image_size * target_aspect_ratio[1]
blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
# resize the image
resized_img = image.resize((target_width, target_height))
processed_images = []
for i in range(blocks):
box = (
(i % (target_width // image_size)) * image_size,
(i // (target_width // image_size)) * image_size,
((i % (target_width // image_size)) + 1) * image_size,
((i // (target_width // image_size)) + 1) * image_size
)
# split the image
split_img = resized_img.crop(box)
processed_images.append(split_img)
assert len(processed_images) == blocks
if use_thumbnail and len(processed_images) != 1:
thumbnail_img = image.resize((image_size, image_size))
processed_images.append(thumbnail_img)
return processed_images
def load_image(image_file, input_size=448, max_num=6):
image = Image.open(image_file).convert('RGB')
transform = build_transform(input_size=input_size)
images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
pixel_values = [transform(image) for image in images]
pixel_values = torch.stack(pixel_values)
return pixel_values
path = "AI4Chem/ChemVLM-26B"
# If you have an 80G A100 GPU, you can put the entire model on a single GPU.
model = AutoModel.from_pretrained(
path,
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=True,
trust_remote_code=True).eval().cuda()
# Otherwise, you need to set device_map='auto' to use multiple GPUs for inference.
# import os
# os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
# model = AutoModel.from_pretrained(
# path,
# torch_dtype=torch.bfloat16,
# low_cpu_mem_usage=True,
# trust_remote_code=True,
# device_map='auto').eval()
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
# set the max number of tiles in `max_num`
pixel_values = load_image('./examples/image1.jpg', max_num=6).to(torch.bfloat16).cuda()
generation_config = dict(
num_beams=1,
max_new_tokens=512,
do_sample=False,
)
# single-round single-image conversation
question = "请详细描述图片" # Please describe the picture in detail
response = model.chat(tokenizer, pixel_values, question, generation_config)
print(question, response)
# multi-round single-image conversation
question = "请详细描述图片" # Please describe the picture in detail
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
print(question, response)
question = "请根据图片写一首诗" # Please write a poem according to the picture
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
print(question, response)
# multi-round multi-image conversation
pixel_values1 = load_image('./examples/image1.jpg', max_num=6).to(torch.bfloat16).cuda()
pixel_values2 = load_image('./examples/image2.jpg', max_num=6).to(torch.bfloat16).cuda()
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
question = "详细描述这两张图片" # Describe the two pictures in detail
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
print(question, response)
question = "这两张图片的相同点和区别分别是什么" # What are the similarities and differences between these two pictures
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
print(question, response)
# batch inference (single image per sample)
pixel_values1 = load_image('./examples/image1.jpg', max_num=6).to(torch.bfloat16).cuda()
pixel_values2 = load_image('./examples/image2.jpg', max_num=6).to(torch.bfloat16).cuda()
image_counts = [pixel_values1.size(0), pixel_values2.size(0)]
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
questions = ["Describe the image in detail."] * len(image_counts)
responses = model.batch_chat(tokenizer, pixel_values,
image_counts=image_counts,
questions=questions,
generation_config=generation_config)
for question, response in zip(questions, responses):
print(question)
print(response)
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。
謝辞
ChemVLMはInternVLをベースに構築されています。InternVLは以下のプロジェクトのコードを参考に構築されています。これらの素晴らしい成果に感謝します。
Clip Vit Large Patch14
CLIPはOpenAIによって開発された視覚-言語モデルで、コントラスティブラーニングを通じて画像とテキストを共有の埋め込み空間にマッピングし、ゼロショット画像分類をサポートします
画像生成テキスト
C
openai
44.7M
1,710
Clip Vit Base Patch32
CLIPはOpenAIが開発したマルチモーダルモデルで、画像とテキストの関係を理解し、ゼロショット画像分類タスクをサポートします。
画像生成テキスト
C
openai
14.0M
666
Siglip So400m Patch14 384
Apache-2.0
SigLIPはWebLiデータセットで事前学習された視覚言語モデルで、改良されたシグモイド損失関数を採用し、画像-テキストマッチングタスクを最適化しています。
画像生成テキスト
Transformers

S
google
6.1M
526
Clip Vit Base Patch16
CLIPはOpenAIが開発したマルチモーダルモデルで、コントラスティブラーニングにより画像とテキストを共有の埋め込み空間にマッピングし、ゼロショット画像分類能力を実現します。
画像生成テキスト
C
openai
4.6M
119
Blip Image Captioning Base
Bsd-3-clause
BLIPは先進的な視覚-言語事前学習モデルで、画像キャプション生成タスクに優れており、条件付きおよび無条件のテキスト生成をサポートします。
画像生成テキスト
Transformers

B
Salesforce
2.8M
688
Blip Image Captioning Large
Bsd-3-clause
BLIPは統一された視覚-言語事前学習フレームワークで、画像キャプション生成タスクに優れており、条件付きおよび無条件の画像キャプション生成をサポートします。
画像生成テキスト
Transformers

B
Salesforce
2.5M
1,312
Openvla 7b
MIT
OpenVLA 7BはOpen X-Embodimentデータセットでトレーニングされたオープンソースの視覚-言語-動作モデルで、言語命令とカメラ画像に基づいてロボットの動作を生成できます。
画像生成テキスト
Transformers 英語

O
openvla
1.7M
108
Llava V1.5 7b
LLaVAはオープンソースのマルチモーダルチャットボットで、LLaMA/Vicunaをファインチューニングし、画像とテキストのインタラクションをサポートします。
画像生成テキスト
Transformers

L
liuhaotian
1.4M
448
Vit Gpt2 Image Captioning
Apache-2.0
これはViTとGPT2アーキテクチャに基づく画像記述生成モデルで、入力画像に対して自然言語の記述を生成することができます。
画像生成テキスト
Transformers

V
nlpconnect
939.88k
887
Blip2 Opt 2.7b
MIT
BLIP-2は画像エンコーダーと大規模言語モデルを組み合わせた視覚言語モデルで、画像からテキストを生成するタスクに使用されます。
画像生成テキスト
Transformers 英語

B
Salesforce
867.78k
359
おすすめAIモデル
Llama 3 Typhoon V1.5x 8b Instruct
タイ語専用に設計された80億パラメータの命令モデルで、GPT-3.5-turboに匹敵する性能を持ち、アプリケーションシナリオ、検索拡張生成、制限付き生成、推論タスクを最適化
大規模言語モデル
Transformers 複数言語対応

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-TinyはSODAデータセットでトレーニングされた超小型対話モデルで、エッジデバイス推論向けに設計されており、体積はCosmo-3Bモデルの約2%です。
対話システム
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
RoBERTaアーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム 中国語
R
uer
2,694
98