Text-to-Image
MLX
Safetensors
English
nemotron_h
apple-silicon
mac
autoregressive
mamba
Mixture of Experts
nemotron
nemotron-labs-image
q5
custom_code
Instructions to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit --local-dir Nemotron-Labs-Image-30B-A3B-MLX-5bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download code/scripts/diag_header.py from VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/diag_header.py
- Command line
-
hf download hf://VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/code/scripts/diag_header.py
-
curl -L -o diag_header.py https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/diag_header.py
1.54 kB
| """Teacher-force the correct size header after a prompt; print p(correct) and top-3 at each header position.""" | |
| import json, sys | |
| import mlx.core as mx, numpy as np | |
| from nemotron_image_mlx.pipeline import load_model | |
| from nemotron_image_mlx.prompt import PromptTokenizer | |
| M = sys.argv[1] | |
| model = load_model(M, embed="cpu"); tok = PromptTokenizer(M) | |
| g = {i["id"]: i for i in json.load(open("upstream/gallery/gallery.json"))["items"]} | |
| cases = [("g023", g["023"]["prompt"], 880, 1184), ("fox", "A cinematic photograph of a red fox in a snowy pine forest at dawn.", 880, 1184), | |
| ("fox_sq", "A cinematic photograph of a red fox in a snowy pine forest at dawn.", 1024, 1024), | |
| ("fox_land", "A cinematic photograph of a red fox in a snowy pine forest at dawn.", 1248, 832)] | |
| for name, p, w, h in cases: | |
| pids = tok.encode(p, w, h) | |
| hdr = tok.tok.encode(f"height={h} width={w}", add_special_tokens=False).ids | |
| tgt = [1010, tok.ids.img_start] + hdr + [tok.ids.vis_row] | |
| ids = mx.array([pids + tgt]) | |
| logits = model(ids)[0].astype(mx.float32) / 0.9 | |
| pr = mx.softmax(logits, axis=-1) | |
| P = len(pids) | |
| out = [] | |
| for k, t in enumerate(tgt): | |
| row = pr[P - 1 + k] | |
| top = np.array(mx.argsort(-row)[:3]) | |
| out.append(f"{tok.tok.decode([t]) if t < 131072 else t!r}:{float(row[t]):.3f} top3=" + | |
| ",".join(f"{tok.tok.decode([int(i)]) if i < 131072 else int(i)!r}:{float(row[int(i)]):.2f}" for i in top)) | |
| print(name, w, h, "P=", P); print(" " + "\n ".join(out), flush=True) | |