Text Generation
MLX
Safetensors
flint
code
coding-agent
Mixture of Experts
apple-silicon
mac
24gb
32gb
3-bit
conversational
4-bit precision
Instructions to use Nav8ha/flint-mixed-3-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Nav8ha/flint-mixed-3-4bit 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("Nav8ha/flint-mixed-3-4bit") 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 Nav8ha/flint-mixed-3-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Nav8ha/flint-mixed-3-4bit"
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": "Nav8ha/flint-mixed-3-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use Nav8ha/flint-mixed-3-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Nav8ha/flint-mixed-3-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Nav8ha/flint-mixed-3-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nav8ha/flint-mixed-3-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use Nav8ha/flint-mixed-3-4bit 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 "Nav8ha/flint-mixed-3-4bit"
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 Nav8ha/flint-mixed-3-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Nav8ha/flint-mixed-3-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Nav8ha/flint-mixed-3-4bit"
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 "Nav8ha/flint-mixed-3-4bit" \ --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 eval_kl.py from Nav8ha/flint-mixed-3-4bit: direct link, hf CLI and curl.
- Browser
- Download file 3.66 kB
-
https://huggingface.co/Nav8ha/flint-mixed-3-4bit/resolve/main/eval_kl.py
- Command line
-
hf download hf://Nav8ha/flint-mixed-3-4bit/eval_kl.py
-
curl -L -o eval_kl.py https://huggingface.co/Nav8ha/flint-mixed-3-4bit/resolve/main/eval_kl.py
3.66 kB
| """Quant quality vs a reference model, on held-out code text. | |
| ref: python eval_kl.py ref MODEL OUT.npz [GLOB ...] -> saves top-K log-probs per token | |
| cmp: python eval_kl.py cmp MODEL OUT.npz [GLOB ...] -> PPL, KL(ref||model), top-1 agreement | |
| KL uses the reference top-K tokens plus one bucket for the rest of the vocab. | |
| """ | |
| import glob, sys, time | |
| import mlx.core as mx | |
| import numpy as np | |
| from mlx_lm import load | |
| K, SEQ, NSEQ = 32, 1024, 48 | |
| def corpus(tok, sources): | |
| files = sorted({f for g in sources for f in glob.glob(g, recursive=True) | |
| if "node_modules" not in f and "/." not in f and "venv" not in f}) | |
| ids = [] | |
| for f in files: | |
| ids += tok.encode(open(f, errors="ignore").read(), add_special_tokens=False) | |
| if len(ids) >= SEQ * NSEQ: | |
| break | |
| assert len(ids) >= SEQ * NSEQ, f"only {len(ids)} tokens" | |
| return np.array(ids[: SEQ * NSEQ]).reshape(NSEQ, SEQ), len(files) | |
| def logprobs(model, seq): | |
| logits = model(mx.array(seq)[None])[0].astype(mx.float32) | |
| return logits - mx.logsumexp(logits, axis=-1, keepdims=True) | |
| def patch_uint8_packing(): | |
| # Recursive's INT4 export packs weights in uint8; mlx-lm expects uint32. | |
| import mlx_lm.utils as u | |
| raw_load = mx.load | |
| def load_u32(f, *a, **k): | |
| w = raw_load(f, *a, **k) | |
| return {n: v.view(mx.uint32) if v.dtype == mx.uint8 else v for n, v in w.items()} | |
| u.mx.load = load_u32 | |
| def main(mode, path, out, *globs): | |
| sources = globs or ["**/*.py"] # held-out code you trust is not in training data | |
| if "flint-int4" in path or "/rec/models/" in path: | |
| patch_uint8_packing() | |
| model, tok = load(path) | |
| data, nfiles = corpus(tok, sources) | |
| t0 = time.time() | |
| if mode == "ref": | |
| top_i, top_lp, tgt_lp = [], [], [] | |
| for n, seq in enumerate(data): | |
| lp = logprobs(model, seq) | |
| print(f" ref seq {n+1}/{NSEQ} {time.time()-t0:.0f}s", flush=True) | |
| idx = mx.argpartition(-lp, K, axis=-1)[:, :K] | |
| top_i.append(np.array(idx)); top_lp.append(np.array(mx.take_along_axis(lp, idx, -1))) | |
| tgt_lp.append(np.array(mx.take_along_axis(lp[:-1], mx.array(seq[1:])[:, None], -1))[:, 0]) | |
| np.savez(out, top_i=np.stack(top_i), top_lp=np.stack(top_lp), tgt_lp=np.stack(tgt_lp), data=data) | |
| print(f"ref {path}: ppl {np.exp(-np.mean(tgt_lp)):.4f} from {nfiles} files, {time.time()-t0:.0f}s") | |
| return | |
| ref = np.load(out) | |
| assert (ref["data"] == data).all(), "tokenized corpus differs from the reference run" | |
| kls, agree, tgt = [], [], [] | |
| for n, seq in enumerate(data): | |
| lp = logprobs(model, seq) | |
| ri, rlp = mx.array(ref["top_i"][n]), mx.array(ref["top_lp"][n]) | |
| qlp = mx.take_along_axis(lp, ri, -1) | |
| p, q = mx.exp(rlp), mx.exp(qlp) | |
| p_rest = mx.maximum(1 - p.sum(-1), 1e-9); q_rest = mx.maximum(1 - q.sum(-1), 1e-9) | |
| kl = (p * (rlp - qlp)).sum(-1) + p_rest * (mx.log(p_rest) - mx.log(q_rest)) | |
| kls.append(np.array(kl)) | |
| print(f" cmp seq {n+1}/{NSEQ} {time.time()-t0:.0f}s", flush=True) | |
| ref_top1 = ri[mx.arange(SEQ), mx.argmax(rlp, -1)] | |
| agree.append(np.array(mx.argmax(lp, -1) == ref_top1)) | |
| tgt.append(np.array(mx.take_along_axis(lp[:-1], mx.array(seq[1:])[:, None], -1))[:, 0]) | |
| kls = np.concatenate(kls) | |
| print(f"cmp {path}: ppl {np.exp(-np.mean(tgt)):.4f} (ref {np.exp(-np.mean(ref['tgt_lp'])):.4f}) " | |
| f"| KL mean {kls.mean():.4f} p99 {np.percentile(kls, 99):.4f} " | |
| f"| top-1 agree {np.concatenate(agree).mean()*100:.2f}% | {time.time()-t0:.0f}s") | |
| if __name__ == "__main__": | |
| main(*sys.argv[1:]) | |