Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -8,46 +8,122 @@ tags: [hobbylm, mixture-of-experts, moe, sparse-moe]
|
|
| 8 |
|
| 9 |
# HobbyLM-Chat (500M MoE, instruction-tuned)
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Architecture
|
| 16 |
|
| 17 |
-
HobbyLM
|
|
|
|
|
|
|
| 18 |
|
| 19 |
| Component | Value |
|
| 20 |
|---|---|
|
| 21 |
-
| Total parameters | ~500M (
|
| 22 |
-
| Hidden size / layers | 768 / 16 (
|
| 23 |
| Routed experts / active | 36 / top-6 (+ 1 always-on shared expert) |
|
| 24 |
-
| Attention | GQA, 12 query / 3 KV heads, head-dim 128, per-head QK-norm |
|
| 25 |
-
| Router | sigmoid gating, aux-loss-free
|
| 26 |
-
| Positional | RoPE |
|
| 27 |
| Tokenizer | GPT-2 byte-level BPE (50,304 vocab, sentinel-padded) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
- `
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
```python
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
from safetensors.torch import load_file
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
```
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
-
|
| 49 |
-
-
|
|
|
|
| 50 |
|
| 51 |
## License
|
| 52 |
|
| 53 |
-
Apache-2.0.
|
|
|
|
|
|
| 8 |
|
| 9 |
# HobbyLM-Chat (500M MoE, instruction-tuned)
|
| 10 |
|
| 11 |
+
HobbyLM-Chat is the instruction-tuned conversational model β HobbyLM-Base taken through SmolTalk supervised fine-tuning and a SmolLM2-style UltraFeedback DPO pass. The jump from base is large: it holds a coherent persona, follows instructions, and (with a repetition penalty) produces varied, flowing prose.
|
| 12 |
|
| 13 |
+
It's part of the **HobbyLM** family β a 500M sparse-MoE model (and its variants) built from scratch on a
|
| 14 |
+
hobby budget: FineWeb, a handful of Modal H100 hours, a lot of ablations, and a from-scratch Rust engine
|
| 15 |
+
([`hobby-rs`](https://github.com/harishsg993010/HobbyLM)) to run it on a laptop CPU.
|
| 16 |
+
|
| 17 |
+
## Intended use
|
| 18 |
+
|
| 19 |
+
General single- and multi-turn chat / instruction following. Prompt it with the trained `SYSTEM:` / `USER:` / `ASSISTANT:` turn format, and decode with a **repetition penalty β1.3** (this is what tames the small-model repetition tendency).
|
| 20 |
|
| 21 |
## Architecture
|
| 22 |
|
| 23 |
+
Every HobbyLM variant shares one core: a **sparse Mixture-of-Experts (MoE)** decoder in the modern
|
| 24 |
+
small-MoE style (DeepSeek-V3 / OLMoE lineage), where each design choice was picked by ablation rather
|
| 25 |
+
than by guesswork.
|
| 26 |
|
| 27 |
| Component | Value |
|
| 28 |
|---|---|
|
| 29 |
+
| Total parameters | ~500M (only a fraction is active per token) |
|
| 30 |
+
| Hidden size / layers | 768 / 16 (first FFN dense, the rest MoE) |
|
| 31 |
| Routed experts / active | 36 / top-6 (+ 1 always-on shared expert) |
|
| 32 |
+
| Attention | GQA, 12 query / 3 KV heads, decoupled head-dim 128, per-head QK-norm |
|
| 33 |
+
| Router | sigmoid gating, DeepSeek-V3 aux-loss-free load balancing, no top-k renorm |
|
| 34 |
+
| Positional | RoPE (ΞΈ up to 1e6 for the 8k-context checkpoints) |
|
| 35 |
| Tokenizer | GPT-2 byte-level BPE (50,304 vocab, sentinel-padded) |
|
| 36 |
+
| Optimizer | Muon on the 2-D + per-expert matrices, AdamW on everything else |
|
| 37 |
+
|
| 38 |
+
The full ablation log (QK-norm is the single biggest lever; aux-loss-free beats classic aux-loss;
|
| 39 |
+
β₯32 experts and top-6 help; embedding-scaling hurt) lives in the project's architecture notes.
|
| 40 |
+
|
| 41 |
+
## Benchmarks
|
| 42 |
+
|
| 43 |
+
0-shot multiple-choice, our harness. Note that MC benchmarks measure *knowledge*, not *chat quality* β the
|
| 44 |
+
goal of this checkpoint is conversational fluency, which these tasks don't capture. The small dip vs the base
|
| 45 |
+
model is the usual **alignment tax**.
|
| 46 |
|
| 47 |
+
| Task | HobbyLM-Chat | HobbyLM-Base |
|
| 48 |
+
|---|---|---|
|
| 49 |
+
| ARC-challenge | 23.8 | 22.4 |
|
| 50 |
+
| ARC-easy | 42.2 | 42.8 |
|
| 51 |
+
| HellaSwag | 39.5 | 41.6 |
|
| 52 |
+
| PIQA | 67.1 | 69.5 |
|
| 53 |
+
| WinoGrande | 53.6 | 51.3 |
|
| 54 |
+
| OpenBookQA | 27.2 | 29.8 |
|
| 55 |
+
| BoolQ | 44.4 | 51.0 |
|
| 56 |
+
| **Average** | **42.5** | **44.0** |
|
| 57 |
|
| 58 |
+
Reasoning tasks (ARC, WinoGrande) held or improved; BoolQ dropped the most β chat phrasing fits the
|
| 59 |
+
log-likelihood format worse, not a capability loss. This is healthy for a ~500M chat model (SmolLM-360M range).
|
| 60 |
|
| 61 |
+
> **How these were measured.** All language-model scores are **0-shot** through our own port of
|
| 62 |
+
> EleutherAI's `lm-evaluation-harness` (a custom `MoELMWrapper` that runs log-likelihood scoring over the
|
| 63 |
+
> HobbyLM MoE + GPT-2 tokenizer). Reference models in the comparison table were run through the **identical
|
| 64 |
+
> harness and task set**, so the numbers are apples-to-apples with ours β they are *not* copied from other
|
| 65 |
+
> model cards. We validated the harness against published cards (e.g. TinyLlama 52.75 vs card 52.99). These
|
| 66 |
+
> are small research models: read the numbers in context, not as leaderboard claims.
|
| 67 |
|
| 68 |
+
## Usage
|
| 69 |
+
|
| 70 |
+
### Python (PyTorch reference implementation)
|
| 71 |
+
|
| 72 |
+
HobbyLM is a custom sparse-MoE architecture β there's no `transformers` `AutoModel` for it, so load it with
|
| 73 |
+
the small reference implementation from the [GitHub repo](https://github.com/harishsg993010/HobbyLM):
|
| 74 |
|
| 75 |
```python
|
| 76 |
+
# HobbyLM is a CUSTOM sparse-MoE architecture, so load it with the reference implementation β
|
| 77 |
+
# NOT transformers.AutoModelForCausalLM (there is no AutoModel mapping for this arch).
|
| 78 |
+
# pip install torch safetensors tiktoken huggingface_hub
|
| 79 |
+
# git clone https://github.com/harishsg993010/HobbyLM && cd HobbyLM
|
| 80 |
+
|
| 81 |
+
import json, torch, tiktoken
|
| 82 |
+
from huggingface_hub import hf_hub_download
|
| 83 |
from safetensors.torch import load_file
|
| 84 |
+
from hobbylm.config import ModelConfig
|
| 85 |
+
from hobbylm.model import MoETransformer
|
| 86 |
+
from hobbylm.generate import generate
|
| 87 |
+
|
| 88 |
+
repo = "rootxhacker/HobbyLM-Chat"
|
| 89 |
+
cfg = ModelConfig(**{k: v for k, v in json.load(open(hf_hub_download(repo, "config.json"))).items() if k != "preset"})
|
| 90 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 91 |
+
cfg.expert_backend = "grouped" if device.type == "cuda" else "bmm"
|
| 92 |
+
|
| 93 |
+
model = MoETransformer(cfg).to(device).eval()
|
| 94 |
+
model.load_state_dict(load_file(hf_hub_download(repo, "model.safetensors")))
|
| 95 |
+
|
| 96 |
+
enc = tiktoken.get_encoding("gpt2")
|
| 97 |
+
prompt = "USER: Give me three tips for better sleep.\nASSISTANT:"
|
| 98 |
+
ids = torch.tensor([enc.encode_ordinary(prompt)], device=device)
|
| 99 |
+
out = generate(model, ids, max_new_tokens=64, temperature=0.7, top_k=0, device=device,
|
| 100 |
+
repetition_penalty=1.3) # temperature=0.0 for greedy
|
| 101 |
+
print(enc.decode(out[0].tolist()))
|
| 102 |
```
|
| 103 |
|
| 104 |
+
> Prompt it with the trained `USER:` / `ASSISTANT:` turn format (a leading `SYSTEM:` turn is optional). A repetition penalty around **1.3** is recommended.
|
| 105 |
+
|
| 106 |
+
### GGUF + hobby-rs (CPU)
|
| 107 |
+
|
| 108 |
+
GGUF builds (architecture `hobbylm`) live in [`rootxhacker/HobbyLM-gguf`](https://huggingface.co/rootxhacker/HobbyLM-gguf). They load
|
| 109 |
+
directly in the from-scratch `hobby-rs` CPU engine β **stock llama.cpp won't load them** without registering
|
| 110 |
+
the `hobbylm` architecture first.
|
| 111 |
+
|
| 112 |
+
```bash
|
| 113 |
+
hobby-rs --model HobbyLM-Chat.gguf --prompt "..." --n 64
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
## Training
|
| 117 |
+
|
| 118 |
+
SFT on ~1.5M chat trajectories (smol-smoltalk + the conversational smoltalk2 subsets), loss on assistant turns only; then UltraFeedback DPO (Ξ²=0.1) β the SmolLM2 recipe. SFT loss β ~1.50, DPO preference accuracy 0.50 β 0.64.
|
| 119 |
+
|
| 120 |
+
## Limitations
|
| 121 |
|
| 122 |
+
- Carries the 500M ceiling: factual hallucination, and weak adherence to strict output formats (e.g. exact syllable counts).
|
| 123 |
+
- Use a repetition penalty at decode time; greedy decoding can loop.
|
| 124 |
+
- Not safety-aligned β no RLHF safety tuning.
|
| 125 |
|
| 126 |
## License
|
| 127 |
|
| 128 |
+
Apache-2.0. Weights aren't a substitute for judgement β this is a research / hobby model at the 500M scale,
|
| 129 |
+
not a production system.
|