convert-quantize
できること
このスキルは、Hugging FaceのAIモデルをMLX形式に変換し、必要に応じて小さくする方法をエージェントに教えます。Apple製品でモデルを動かしたい人向けです。
使う場面
- ✓Hugging FaceのモデルをMacで使うため、MLXの版に変換したいとき。
- ✓モデルの4ビットや8ビットの小さい版がほしいとき。
- ✓変換や量子化のコマンドが失敗し、直す必要があるとき。
スキルのリンク
https://github.com/Blaizzy/mlx-vlm/blob/main/skills/skills/convert-quantize/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このHugging FaceのモデルをMLXに変換し、私のMacに収まる4ビットの版を作ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、元のモデルとモデルのファミリーを確認し、選んだビット数、グループのサイズ、モードで変換のコマンドを実行します。フラグは変わることがあるので、先にヘルプの出力を確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Convert & Quantize
Use this workflow for mlx_vlm.convert — turning a Hugging Face checkpoint into MLX format, optionally quantizing it.
First Checks
- Confirm the source: a Hugging Face repo id or a local path (
--hf-path, alias--model). - Confirm the model family is supported in
mlx_vlm/models/(a folder named after theconfig.jsonmodel_type). If not, this is a porting task — switch toSkill("mlx-vlm-skills:add-new-model"). - Verify current flags before finalizing:
uv run mlx_vlm.convert --help. - Entry point is
mlx_vlm.convert.python -m mlx_vlm.convertis deprecated; useuv run mlx_vlm.convert ...orpython -m mlx_vlm convert ....
Command Patterns
Plain convert (no quantization), saves to ./mlx_model by default:
uv run mlx_vlm.convert --hf-path <repo-or-path> --mlx-path ./out-mlx
4-bit affine quantization (RTN, the default method):
uv run mlx_vlm.convert --hf-path <repo-or-path> --mlx-path ./out-4bit -q --q-bits 4 --q-group-size 64
Other quant modes (--q-mode sets its own bit/group defaults):
# mxfp4 (group 32, 4 bit), nvfp4 (group 16, 4 bit), mxfp8 (group 32, 8 bit)
uv run mlx_vlm.convert --hf-path <repo-or-path> --mlx-path ./out-mxfp4 -q --q-mode mxfp4
Mixed-bit recipe (per-layer bit allocation, llama.cpp-style):
# recipes: mixed_2_6 mixed_3_4 mixed_3_5 mixed_3_6 mixed_3_8 mixed_4_6 mixed_4_8
uv run mlx_vlm.convert --hf-path <repo-or-path> --mlx-path ./out-mixed -q --quant-predicate mixed_3_6
AWQ (activation-aware, needs a calibration pass):
uv run mlx_vlm.convert --hf-path <repo-or-path> --mlx-path ./out-awq -q --quant-method awq \
--calibration multimodal --calibration-data /path/to/media # or --calibration text (default)
dtype cast only / dequantize:
uv run mlx_vlm.convert --hf-path <repo-or-path> --mlx-path ./out-bf16 --dtype bfloat16
uv run mlx_vlm.convert --hf-path <quantized-repo> --mlx-path ./out-fp -d # dequantize
Upload the result to the Hub:
uv run mlx_vlm.convert --hf-path <repo> --mlx-path ./out -q --upload-repo <user>/<name>-mlx
Key Facts
- Multimodal modules are skipped from quantization by default (
skip_multimodal_module) — vision/audio towers stay full precision; only the language model is quantized. This is expected, not a bug. --q-modechoices:affine(default, group 64 / 4 bit),mxfp4(32/4),nvfp4(16/4),mxfp8(32/8).--q-bits/--q-group-sizeoverride the mode defaults.--quant-method:rtn(default, round-to-nearest) orawq(needs calibration;--calibration text|multimodal, optional--calibration-data).-q/--quantizeand-d/--dequantizeare mutually exclusive.--dtype(fromconfig.jsontorch_dtypeif unset) casts float weights; useful for shrinking fp32 → bf16 without quantizing.- The converted folder gets the weights, copied
*.py/*.json, the processor, a regeneratedconfig.json, and a model card — it is ready formlx_vlm.generateand the server.
Validation
- After converting, load and run a tiny generation to prove the checkpoint works — see
Skill("mlx-vlm-skills:cli-inference"). Run on Apple Silicon with enough RAM for the model; do not attempt a large model on an 8 GB machine. - For quality, compare a few greedy outputs between the source and the quantized model; large drops usually mean too-low bits or a wrong
--q-modefor the model. - For code changes touching conversion, run
uv run --with pytest python -m pytest mlx_vlm/tests/test_utils.py -qand any model-specific test. - If the outcome is a bug report, switch to
Skill("mlx-vlm-skills:reproducible-github-issues").
よくある質問
どのモデルも変換できますか?
いいえ。モデルのファミリーが既にサポートされているか、移植の作業が必要です。
量子化の手順は何をしますか?
選んだビット数で、変換したモデルを小さくします。
結果をHugging Faceにアップロードできますか?
はい。任意の選択肢として、Hubへのアップロードも扱うと説明されています。
詳細
作者による元の説明
Use this skill when the user wants to convert a Hugging Face model to MLX or quantize/dequantize one with mlx_vlm.convert, including bits and group size, quant modes (affine, mxfp4, nvfp4, mxfp8), RTN vs AWQ, mixed-bit recipes, dtype casts, calibration (text or multimodal), local vs Hub paths, revisions, uploading to the Hub, and convert/quant errors.
repo: Blaizzy/mlx-vlm
人気
- GitHubのスター
- 5.7k
- ランキング
- #14749
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
cli-inference
5.7kエージェントが、コマンドラインからMLX-VLMのモデルの推論を実行、またはトラブルシュートできるよう支援します。テキスト、画像、音声の入力に対応し、作業ごとの適切なフラグを見つけます。
hf-cache-models
5.7kエージェントが、実行中のMLX-VLMサーバーから見えるモデルを一覧にし、キャッシュされたもの、独自のもの、読み込み済みのものを、モデル探索のエンドポイントに問い合わせて確認できるよう支援します。
reproducible-github-issues
5.7kエージェントが、MLX-VLMのバグや遅い結果について、環境の詳細、正確なコマンド、小さな例を含む、明確で再現できるGitHubのIssueを書けるよう支援します。
server-inference
5.7kエージェントが、MLX-VLMのAPIサーバーを実行してデバッグできるよう支援します。ヘルスチェック、チャットと応答のリクエスト、ストリーミング、よくあるリクエストのエラーを扱います。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。