Skip to content

Add Command to Register MLX Models from Arbitrary Paths (e.g., LM Studio Downloads) #12

Description

@kj-9

Hi,

I would like to use the mlx model files downloaded with LM Studio. I was able to achieve this by manually editing llm-mlx.json, but how about implementing a smarter method?

Situation

The models downloaded with LM Studio are saved in ~/.lmstudio/models/mlx-community on my MacBook:

❯ tree ~/.lmstudio/models/mlx-community
/Users/kh03/.lmstudio/models/mlx-community
├── DeepSeek-R1-Distill-Qwen-7B-4bit
│   ├── config.json
│   ├── model.safetensors
│   ├── model.safetensors.index.json
│   ├── special_tokens_map.json
│   ├── tokenizer.json
│   └── tokenizer_config.json
├── Mistral-7B-Instruct-v0.3-4bit
│   ├── config.json
│   ├── hub
│   │   └── version.txt
│   ├── model.safetensors
│   ├── model.safetensors.index.json
│   ├── special_tokens_map.json
│   ├── tokenizer.json
│   ├── tokenizer.model
│   └── tokenizer_config.json
└── hub
    └── version.txt

To use these models from LLM, I first tried the llm mlx import-models command added in #6 but failed:

❯ HF_HOME='~/.lmstudio/models/' llm mlx import-models
No MLX models found in Hugging Face cache

This command did not find anything because the current implementation requires:

  • A /snapshot/ directory to exist
  • The directory name representing the model to be separated by --

In other words, it needs to be in the following format: ${HF_HOME}/hub/models--mlx-community--Llama-3.2-3B-Instruct-4bit/ which lm studio dowloaded dirs not follow (as shown above)

As a workaround, I was able to use the model by editing the json file at $(llm mlx models-file):

{
  "~/.lmstudio/models/mlx-community/Mistral-7B-Instruct-v0.3-4bit": {
    "aliases": ["lmstudio-mistral"]
  }
}

where the key is path to the model directory lm studio downloaded.
Then I was able to execute:

llm -m lmstudio-mistral hi

As a side note, The load function used internally by mlx-lm seems to accept both Hugging Face repositories and paths as shown above.

Proposal

In llm gguf, there is a register-model command to register any gguf file.

Similarly, how about adding a command to register any path like this?

llm mlx register-models ~/.lmstudio/models/mlx-community/Mistral-7B-Instruct-v0.3-4bit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions