Text Classification
MLX
Safetensors
English
gemma4
mlx-4bit
decision-model
classification
calibration
baseten
apple-silicon
4-bit precision
Instructions to use pratikgx/bison-1-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use pratikgx/bison-1-MLX-4bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download pratikgx/bison-1-MLX-4bit --local-dir bison-1-MLX-4bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download engine/readout.py from pratikgx/bison-1-MLX-4bit: direct link, hf CLI and curl.
- Browser
- Download file 3.06 kB
-
https://huggingface.co/pratikgx/bison-1-MLX-4bit/resolve/main/engine/readout.py
- Command line
-
hf download hf://pratikgx/bison-1-MLX-4bit/engine/readout.py
-
curl -L -o readout.py https://huggingface.co/pratikgx/bison-1-MLX-4bit/resolve/main/engine/readout.py
3.06 kB
| """Load Baseten / OneJev readout settings from readout.json and config.json. | |
| bison-1 and groundhog-1 store the mask under `baseten_modeling_overrides`. Older Qwen | |
| checkpoints (elephant-1, mammoth-1) use `modeling_overrides`. Both keys are accepted. | |
| `block_bidirectional` on full-attention layers is the `noncausal` setting in OneJev/qev. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from dataclasses import dataclass | |
| from pathlib import Path | |
| from typing import Any | |
| OVERRIDE_KEYS = ("baseten_modeling_overrides", "modeling_overrides") | |
| FULL_ATTENTION_MASK = {"causal": "causal", "block_bidirectional": "noncausal"} | |
| class ReadoutConfig: | |
| attention: str # "causal" or "noncausal" | |
| readout: str = "slot_lm" | |
| head_dim: int = 256 | |
| n_slots: int = 256 | |
| sliding_attention: str = "causal" | |
| logit_softcap: float | None = 30.0 | |
| def block_bidirectional(self) -> bool: | |
| return self.attention == "noncausal" | |
| def _overrides(config: dict[str, Any]) -> dict[str, Any] | None: | |
| for key in OVERRIDE_KEYS: | |
| if key in config and config[key]: | |
| return config[key] | |
| return None | |
| def load_readout_config(model_dir: str | Path, logit_softcap: float | None = None) -> ReadoutConfig: | |
| model_dir = Path(model_dir) | |
| readout_path = model_dir / "readout.json" | |
| config_path = model_dir / "config.json" | |
| fields: dict[str, Any] = json.loads(readout_path.read_text()) if readout_path.is_file() else {} | |
| config: dict[str, Any] = json.loads(config_path.read_text()) if config_path.is_file() else {} | |
| overrides = _overrides(config) | |
| if overrides: | |
| mask = (overrides.get("attention") or {}).get("full_attention") | |
| attention = FULL_ATTENTION_MASK.get(mask) | |
| if attention is None: | |
| raise ValueError(f"unsupported full_attention mask {mask!r} in {config_path}") | |
| if fields.get("attention", attention) != attention: | |
| raise ValueError( | |
| f"{readout_path} says attention {fields.get('attention')!r} but {config_path} says {mask!r}" | |
| ) | |
| fields["attention"] = attention | |
| sliding = (overrides.get("attention") or {}).get("sliding_attention", "causal") | |
| fields["sliding_attention"] = sliding | |
| fields.setdefault("readout", overrides.get("readout", "slot_lm")) | |
| fields.setdefault("head_dim", overrides.get("head_dim", 256)) | |
| fields.setdefault("n_slots", overrides.get("n_slots", 256)) | |
| fields.setdefault("attention", "causal") | |
| fields.setdefault("readout", "slot_lm") | |
| fields.setdefault("head_dim", 256) | |
| fields.setdefault("n_slots", 256) | |
| fields.setdefault("sliding_attention", "causal") | |
| if logit_softcap is None: | |
| text = config.get("text_config") or config | |
| logit_softcap = text.get("final_logit_softcapping", 30.0) | |
| fields["logit_softcap"] = logit_softcap | |
| allowed = {"attention", "readout", "head_dim", "n_slots", "sliding_attention", "logit_softcap"} | |
| return ReadoutConfig(**{k: v for k, v in fields.items() if k in allowed}) | |