Ghostgim commited on
Commit
ea0bf93
·
verified ·
1 Parent(s): f628726

ghost-small-gen: 45M from-scratch generalist (GhostLM v0.12.0)

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ ghostlm_mark_512.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ library_name: ghostlm
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - ghostlm
9
+ - from-scratch
10
+ - generalist
11
+ - cybersecurity
12
+ - small-language-model
13
+ ---
14
+
15
+ # ghost-small-gen
16
+
17
+ A small (~45M parameter) decoder-only language model **trained entirely from
18
+ scratch** in PyTorch, no pretrained weights and no fine-tuning. It is the first
19
+ generalist checkpoint in the [GhostLM](https://github.com/joemunene-by/GhostLM)
20
+ project: a model that broadened from a cybersecurity-only corpus into a small
21
+ generalist while keeping cybersecurity as its deepest specialty.
22
+
23
+ - Parameters: ~45M (6 layers, d_model 512, RoPE + SwiGLU + RMSNorm)
24
+ - Tokenizer: GPT-2 BPE (50,257) + 7 special tokens
25
+ - Training: 30,000 steps on a Mac M4 (MPS), final val_loss 3.76
26
+ - Corpus: a decontaminated 258.9M-token multi-domain corpus that is only
27
+ **8.6% cybersecurity** (general web, broad Wikipedia, code, math, instruction,
28
+ and a cybersecurity layer), with 0.004% measured benchmark contamination
29
+ - Recipe: intra-document attention masking + a multi-stage domain curriculum
30
+
31
+ ## Evaluation (honest, full benchmark sets)
32
+
33
+ Debiased multi-permutation text-scoring. `+` means the 95% bootstrap CI lower
34
+ bound is above the 25% random baseline (significantly above chance). Peer
35
+ numbers are published zero-shot references for the small-model class; harnesses
36
+ differ, so treat them as context, not an exact comparison.
37
+
38
+ | Benchmark | n | ghost-small-gen (45M) | 95% CI | vs random | Peer reference |
39
+ |---|---:|---:|---:|:--:|---|
40
+ | ARC-Easy | 2365 | 27.2% | 25.4-28.9 | + | Pythia-160M 43.5, 111M 34.8, 256M 37.6 |
41
+ | ARC-Challenge | 1165 | 24.3% | 22.1-26.6 | ~ | Pythia-160M 18.8, SmolLM2-360M 36.6 |
42
+ | OpenBookQA | 500 | 27.4% | 23.7-31.1 | ~ | 111M 27.8, 256M 25.4, LaMini-35M 26.2 |
43
+ | SecQA (cyber) | 210 | 34.3% | 28.5-40.6 | + | retained specialty |
44
+ | CTF eval (cyber) | 30 | 63.3% | 46.7-80.0 | + | retained specialty |
45
+
46
+ What this says, calibrated for a 45M model trained from scratch on free compute:
47
+
48
+ - The generalist pivot worked. Three of five benchmarks are statistically above
49
+ the 25% random baseline, on a corpus only 8.6% cybersecurity.
50
+ - Cybersecurity is fully retained and is the standout (SecQA 34.3%, CTF 63.3%).
51
+ - It is competitive within its own size class: OpenBookQA beats the 256M and 35M
52
+ survey peers, and ARC-Challenge beats Pythia-160M, a roughly 3.5x larger model.
53
+ - It does not clear the 35-45% competitive band on ARC-Easy (27.2%): above
54
+ chance, not state of the art there.
55
+
56
+ This is a solid, defensible result for the size and the compute, not a
57
+ "beats everything" claim.
58
+
59
+ ## Intended use and limitations
60
+
61
+ Research and education: a transparent, hand-written small model for studying
62
+ from-scratch training, generalist corpus design, and cybersecurity-aware
63
+ language modeling. It is a base model (not instruction-tuned), small, and will
64
+ hallucinate. Do not use it for safety-critical decisions. The cybersecurity
65
+ content is for defensive and educational understanding.
66
+
67
+ ## How to load
68
+
69
+ This is a custom architecture, not a `transformers` model. Load it with the
70
+ GhostLM code:
71
+
72
+ ```python
73
+ import torch
74
+ from safetensors.torch import load_model
75
+ from ghostlm.config import GhostLMConfig
76
+ from ghostlm.model import GhostLM
77
+ from huggingface_hub import hf_hub_download
78
+ import json
79
+
80
+ repo = "Ghostgim/ghost-small-gen"
81
+ cfg = GhostLMConfig(**{k: v for k, v in json.load(open(hf_hub_download(repo, "config.json"))).items()
82
+ if k in GhostLMConfig().__dataclass_fields__})
83
+ model = GhostLM(cfg)
84
+ load_model(model, hf_hub_download(repo, "model.safetensors"))
85
+ model.eval()
86
+ ```
87
+
88
+ See the [GhostLM repository](https://github.com/joemunene-by/GhostLM) for the
89
+ model code, tokenizer, generation utilities, and the full scorecard.
90
+
91
+ ## Training details
92
+
93
+ - Base architecture: ghost-small-v0.5 (RoPE, SwiGLU, RMSNorm)
94
+ - Context length: 512, batch 16, grad-accum 4, lr 3e-4, 2000-step warmup
95
+ - Intra-document attention masking so packed documents do not attend across
96
+ EOS boundaries
97
+ - Multi-stage domain curriculum that shifts the data mixture across training
98
+ (broad web early, code/math/knowledge upweighted later)
99
+ - Corpus decontaminated against every evaluation benchmark before training
100
+
101
+ ## License
102
+
103
+ MIT. Built and trained by Joe Munene.
config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "vocab_size": 50264,
3
+ "context_length": 512,
4
+ "d_model": 512,
5
+ "n_heads": 8,
6
+ "n_layers": 6,
7
+ "d_ff": 2048,
8
+ "dropout": 0.1,
9
+ "bias": true,
10
+ "use_rope": true,
11
+ "rope_base": 10000.0,
12
+ "use_swiglu": true,
13
+ "use_rmsnorm": true,
14
+ "use_flash_attention": false,
15
+ "n_kv_heads": null,
16
+ "use_qk_norm": false,
17
+ "intra_doc_mask": true,
18
+ "eos_token_id": 50258,
19
+ "use_moe": false,
20
+ "n_experts": 4,
21
+ "n_experts_active": 2,
22
+ "moe_aux_loss_coef": 0.01,
23
+ "batch_size": 16,
24
+ "learning_rate": 0.0003,
25
+ "weight_decay": 0.1,
26
+ "beta1": 0.9,
27
+ "beta2": 0.95,
28
+ "grad_clip": 1.0,
29
+ "grad_accum_steps": 4,
30
+ "warmup_steps": 2000,
31
+ "max_steps": 30000,
32
+ "eval_interval": 1500,
33
+ "save_interval": 3000,
34
+ "data_dir": "data/processed",
35
+ "checkpoint_dir": "checkpoints/ghost_small_gen",
36
+ "log_dir": "logs/ghost_small_gen",
37
+ "device": "mps",
38
+ "dtype": "float32",
39
+ "seed": 42,
40
+ "use_wandb": false,
41
+ "wandb_project": "ghostlm",
42
+ "use_compile": false,
43
+ "gradient_checkpointing": false
44
+ }
ghostlm_mark_512.png ADDED

Git LFS Details

  • SHA256: ad94adb2d231959f124a16c66ee40ca53de3100e279475386b5e89625ce13a9d
  • Pointer size: 131 Bytes
  • Size of remote file: 105 kB
ghostlm_wordmark.png ADDED
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4eb2841582dc5a9570412ca1387865d79174a9cae0cc8128f21ed5503c1a6637
3
+ size 90048640
tokenizer_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_type": "tiktoken",
3
+ "vocab_size": 50264,
4
+ "model": "gpt2"
5
+ }