blaizzy/mlx-vlm/add-new-model
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use this skill when the user wants to add or port a new model architecture to MLX-VLM — mapping a Hugging Face model_type to a new file under mlx_vlm/models, writing the ModelConfig, matching layer/weight names, reusing a similar existing model, adding a test class, and validating the port. Covers vision-language, language, audio, and diffusion model ports.
Install
npx vskill@latest install blaizzy/mlx-vlm/add-new-modelSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Add a New Model
Use this workflow to port a new model to MLX-VLM.
Layout Rules
- New model lives in
mlx_vlm/models/<model_type>/, and the main file is named after theconfig.jsonmodel_type(e.g.model_type: "llava"→mlx_vlm/models/llava/llava.py). The loader resolves the arch by importingmlx_vlm.models.<model_type>(seeMODEL_REMAPPINGinmlx_vlm/utils.pyfor aliases). - Split by concern like the existing families:
language.py,vision.py,config.py,processing_*.py. A new kernel/helper goes in its own file in the model dir, not insidelanguage.py. - Start from a similar existing model in
mlx_vlm/models/and adapt — don't write from scratch.
Steps
- Confirm weights are safetensors. If not, convert them first (HF safetensors converter), then proceed.
- Copy a close relative as scaffolding (same attention/vision style). Rename to the new
model_type. - Write `config.py`. A
ModelConfigdataclass; give every new field a backward-compatible default (None/0/False) so existing configs still load unchanged. Add inline# comments. - Map layer/weight names. Determine them by one of:
- the Transformers implementation, if you know it;
- loading the weights and printing key names;
- reading
model.safetensors.index.jsonin the HF repo.
- Wire the forward pass (embeddings → vision/audio encoder → projector → language model), reusing shared helpers (
prompt_utils.py, processors) where possible. - Convert to MLX to get loadable weights —
Skill("mlx-vlm-skills:convert-quantize"). Upload them to tomlx-community(which is self-add) on HF if there is no usable official repo. If the model is already usable directly from HF, you can skip this step and just use the repo directly. - Check tool calling for every model. Inspect the official model card, chat template, and reference parser to establish support, including for models that reuse an existing architecture. If supported, complete Tool Calling; otherwise record whether support is absent or still unknown.
- Add a test class in
mlx_vlm/tests/test_models.py(e.g.TestMyModel) — a tiny random-weight config, a shape/forward check, and (if applicable) an exactness check against a reference path in the degenerate limit. Do not create a standalone test file. - Add a README in the model dir with a short description of the model, supported HF repos, and example usage.
Tool Calling
- Verify
_infer_tool_parser_from_processoragainst the model's actual chat template. Reuse a compatible parser inmlx_vlm/tool_parsers/; add a parser and register its template markers in__init__.pyonly when needed. Check that existing formats still select the right parser. - Match the native protocol and schema types, including its string escaping or CDATA rules where applicable. Exercise
process_tool_callsinmlx_vlm/server/responses_state.py: it strips the start/end markers before invoking the parser. Confirm tools and prior tool results render correctly through the chat template. - Keep regressions compact in
TestProcessToolCallsinmlx_vlm/tests/test_server.py, reusing existing streaming tests and fixtures. Avoid a new model-specific test file or duplicated endpoint mocks. Cover a single call, argument types, malformed input, and ordinary text around calls. - For models supporting multiple calls per response, check both different functions and repeated calls to the same function with different arguments. Assert independent arguments, unique IDs, and ordered indices. Verify split streaming markers do not leak markup or swallow surrounding text; the client controls concurrent tool execution.
- Run the focused parser cases and shared streaming tests from the repository root:
uv run --with pytest python -m pytest mlx_vlm/tests/test_server.py -q -k 'ToolCall or tool_stream'. Include existing tests for any reused parser that changed. - With loadable weights, smoke-test tools through the server in streaming and non-streaming modes, plus a normal reply without a call. Report whether validation used actual generation or synthetic output. Include a concrete before/after response example when describing a tool-calling fix in a PR.
Determine Layer Names (quick)
Validation
- Run the model's test class:
``bash cd mlx_vlm && uv run --with pytest python -m pytest tests/test_models.py -q -k "TestMyModel" ``
- Then a real end-to-end generation via
Skill("mlx-vlm-skills:cli-inference"). Run on Apple Silicon with enough RAM for the model; isolate a submodule with random-init weights if the full model does not fit (do not run large models on an 8 GB machine). - Compare a few greedy outputs against the reference implementation (transformers / diffusers) on the same prompt to confirm correctness, not just that it runs.
- Format with pre-commit and follow PR expectations —
Skill("mlx-vlm-skills:contributing"). - Ensure all commits are signed or else the opened PR will not be merged.
Common Failure Routing
Model type <x> not supported: the folder name /model_typedon't match, or the arch import failed — checkmlx_vlm/models/<model_type>/exists and imports cleanly.- Weight-name mismatches on load: your module attribute names don't match the checkpoint; reconcile against
model.safetensors.index.json. - Processor/chat-template errors: mirror a sibling model's
processing_*.pyandprompt_utilsusage. - If you get stuck and want to file it, use
Skill("mlx-vlm-skills:reproducible-github-issues").
Code standards
- Keep code comments concise (usually 1-2 lines)
- Avoid redundant or excessive inline commentary
- Use ASD-STE100 Simplified Technical English, simple wordings
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/skills/add-new-model/SKILL.md
Popularity
- Repository stars
- 5,624
- Repository forks
- 829
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/blaizzy/mlx-vlm/add-new-model)