convert-quantize
Skill này làm gì
Skill này dạy agent cách chuyển một mô hình AI từ Hugging Face sang định dạng MLX, và tùy chọn làm nó nhỏ hơn. Dành cho người muốn chạy mô hình trên thiết bị Apple.
Khi nào nên dùng
- ✓Khi người dùng muốn chuyển một mô hình Hugging Face thành phiên bản MLX cho Mac.
- ✓Khi người dùng muốn một phiên bản 4-bit hoặc 8-bit nhỏ hơn của mô hình.
- ✓Khi một lệnh chuyển đổi hoặc lượng tử hóa bị lỗi và cần sửa.
Liên kết skill
https://github.com/Blaizzy/mlx-vlm/blob/main/skills/skills/convert-quantize/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy chuyển mô hình Hugging Face này sang MLX và tạo phiên bản 4-bit vừa với Mac của tôi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent xác nhận nguồn và họ mô hình, rồi chạy lệnh convert với số bit, kích thước nhóm và chế độ đã chọn. Nó kiểm tra đầu ra trợ giúp trước, vì các cờ có thể thay đổi.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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").
Câu hỏi thường gặp
Mọi mô hình đều có thể chuyển đổi không?
Không. Skill nói họ mô hình phải đã được hỗ trợ, hoặc đó là một công việc đưa sang nền tảng khác.
Bước lượng tử hóa làm gì?
Nó làm mô hình nhỏ hơn, dùng số bit bạn chọn.
Kết quả có thể tải lên Hugging Face không?
Có. Skill bao quát việc tải lên Hub như một tùy chọn.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 5.7k
- Vị trí xếp hạng
- #14749
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
cli-inference
5.7kGiúp agent chạy hoặc khắc phục suy luận MLX-VLM từ dòng lệnh, với đầu vào văn bản, hình ảnh và âm thanh, và tìm đúng cờ cho từng việc.
hf-cache-models
5.7kGiúp agent của bạn liệt kê model mà server MLX-VLM đang chạy thấy được, gồm model đã cache, tùy chỉnh và đã tải, qua endpoint khám phá model.
reproducible-github-issues
5.7kGiúp agent của bạn viết issue GitHub rõ ràng, tái hiện được cho MLX-VLM, kèm thông tin môi trường, lệnh chính xác và ví dụ nhỏ, khi gặp lỗi hoặc chạy chậm.
server-inference
5.7kGiúp agent của bạn chạy và gỡ lỗi server API MLX-VLM, gồm kiểm tra tình trạng, yêu cầu chat và responses, streaming và các lỗi thường gặp.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.