mlx-vlm
Apple Silicon Mac上で、画像とテキストを入力して応答を得るVLM(Vision Language Model)の推論や、モデルの微調整、画像の一括処理などをローカル環境で実行できるため、クラウドAPIとの比較検証にも活用できるSkill。
📜 元の英語説明(参考)
Run Vision Language Models locally on Apple Silicon Macs using MLX. Use when: installing mlx-vlm, running VLM inference (image + text → response), fine-tuning vision models on custom datasets, batch processing images with local AI, comparing local VLM to cloud APIs (GPT-4V, Claude Vision), or working with LLaVA, Phi-3-Vision, Qwen2-VL, Pixtral, Llama-3.2-Vision on Mac.
🇯🇵 日本人クリエイター向け解説
Apple Silicon Mac上で、画像とテキストを入力して応答を得るVLM(Vision Language Model)の推論や、モデルの微調整、画像の一括処理などをローカル環境で実行できるため、クラウドAPIとの比較検証にも活用できるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o mlx-vlm.zip https://jpskill.com/download/15134.zip && unzip -o mlx-vlm.zip && rm mlx-vlm.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15134.zip -OutFile "$d\mlx-vlm.zip"; Expand-Archive "$d\mlx-vlm.zip" -DestinationPath $d -Force; ri "$d\mlx-vlm.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
mlx-vlm.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
mlx-vlmフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
MLX-VLM — Apple Silicon 上の Vision Language Models
概要
mlx-vlm は、MLX フレームワークを使用して、Apple Silicon 上でネイティブに vision-language モデルを実行します。統合メモリによる推論とファインチューニングをサポートしており、GPU サーバーは不要です。
リポジトリ: Blaizzy/mlx-vlm
要件: macOS 14 以降、Apple Silicon (M1/M2/M3/M4)、Python 3.10 以降
インストール
# 仮想環境の作成 (推奨)
python3 -m venv ~/.venvs/mlx-vlm
source ~/.venvs/mlx-vlm/bin/activate
# インストール
pip install mlx-vlm
開発用:
git clone https://github.com/Blaizzy/mlx-vlm.git
cd mlx-vlm && pip install -e .
サポートされているモデル
| モデル | HuggingFace ID | 最適な用途 |
|---|---|---|
| Pixtral | mistral-community/pixtral-12b-240910 |
一般的なビジョン、マルチイメージ |
| Qwen2-VL | Qwen/Qwen2-VL-7B-Instruct |
OCR、ドキュメント理解 |
| Phi-3-Vision | microsoft/Phi-3.5-vision-instruct |
軽量、高速推論 |
| LLaVA-1.6 | llava-hf/llava-v1.6-mistral-7b-hf |
画像に関する会話 |
| Llama-3.2-Vision | meta-llama/Llama-3.2-11B-Vision-Instruct |
強力な一般的な推論 |
推論
CLI
# 単一画像分析
python -m mlx_vlm.generate \
--model mlx-community/pixtral-12b-240910-4bit \
--image path/to/image.jpg \
--prompt "Describe this image in detail" \
--max-tokens 512
# 複数画像比較
python -m mlx_vlm.generate \
--model mlx-community/pixtral-12b-240910-4bit \
--image img1.jpg img2.jpg \
--prompt "Compare these two images"
Python API
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model_path = "mlx-community/pixtral-12b-240910-4bit"
model, processor = load(model_path)
prompt = apply_chat_template(
processor,
config=model.config,
prompt="What objects are in this image?",
images=["product.jpg"],
)
output = generate(
model, processor, prompt,
images=["product.jpg"],
max_tokens=512,
temperature=0.7,
)
print(output)
バッチ処理
import os, csv
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model, processor = load("mlx-community/pixtral-12b-240910-4bit")
image_dir = "images/"
results = []
for filename in os.listdir(image_dir):
if not filename.lower().endswith((".jpg", ".png", ".webp")):
continue
path = os.path.join(image_dir, filename)
prompt = apply_chat_template(
processor, config=model.config,
prompt="Describe this product photo. Include: category, color, condition, key features.",
images=[path],
)
desc = generate(model, processor, prompt, images=[path], max_tokens=256)
results.append({"file": filename, "description": desc})
with open("descriptions.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=["file", "description"])
writer.writeheader()
writer.writerows(results)
ファインチューニング
データセットの準備
画像パスと会話を含む JSONL を作成します。
{"image": "train/001.jpg", "conversations": [{"role": "user", "content": "Classify this product"}, {"role": "assistant", "content": "Category: Electronics, Subcategory: Headphones, Condition: New"}]}
{"image": "train/002.jpg", "conversations": [{"role": "user", "content": "Classify this product"}, {"role": "assistant", "content": "Category: Clothing, Subcategory: T-Shirt, Condition: Used - Good"}]}
ファインチューニングの実行 (LoRA)
python -m mlx_vlm.lora \
--model mlx-community/pixtral-12b-240910-4bit \
--data ./dataset \
--train-file train.jsonl \
--valid-file val.jsonl \
--num-layers 8 \
--batch-size 1 \
--epochs 3 \
--lr 1e-5 \
--adapter-path ./adapters
ファインチューニングされたアダプターによる推論
python -m mlx_vlm.generate \
--model mlx-community/pixtral-12b-240910-4bit \
--adapter-path ./adapters \
--image test.jpg \
--prompt "Classify this product"
クラウド API の比較
| 因子 | mlx-vlm (ローカル) | クラウド API (GPT-4V, Claude) |
|---|---|---|
| コスト | ハードウェア購入後は $0 | 画像 1 枚あたり $0.01-$0.04 |
| プライバシー | データはローカルに保持 | データはプロバイダーに送信 |
| 速度 | 画像 1 枚あたり約 2-8 秒 (M3 Max) | 画像 1 枚あたり約 1-3 秒 |
| オフライン | はい | いいえ |
| カスタムモデル | LoRA ファインチューニング | 限定的 / 高価 |
| 品質 | 良好 (7-12B モデル) | 非常に優れている (最先端モデル) |
パフォーマンスのヒント
- 4 ビット量子化モデル (名前の中に
4bitが含まれるもの) を使用すると、品質の低下を最小限に抑えながら、速度が 2 ~ 3 倍向上します。 - 36GB 以上の RAM を搭載した M3 Max / M4 Pro は、12B モデルを快適に実行できます。
- 16GB の M1/M2 の場合は、7B 4 ビットモデルを使用してください。
- 最初の実行時に
MLX_METAL_JIT=1を設定すると、速度が向上する可能性があります。 - 推論を実行する前に、メモリを大量に消費するアプリを閉じてください。統合メモリはシステムと共有されます。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
MLX-VLM — Vision Language Models on Apple Silicon
Overview
mlx-vlm runs vision-language models natively on Apple Silicon using the MLX framework. It supports inference and fine-tuning with unified memory — no GPU server needed.
Repo: Blaizzy/mlx-vlm
Requirements: macOS 14+, Apple Silicon (M1/M2/M3/M4), Python 3.10+
Installation
# Create virtual environment (recommended)
python3 -m venv ~/.venvs/mlx-vlm
source ~/.venvs/mlx-vlm/bin/activate
# Install
pip install mlx-vlm
For development:
git clone https://github.com/Blaizzy/mlx-vlm.git
cd mlx-vlm && pip install -e .
Supported Models
| Model | HuggingFace ID | Best For |
|---|---|---|
| Pixtral | mistral-community/pixtral-12b-240910 |
General vision, multi-image |
| Qwen2-VL | Qwen/Qwen2-VL-7B-Instruct |
OCR, document understanding |
| Phi-3-Vision | microsoft/Phi-3.5-vision-instruct |
Lightweight, fast inference |
| LLaVA-1.6 | llava-hf/llava-v1.6-mistral-7b-hf |
Conversation about images |
| Llama-3.2-Vision | meta-llama/Llama-3.2-11B-Vision-Instruct |
Strong general reasoning |
Inference
CLI
# Single image analysis
python -m mlx_vlm.generate \
--model mlx-community/pixtral-12b-240910-4bit \
--image path/to/image.jpg \
--prompt "Describe this image in detail" \
--max-tokens 512
# Multi-image comparison
python -m mlx_vlm.generate \
--model mlx-community/pixtral-12b-240910-4bit \
--image img1.jpg img2.jpg \
--prompt "Compare these two images"
Python API
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model_path = "mlx-community/pixtral-12b-240910-4bit"
model, processor = load(model_path)
prompt = apply_chat_template(
processor,
config=model.config,
prompt="What objects are in this image?",
images=["product.jpg"],
)
output = generate(
model, processor, prompt,
images=["product.jpg"],
max_tokens=512,
temperature=0.7,
)
print(output)
Batch Processing
import os, csv
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model, processor = load("mlx-community/pixtral-12b-240910-4bit")
image_dir = "images/"
results = []
for filename in os.listdir(image_dir):
if not filename.lower().endswith((".jpg", ".png", ".webp")):
continue
path = os.path.join(image_dir, filename)
prompt = apply_chat_template(
processor, config=model.config,
prompt="Describe this product photo. Include: category, color, condition, key features.",
images=[path],
)
desc = generate(model, processor, prompt, images=[path], max_tokens=256)
results.append({"file": filename, "description": desc})
with open("descriptions.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=["file", "description"])
writer.writeheader()
writer.writerows(results)
Fine-Tuning
Prepare Dataset
Create JSONL with image paths and conversations:
{"image": "train/001.jpg", "conversations": [{"role": "user", "content": "Classify this product"}, {"role": "assistant", "content": "Category: Electronics, Subcategory: Headphones, Condition: New"}]}
{"image": "train/002.jpg", "conversations": [{"role": "user", "content": "Classify this product"}, {"role": "assistant", "content": "Category: Clothing, Subcategory: T-Shirt, Condition: Used - Good"}]}
Run Fine-Tuning (LoRA)
python -m mlx_vlm.lora \
--model mlx-community/pixtral-12b-240910-4bit \
--data ./dataset \
--train-file train.jsonl \
--valid-file val.jsonl \
--num-layers 8 \
--batch-size 1 \
--epochs 3 \
--lr 1e-5 \
--adapter-path ./adapters
Inference with Fine-Tuned Adapter
python -m mlx_vlm.generate \
--model mlx-community/pixtral-12b-240910-4bit \
--adapter-path ./adapters \
--image test.jpg \
--prompt "Classify this product"
Cloud API Comparison
| Factor | mlx-vlm (Local) | Cloud APIs (GPT-4V, Claude) |
|---|---|---|
| Cost | $0 after hardware | $0.01-0.04 per image |
| Privacy | Data stays local | Data sent to provider |
| Speed | ~2-8s per image (M3 Max) | ~1-3s per image |
| Offline | Yes | No |
| Custom models | LoRA fine-tuning | Limited / expensive |
| Quality | Good (7-12B models) | Excellent (frontier models) |
Performance Tips
- Use 4-bit quantized models (
4bitin name) for 2-3x speedup with minimal quality loss - M3 Max / M4 Pro with 36GB+ RAM can run 12B models comfortably
- For M1/M2 with 16GB, stick to 7B 4-bit models
- Set
MLX_METAL_JIT=1for potential speedup on first run - Close memory-heavy apps before inference — unified memory is shared with system