Image-Text-to-Text
MLX
Safetensors
inkling_mm_model
inkling
Mixture of Experts
multimodal
text-generation
apple-silicon
conversational
Instructions to use mlx-community/Inkling-Small-mlx-2bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/Inkling-Small-mlx-2bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("mlx-community/Inkling-Small-mlx-2bit") config = load_config("mlx-community/Inkling-Small-mlx-2bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/Inkling-Small-mlx-2bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Inkling-Small-mlx-2bit"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/Inkling-Small-mlx-2bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- OpenClaw new
How to use mlx-community/Inkling-Small-mlx-2bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Inkling-Small-mlx-2bit"
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 "mlx-community/Inkling-Small-mlx-2bit" \ --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"
- Hermes Agent
How to use mlx-community/Inkling-Small-mlx-2bit 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 "mlx-community/Inkling-Small-mlx-2bit"
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 mlx-community/Inkling-Small-mlx-2bit
Run Hermes
hermes
File size: 2,602 Bytes
a9c0188 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | """Load a (possibly quantized) Inkling MLX model produced by ``convert_model``."""
from __future__ import annotations
import glob
import json
import os
import mlx.core as mx
import mlx.nn as nn
from mlx.utils import tree_flatten
from .config import InklingConfig
from .model import InklingForConditionalGeneration
def quant_predicate(group_size: int, recipe: str = "uniform"):
"""Quantize exactly the modules the converter did, by delegating to
``convert.is_quant_target`` with the same ``recipe``. Guarantees the loaded
module set matches the checkpoint (e.g. under ``experts_only``, attention and
embed/unembed stay bf16 and must NOT be re-quantized here)."""
from .convert import is_quant_target
def pred(path, module):
if not hasattr(module, "to_quantized"):
return False
w = getattr(module, "weight", None)
if w is None:
return False
return is_quant_target(path + ".weight", w.shape[-1], group_size, recipe)
return pred
def load(path: str, lazy: bool = False):
cfg_dict = json.load(open(os.path.join(path, "config.json")))
config = InklingConfig.from_dict(cfg_dict)
model = InklingForConditionalGeneration(config)
q = cfg_dict.get("quantization")
if q:
nn.quantize(model, group_size=q["group_size"], bits=q["bits"],
class_predicate=quant_predicate(q["group_size"], q.get("recipe", "uniform")))
# Stream shards: assign each, then release its handle. We do NOT eagerly
# mx.eval() the whole parameter tree — for a ~500 GB model that builds one
# enormous eval graph and trips a Metal resource limit. Weights stay lazy
# (mmap-backed) and materialize on demand during the forward pass, exactly
# like mlx-lm loads large models.
loaded = set()
shards = sorted(glob.glob(os.path.join(path, "*.safetensors")))
for shard in shards:
w = mx.load(shard)
model.load_weights(list(w.items()), strict=False)
if not lazy:
# materialize THIS shard's tensors now (bounded graph) and keep them
# resident. Avoids one enormous eval over all ~500 GB of params, which
# trips a Metal resource limit; also prevents per-token disk paging.
mx.eval(list(w.values()))
loaded.update(w.keys())
del w
expected = {k for k, _ in tree_flatten(model.parameters())}
missing = expected - loaded
if missing:
raise ValueError(f"{len(missing)} params not found in checkpoint, e.g. {sorted(missing)[:3]}")
model.eval()
return model, config
|