Text Generation
MLX
English
German
next-concept-modeling
apple-silicon
diffusion-lm
research-code
negative-results
Instructions to use Red-fuchs/ncm-modular with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Red-fuchs/ncm-modular 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("Red-fuchs/ncm-modular") 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 Red-fuchs/ncm-modular with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "Red-fuchs/ncm-modular" --prompt "Once upon a time"
- Atomic Chat
Download src/ncm_modular/massive_eval.py from Red-fuchs/ncm-modular: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/Red-fuchs/ncm-modular/resolve/main/src/ncm_modular/massive_eval.py
- Command line
-
hf download hf://Red-fuchs/ncm-modular/src/ncm_modular/massive_eval.py
-
curl -L -o massive_eval.py https://huggingface.co/Red-fuchs/ncm-modular/resolve/main/src/ncm_modular/massive_eval.py
1.4 kB
| """Metrics on decoded target strings (surrogate form) for MASSIVE structured output.""" | |
| import os, sys, json, collections | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| os.environ.setdefault("MFMT", "C") | |
| import massive_build as mb | |
| def score(preds, D): | |
| """preds: decoded strings. returns dict of metrics.""" | |
| tp = fp = fn = 0; it_ok = ex = 0; rec_n = rec_hit = 0; valid = 0; inv_sur = 0 | |
| for p, d in zip(preds, D): | |
| inv = {v: k for k, v in d["map"].items()} | |
| it, sl = mb.parse(p, inv) | |
| gold = [tuple(x) for x in d["slots"]] | |
| it_ok += it == d["intent"]; ex += (it == d["intent"] and sl == gold) | |
| g, q = collections.Counter(gold), collections.Counter(sl) | |
| c = sum((g & q).values()); tp += c; fp += sum(q.values()) - c; fn += sum(g.values()) - c | |
| rec_n += len(gold); rec_hit += c | |
| # surrogate integrity: every surrogate the output uses must exist in the prefix map | |
| segs = mb.re.findall(r"The .*? is ([^.]*)\.", p) | |
| bad = [s for s in segs[1:] if s not in inv] if len(segs) > 1 else [] | |
| inv_sur += len(bad) > 0 | |
| n = len(D); pr = tp / max(tp + fp, 1); rc = tp / max(tp + fn, 1) | |
| return dict(n=n, intent_acc=it_ok / n, slot_f1=2 * pr * rc / max(pr + rc, 1e-9), slot_p=pr, slot_r=rc, | |
| exact_match=ex / n, fact_restoration=rec_hit / max(rec_n, 1), invalid_surrogate_rate=inv_sur / n) | |