Run this model with HF Jobs
Run brendanboyle/Inkling-2-Mini-Codex-MLX on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/brendanboyle/Inkling-2-Mini-Codex-MLX. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/brendanboyle/Inkling-2-Mini-Codex-MLX on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/brendanboyle/Inkling-2-Mini-Codex-MLX. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/brendanboyle/Inkling-2-Mini-Codex-MLX. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use brendanboyle/Inkling-2-Mini-Codex-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use brendanboyle/Inkling-2-Mini-Codex-MLX with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("brendanboyle/Inkling-2-Mini-Codex-MLX") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use brendanboyle/Inkling-2-Mini-Codex-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "brendanboyle/Inkling-2-Mini-Codex-MLX" --prompt "Once upon a time"
- Atomic Chat
Download verify_mlx.py from brendanboyle/Inkling-2-Mini-Codex-MLX: direct link, hf CLI and curl.
- Browser
- Download file 3.42 kB
-
https://huggingface.co/brendanboyle/Inkling-2-Mini-Codex-MLX/resolve/main/verify_mlx.py
- Command line
-
hf download hf://brendanboyle/Inkling-2-Mini-Codex-MLX/verify_mlx.py
-
curl -L -o verify_mlx.py https://huggingface.co/brendanboyle/Inkling-2-Mini-Codex-MLX/resolve/main/verify_mlx.py
3.42 kB
| """Check every tensor through the stock MLX-LM adapter loader.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import mlx.core as mx | |
| import mlx.nn as nn | |
| import numpy as np | |
| from mlx.utils import tree_flatten | |
| from mlx_lm import load | |
| from mlx_lm.tuner.lora import LoRALinear | |
| from mlx_lm.tuner.utils import load_adapters | |
| from safetensors.numpy import load_file | |
| from convert import FEATURE_COUNTS, SCALE, TARGETS, sha256 | |
| class LinearFixture(nn.Linear): | |
| """Keep the base weight a broadcast scalar, with the real projection shape.""" | |
| def __init__(self, inputs: int, outputs: int): | |
| nn.Module.__init__(self) | |
| self.weight = mx.broadcast_to(mx.array(0.0), (outputs, inputs)) | |
| class ModelFixture(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.model = nn.Module() | |
| self.model.language_model = nn.Module() | |
| self.model.language_model.layers = [] | |
| for _ in range(24): | |
| layer = nn.Module() | |
| layer.self_attn = nn.Module() | |
| for projection, shape in FEATURE_COUNTS.items(): | |
| setattr(layer.self_attn, projection, LinearFixture(*shape)) | |
| self.layers.append(layer) | |
| def layers(self): | |
| return self.model.language_model.layers | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("adapter", type=Path) | |
| parser.add_argument( | |
| "--base", type=Path, help="Optional pinned base snapshot for a full Apple Silicon load" | |
| ) | |
| args = parser.parse_args() | |
| if args.base is not None: | |
| if not (args.base / "config.json").is_file(): | |
| parser.error("--base must be a local model snapshot") | |
| model, tokenizer = load(str(args.base.resolve()), adapter_path=str(args.adapter.resolve())) | |
| if not tokenizer.has_tool_calling: | |
| raise ValueError("The base tokenizer did not register the Inkling tool parser") | |
| else: | |
| mx.set_default_device(mx.cpu) | |
| model = load_adapters(ModelFixture(), str(args.adapter)) | |
| scales = { | |
| name: module.scale | |
| for name, module in model.named_modules() | |
| if isinstance(module, LoRALinear) | |
| } | |
| if scales != dict.fromkeys(TARGETS, SCALE): | |
| raise ValueError("Unexpected loaded LoRA targets or multipliers") | |
| loaded = { | |
| name: array for name, array in tree_flatten(model.parameters()) | |
| if name.endswith((".lora_a", ".lora_b")) | |
| } | |
| weights_path = args.adapter / "adapters.safetensors" | |
| serialized = load_file(weights_path) | |
| if loaded.keys() != serialized.keys() or len(loaded) != 2 * len(TARGETS): | |
| raise ValueError("The loaded tensor keys differ from the serialized adapter") | |
| for name, array in loaded.items(): | |
| loaded_array = np.asarray(array) | |
| source_array = serialized[name] | |
| if loaded_array.dtype != np.float32 or loaded_array.shape != source_array.shape: | |
| raise ValueError(f"Unexpected loaded shape or dtype for {name}") | |
| np.testing.assert_array_equal(loaded_array.view(np.uint32), source_array.view(np.uint32)) | |
| print(json.dumps({ | |
| "base": str(args.base.resolve()) if args.base is not None else "synthetic CPU fixture", | |
| "loaded_projections": len(scales), | |
| "bit_exact_loaded_tensors": len(loaded), | |
| "weights_sha256": sha256(weights_path), | |
| }, indent=2)) | |
| if __name__ == "__main__": | |
| main() | |