Downloads · 30 days
36
17% of all-time downloads
tokimoa/plamo-2.1-2b-vl-mlx-8bit
plamo-2.1-2b-vl-mlx-8bit is a image-text-to-text model from tokimoa. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for mlx. The card lists the license as other.
Preferred Networksの PLaMo 2.1-2B-VL(Mamba×Attentionハイブリッドplamo2 LM+SigLIP so400mの日英VLM)をMLX 8bit(group size 64、実効9.58bpw)に量子化したものです。
Downloads · 30 days
36
17% of all-time downloads
All-time downloads
206
Public
Parameters
2.9B
3.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.4 GB · 100%
How the weights are stored.
U322.5B · 86%
From the Hugging Face model README
Preferred Networksの PLaMo 2.1-2B-VL(Mamba×Attentionハイブリッドplamo2 LM+SigLIP so400mの日英VLM)をMLX 8bit(group size 64、実効9.58bpw)に量子化したものです。
当方で移植したMLX実装は**mlx-vlm本体にマージ済み(0.6.8で標準対応)**です(plamo2vl/ディレクトリ)。mlx-vlm 0.6.8以降ではそのまま使えます。
3版のうち品質・速度バランスの良いこの8bit版を推奨します。写真・画像説明の検証セットでbf16版と出力完全一致、約84 tok/s・ピークメモリ6.9GBで、8GBメモリのMacでも動く軽さです。
このrepoは上流のtrust_remote_codeをtransformers 5対応に再構成済みです(上流はtransformers<5専用。standalone configへの差し替え・torch用modelingの除去)。mlx-vlm 0.6.7(transformers 5系)でそのまま動きます。
mlx-vlm 0.6.8以降なら追加手順は不要です(この移植実装は#1739で本体にマージされ、0.6.8に収録されました。0.6.8での動作を実測確認済み):
pip install mlx-vlm numba torch torchvision
<details><summary>0.6.7以前を使う場合(旧手順)</summary>
repo同梱のplamo2vl/をmlx_vlm/models/へコピーしてください(詳細は旧版カード参照)。
このモデルはチャットテンプレートではなく、processorが日本語Alpaca型(### 指示:/### 応答:)のプロンプトを内部で組み立てます。processor(images=画像, text=質問)だけで正しい形式になります。
import mlx.core as mx
import torch
from PIL import Image
from transformers import AutoProcessor
from mlx_vlm import load
repo = "tokimoa/plamo-2.1-2b-vl-mlx-8bit"
model, _ = load(repo, trust_remote_code=True)
processor = AutoProcessor.from_pretrained(repo, trust_remote_code=True)
inputs = processor(images=Image.open("photo.png"), text="この画像に写っているものを説明してください。")
input_ids = mx.array(inputs["input_ids"].numpy())
pixel_values = mx.array(inputs["pixel_values"].to(dtype=torch.float32).numpy())
cache = model.make_cache()
logits = model(input_ids, pixel_values, mask=None, cache=cache).logits
y = mx.argmax(logits[:, -1, :], axis=-1)
tokens = []
for _ in range(256):
t = int(y[0])
tokens.append(t)
if t == 1: # <|plamo:eos|>
break
logits = model(y[None], None, mask=None, cache=cache).logits
y = mx.argmax(logits[:, -1, :], axis=-1)
print(processor.tokenizer.decode(tokens, skip_special_tokens=True))
同梱のMLX実装は、bf16変換版でtransformers公式実装(bf16・MPS)との突き合わせ検証を実施済みです:
この8bit版の検証:
用途上の注意: 2Bクラスのため、高密度なビジネス文書の細かい数値読み取りは苦手です(transformers公式実装でも同様に誤読することを確認済み=変換起因ではありません)。写真・図の説明、簡単な画像質問など軽量VL用途に向いています。文書読解が必要な場合は llm-jp-4-vl-9b-beta MLX や Stockmark-DocReasoner MLX を推奨します。
pfnet/plamo-2.1-2b-vl(公式BF16、commit 3d32366)plamo2実装をベースに移植したplamo2vlパッケージ(このrepoに同梱。RoPE base=1e6のplamo-2.1系対応を含む)mlx-vlm 0.6.7 convert -q --q-bits 8(group size 64 affine、実効9.58bpw)PLaMoコミュニティライセンス(全文を同梱のLICENSE.mdに収録。本モデルの利用はその条件に従います):