Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -8,46 +8,118 @@ tags: [hobbylm, mixture-of-experts, moe, sparse-moe]
|
|
| 8 |
|
| 9 |
# HobbyLM-Computer-Use (500M MoE, GUI agent / tool use)
|
| 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-Computer-Use (500M MoE, GUI agent / tool use)
|
| 10 |
|
| 11 |
+
HobbyLM-Computer-Use is the agentic variant: function calling plus a **text-only GUI agent** that reads a serialized accessibility tree (no pixels, no screenshots) and emits a grounded UI action. It can also decompose a multi-step goal and drive it to completion, deciding when it's `finish`ed.
|
| 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 |
+
Computer-use / GUI automation over a UI-Automation accessibility tree, and general tool / function calling. Serialize the screen as `SCREEN:\n[ControlType] "Name" (state) …`, give it the 12-action schema, and it returns a grounded action as JSON. Powers the Computer panel in the hobby-chat app.
|
| 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 |
+
Held-out evaluation of the v4 checkpoint (accessibility-tree grounding + multi-step planning). `param-hallucination`
|
| 44 |
+
is the rate of invented element names/arguments — strict tree-grounding in the data drives it to **0**.
|
| 45 |
|
| 46 |
+
| Split | JSON-parse | Name-F1 | Value-acc | Exact-match | Param-halluc |
|
| 47 |
+
|---|---|---|---|---|---|
|
| 48 |
+
| Planning (multi-step goals) | 96.5% | 94.7% | — | 82.6% | 0.0% |
|
| 49 |
+
| Grounding (real app trees) | ~96% | 95.5% | 91% | 78.4% | 0.0% |
|
| 50 |
+
| Grounding (synthetic screens) | 100% | 90.7% | 88.6% | 72.5% | 0.0% |
|
| 51 |
|
| 52 |
+
For general (non-GUI) function calling, the HobbyLM tool-use lineage scores **~24% average on BFCL v3**
|
| 53 |
+
(grammar-constrained) — strong relevance/abstention (relevance 77.8, beating the needle reference's 61.1),
|
| 54 |
+
weaker on parallel multi-call, which is the 500M ceiling. Exact-match understates real quality: many "misses"
|
| 55 |
+
are ambiguous numerics (e.g. *"give it a minute"* → `wait(60)` vs the reference `wait(7)`).
|
| 56 |
|
| 57 |
+
> **How these were measured.** All language-model scores are **0-shot** through our own port of
|
| 58 |
+
> EleutherAI's `lm-evaluation-harness` (a custom `MoELMWrapper` that runs log-likelihood scoring over the
|
| 59 |
+
> HobbyLM MoE + GPT-2 tokenizer). Reference models in the comparison table were run through the **identical
|
| 60 |
+
> harness and task set**, so the numbers are apples-to-apples with ours — they are *not* copied from other
|
| 61 |
+
> model cards. We validated the harness against published cards (e.g. TinyLlama 52.75 vs card 52.99). These
|
| 62 |
+
> are small research models: read the numbers in context, not as leaderboard claims.
|
| 63 |
|
| 64 |
+
## Usage
|
| 65 |
+
|
| 66 |
+
### Python (PyTorch reference implementation)
|
| 67 |
+
|
| 68 |
+
HobbyLM is a custom sparse-MoE architecture — there's no `transformers` `AutoModel` for it, so load it with
|
| 69 |
+
the small reference implementation from the [GitHub repo](https://github.com/harishsg993010/HobbyLM):
|
| 70 |
|
| 71 |
```python
|
| 72 |
+
# HobbyLM is a CUSTOM sparse-MoE architecture, so load it with the reference implementation —
|
| 73 |
+
# NOT transformers.AutoModelForCausalLM (there is no AutoModel mapping for this arch).
|
| 74 |
+
# pip install torch safetensors tiktoken huggingface_hub
|
| 75 |
+
# git clone https://github.com/harishsg993010/HobbyLM && cd HobbyLM
|
| 76 |
+
|
| 77 |
+
import json, torch, tiktoken
|
| 78 |
+
from huggingface_hub import hf_hub_download
|
| 79 |
from safetensors.torch import load_file
|
| 80 |
+
from hobbylm.config import ModelConfig
|
| 81 |
+
from hobbylm.model import MoETransformer
|
| 82 |
+
from hobbylm.generate import generate
|
| 83 |
+
|
| 84 |
+
repo = "rootxhacker/HobbyLM-Computer-Use"
|
| 85 |
+
cfg = ModelConfig(**{k: v for k, v in json.load(open(hf_hub_download(repo, "config.json"))).items() if k != "preset"})
|
| 86 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 87 |
+
cfg.expert_backend = "grouped" if device.type == "cuda" else "bmm"
|
| 88 |
+
|
| 89 |
+
model = MoETransformer(cfg).to(device).eval()
|
| 90 |
+
model.load_state_dict(load_file(hf_hub_download(repo, "model.safetensors")))
|
| 91 |
+
|
| 92 |
+
enc = tiktoken.get_encoding("gpt2")
|
| 93 |
+
prompt = "USER: What is 7 plus 2?\nASSISTANT:"
|
| 94 |
+
ids = torch.tensor([enc.encode_ordinary(prompt)], device=device)
|
| 95 |
+
out = generate(model, ids, max_new_tokens=64, temperature=0.7, top_k=0, device=device,
|
| 96 |
+
repetition_penalty=1.3) # temperature=0.0 for greedy
|
| 97 |
+
print(enc.decode(out[0].tolist()))
|
| 98 |
```
|
| 99 |
|
| 100 |
+
> For GUI / tool use, the real prompt format is `TOOLS: [<schema>]\nSCREEN:\n[ControlType] "Name" (state) …\nUSER: <instruction>\nASSISTANT:` and the model replies with a JSON action. The end-to-end agent loop lives in `agents/` in the repo.
|
| 101 |
+
|
| 102 |
+
### GGUF + hobby-rs (CPU)
|
| 103 |
+
|
| 104 |
+
GGUF builds (architecture `hobbylm`) live in [`rootxhacker/HobbyLM-gguf`](https://huggingface.co/rootxhacker/HobbyLM-gguf). They load
|
| 105 |
+
directly in the from-scratch `hobby-rs` CPU engine — **stock llama.cpp won't load them** without registering
|
| 106 |
+
the `hobbylm` architecture first.
|
| 107 |
+
|
| 108 |
+
```bash
|
| 109 |
+
hobby-rs --model HobbyLM-Computer-Use.gguf --prompt "..." --n 64
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
## Training
|
| 113 |
+
|
| 114 |
+
Continue-SFT from the combined tool checkpoint on synthetic accessibility-tree data (Gemini-generated, strictly tree-validated) + real-app UI trees + planning trajectories, with a weighted loss. 13-action vocabulary (12 UI actions + `finish`).
|
| 115 |
+
|
| 116 |
+
## Limitations
|
| 117 |
|
| 118 |
+
- Per-step grounding is ~80% accurate; on **long** goals those errors compound (short tasks usually complete, long ones can drift) and there is no per-step recovery.
|
| 119 |
+
- Trained on trees capped at ~45 elements (2k-context era); very large raw UI trees should be filtered.
|
| 120 |
+
- Near-identical controls (e.g. digit buttons) occasionally mis-ground.
|
| 121 |
|
| 122 |
## License
|
| 123 |
|
| 124 |
+
Apache-2.0. Weights aren't a substitute for judgement — this is a research / hobby model at the 500M scale,
|
| 125 |
+
not a production system.
|