Text Generation
MLX
Safetensors
PyTorch
English
llama4_text
facebook
meta
mobilellm
mlx - apple-mlx - runtime
conversational
Instructions to use robbiemu/MobileLLM-R1-950M-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use robbiemu/MobileLLM-R1-950M-MLX with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("robbiemu/MobileLLM-R1-950M-MLX") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use robbiemu/MobileLLM-R1-950M-MLX with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "robbiemu/MobileLLM-R1-950M-MLX"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "robbiemu/MobileLLM-R1-950M-MLX" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use robbiemu/MobileLLM-R1-950M-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "robbiemu/MobileLLM-R1-950M-MLX"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "robbiemu/MobileLLM-R1-950M-MLX" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8080/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robbiemu/MobileLLM-R1-950M-MLX", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use robbiemu/MobileLLM-R1-950M-MLX with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "robbiemu/MobileLLM-R1-950M-MLX"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default robbiemu/MobileLLM-R1-950M-MLX
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use robbiemu/MobileLLM-R1-950M-MLX with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "robbiemu/MobileLLM-R1-950M-MLX"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "robbiemu/MobileLLM-R1-950M-MLX" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download custom_mlx_lm/custom_loader.py from robbiemu/MobileLLM-R1-950M-MLX: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/robbiemu/MobileLLM-R1-950M-MLX/resolve/main/custom_mlx_lm/custom_loader.py
- Command line
-
hf download hf://robbiemu/MobileLLM-R1-950M-MLX/custom_mlx_lm/custom_loader.py
-
curl -L -o custom_loader.py https://huggingface.co/robbiemu/MobileLLM-R1-950M-MLX/resolve/main/custom_mlx_lm/custom_loader.py
1.91 kB
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| import mlx.core as mx | |
| import mlx.nn as nn | |
| from mlx.utils import tree_unflatten | |
| # We must import from the project root's model.py | |
| from model import Model, ModelArgs | |
| def load_model(model_path: str): | |
| model_path = Path(model_path) | |
| with open(model_path / "config.json", "r") as f: | |
| config = json.load(f) | |
| # Peek with numpy to inspect keys without materializing MLX arrays yet | |
| npz_path = model_path / "weights.npz" | |
| npz = np.load(npz_path, allow_pickle=False) | |
| keys = list(npz.files) | |
| has_dual = any("g_up" in k for k in keys) | |
| args = ModelArgs.from_dict(config) | |
| args.use_dual_mlp = bool(has_dual) | |
| model = Model(args) | |
| # If quantization metadata is present, re-materialize QuantizedLinear modules | |
| qcfg = config.get("quantization") or {} | |
| method = qcfg.get("method") | |
| group_size = qcfg.get("group_size") | |
| if method == "uniform": | |
| bits = int(qcfg.get("bits", 4)) | |
| nn.quantize( | |
| model, | |
| group_size=int(group_size) if group_size is not None else 64, | |
| bits=bits, | |
| class_predicate=lambda p, m: isinstance(m, nn.Linear), | |
| ) | |
| elif method == "mixed_precision_dynamic": | |
| per_layer_bits = qcfg.get("per_layer_bits", {}) | |
| def predicate(p, m): | |
| if not isinstance(m, nn.Linear): | |
| return False | |
| b = per_layer_bits.get(p) | |
| if b is None: | |
| return False | |
| return {"bits": int(b), "group_size": int(group_size)} | |
| nn.quantize( | |
| model, | |
| group_size=int(group_size) if group_size is not None else 64, | |
| bits=4, | |
| class_predicate=predicate, | |
| ) | |
| # Now load the actual weights into MLX and update | |
| weights = mx.load(str(npz_path)) | |
| model.update(tree_unflatten(list(weights.items()))) | |
| return model | |