rootxhacker commited on
Commit
5386b53
Β·
verified Β·
1 Parent(s): 6342b1c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +97 -23
README.md CHANGED
@@ -8,51 +8,125 @@ tags: [hobbylm, mixture-of-experts, moe, sparse-moe]
8
 
9
  # HobbyLM-Omni (500M MoE, text + image + audio)
10
 
11
- Multimodal (omni) variant: a TinyLLaVA-style VLM over the HobbyLM MoE core, with vision and speech projectors.
12
 
13
- Part of the **HobbyLM** family β€” a from-scratch 500M sparse-MoE model trained on consumer-scale budgets.
 
 
 
 
 
 
14
 
15
  ## Architecture
16
 
17
- HobbyLM is a **sparse Mixture-of-Experts (MoE)** transformer (DeepSeek-V3 / Ling-style):
 
 
18
 
19
  | Component | Value |
20
  |---|---|
21
- | Total parameters | ~500M (β‰ˆ a fraction active per token) |
22
- | Hidden size / layers | 768 / 16 (1 dense FFN layer, 15 MoE) |
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 balancing bias, no top-k renorm |
26
- | Positional | RoPE |
27
  | Tokenizer | GPT-2 byte-level BPE (50,304 vocab, sentinel-padded) |
 
28
 
 
 
29
 
30
  ## Multimodal use
31
 
32
- This repo also ships the projector weights:
33
- `vision_projector.safetensors` (SigLIP2 β†’ LLM) and `speech_projector.safetensors` (Whisper-mel β†’ LLM), plus `melfilters.bytes`. Image/audio are encoded by the (frozen) SigLIP2 / mel front-ends, projected, and spliced in at the `[IMAGE]`/`[AUDIO]`/`[SPEECH]` sentinel tokens (ids 50257–50262).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- ## Files
36
 
37
- - `model.safetensors` β€” the model weights (fp32).
38
- - `config.json` β€” architecture / hyperparameters.
39
- - GGUF builds (arch `hobbylm`) live in [`rootxhacker/HobbyLM-gguf`](https://huggingface.co/rootxhacker/HobbyLM-gguf).
40
 
41
- ## Loading (safetensors)
 
42
 
43
  ```python
44
- import json, torch
 
 
 
 
 
 
45
  from safetensors.torch import load_file
46
- sd = load_file("model.safetensors")
47
- cfg = json.load(open("config.json"))
48
- # rebuild the HobbyLM nn.Module from `cfg` and `load_state_dict(sd)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ```
50
 
51
- ## Notes & limitations
 
 
 
 
52
 
53
- - Research model at the ~500M scale: fluent but with the capability ceiling of a small model.
54
- - The GGUF uses a custom `hobbylm` architecture (see the GGUF repo) and needs `moe-rs` or a patched llama.cpp.
 
55
 
56
  ## License
57
 
58
- Apache-2.0.
 
 
8
 
9
  # HobbyLM-Omni (500M MoE, text + image + audio)
10
 
11
+ HobbyLM-Omni is the multimodal core: **one** 500M MoE model that handles text, image, video, audio, and speech β€” plus tool use, OCR, and UI grounding β€” folded into a single checkpoint across 18 training paths (TinyLLaVA-style projectors over frozen SigLIP2 / Whisper / CLAP front-ends). The headline isn't any single score; it's the **breadth** in one small model.
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
+ Vision-language and audio-language tasks: captioning, visual QA, OCR, sound/speech understanding, spoken-question answering, and tool calling. Image/audio/speech features are projected and spliced at the `[IMAGE]`/`[AUDIO]`/`[SPEECH]` sentinel tokens (ids 50257–50262).
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
  ## Multimodal use
42
 
43
+ This repo also ships the projector weights β€” `vision_projector.safetensors` (SigLIP2 β†’ LLM) and `speech_projector.safetensors` (Whisper-mel β†’ LLM), plus `melfilters.bytes`. The frozen front-ends encode the raw image/audio, the projectors map those features into the LLM embedding space, and they're spliced in at the modality sentinel tokens.
44
+
45
+ ## Benchmarks
46
+
47
+ Visual QA is scored with **containment** (the model is chat-trained and answers in full sentences, so strict
48
+ single-word exact-match badly under-scores it):
49
+
50
+ | Task | Score |
51
+ |---|---|
52
+ | VQAv2 (val) | 47.0 |
53
+ | GQA | 39.2 |
54
+ | POPE β€” accuracy / F1 | 50.0 / 66.7 |
55
+ | Tool calling β€” Needle (JSON-parse / Name-F1 / param-halluc) | 93.8 / 77.7 / 0.0 |
56
+ | BFCL (forced-call: simple / multiple) | 21.7 / 18.3 |
57
+ | Text β€” lm-eval 9-task avg | 0.432 |
58
+
59
+ POPE at 50/66.7 is a **real** ceiling β€” object-presence hallucination ("yes" to everything) is the known
60
+ small-VLM weakness, quantified. On function calling, Omni *can* call as well as the dedicated tool model
61
+ (forced-call simple 21.7 β‰ˆ the specialist's 22.7); left to itself it prefers to abstain (irrelevance 86.7),
62
+ a safer agent failure mode. Speech does spoken-QA and commands rather than verbatim transcription.
63
+
64
+ > **How these were measured.** All language-model scores are **0-shot** through our own port of
65
+ > EleutherAI's `lm-evaluation-harness` (a custom `MoELMWrapper` that runs log-likelihood scoring over the
66
+ > HobbyLM MoE + GPT-2 tokenizer). Reference models in the comparison table were run through the **identical
67
+ > harness and task set**, so the numbers are apples-to-apples with ours β€” they are *not* copied from other
68
+ > model cards. We validated the harness against published cards (e.g. TinyLlama 52.75 vs card 52.99). These
69
+ > are small research models: read the numbers in context, not as leaderboard claims.
70
 
71
+ ## Usage
72
 
73
+ ### Python (PyTorch reference implementation)
 
 
74
 
75
+ HobbyLM is a custom sparse-MoE architecture β€” there's no `transformers` `AutoModel` for it, so load it with
76
+ the small reference implementation from the [GitHub repo](https://github.com/harishsg993010/HobbyLM):
77
 
78
  ```python
79
+ # HobbyLM is a CUSTOM sparse-MoE architecture, so load it with the reference implementation β€”
80
+ # NOT transformers.AutoModelForCausalLM (there is no AutoModel mapping for this arch).
81
+ # pip install torch safetensors tiktoken huggingface_hub
82
+ # git clone https://github.com/harishsg993010/HobbyLM && cd HobbyLM
83
+
84
+ import json, torch, tiktoken
85
+ from huggingface_hub import hf_hub_download
86
  from safetensors.torch import load_file
87
+ from hobbylm.config import ModelConfig
88
+ from hobbylm.model import MoETransformer
89
+ from hobbylm.generate import generate
90
+
91
+ repo = "rootxhacker/HobbyLM-Omni"
92
+ cfg = ModelConfig(**{k: v for k, v in json.load(open(hf_hub_download(repo, "config.json"))).items() if k != "preset"})
93
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
94
+ cfg.expert_backend = "grouped" if device.type == "cuda" else "bmm"
95
+
96
+ model = MoETransformer(cfg).to(device).eval()
97
+ model.load_state_dict(load_file(hf_hub_download(repo, "model.safetensors")))
98
+
99
+ enc = tiktoken.get_encoding("gpt2")
100
+ prompt = "USER: Explain a mixture-of-experts model in one sentence.\nASSISTANT:"
101
+ ids = torch.tensor([enc.encode_ordinary(prompt)], device=device)
102
+ out = generate(model, ids, max_new_tokens=64, temperature=0.7, top_k=0, device=device,
103
+ repetition_penalty=1.3) # temperature=0.0 for greedy
104
+ print(enc.decode(out[0].tolist()))
105
+ ```
106
+
107
+ > The snippet above is the **text** path. For image / audio / speech, encode the input with the (frozen) SigLIP2 / Whisper / CLAP front-end, project it with the bundled projectors, and splice it at the modality sentinel token β€” see `hobbylm/multimodal.py`, or just pass `--image` / `--speech` to `hobby-rs`.
108
+
109
+ ### GGUF + hobby-rs (CPU)
110
+
111
+ GGUF builds (architecture `hobbylm`) live in [`rootxhacker/HobbyLM-gguf`](https://huggingface.co/rootxhacker/HobbyLM-gguf). They load
112
+ directly in the from-scratch `hobby-rs` CPU engine β€” **stock llama.cpp won't load them** without registering
113
+ the `hobbylm` architecture first.
114
+
115
+ ```bash
116
+ hobby-rs --model HobbyLM-Omni.gguf --prompt "..." --n 64
117
  ```
118
 
119
+ ## Training
120
+
121
+ Built in stages on the context-extended (8k, ΞΈ 1e6) backbone with a 512px SigLIP2 vision tower: projector alignment β†’ multimodal SFT β†’ a joint 18-path co-training cycle (image / video / audio / speech / text / tools / OCR / UI-grounding) that keeps every modality from drifting.
122
+
123
+ ## Limitations
124
 
125
+ - Breadth over depth: strong **in-distribution** (VQA, JSON tool calls with 0 hallucination, OCR, grounding) but below specialist sub-1B models on hard text reasoning (GSM8K, multi-hop QA).
126
+ - Object-presence hallucination on POPE-style probes.
127
+ - Verbose by default β€” ask for short answers explicitly, or score with containment, not exact-match.
128
 
129
  ## License
130
 
131
+ Apache-2.0. Weights aren't a substitute for judgement β€” this is a research / hobby model at the 500M scale,
132
+ not a production system.