JustScriptzz commited on
Commit
e4c3273
·
verified ·
1 Parent(s): eaea5c6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +99 -0
README.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - it
6
+ tags:
7
+ - custom-transformer
8
+ - from-scratch
9
+ - small-language-model
10
+ - gqa
11
+ - swiglu
12
+ - rope
13
+ - pytorch
14
+ library_name: custom
15
+ ---
16
+
17
+ # Nexus SmAll v1
18
+
19
+ A **89.8M parameter** causal language model built entirely from scratch using a custom transformer architecture, trained on WikiText-103 + synthetic instruction data.
20
+
21
+ ## Architecture
22
+
23
+ | Parameter | Value |
24
+ |-----------|-------|
25
+ | Parameters | 89.8M |
26
+ | Layers | 10 |
27
+ | Hidden dim | 768 |
28
+ | Attention heads | 12 |
29
+ | KV heads (GQA) | 4 |
30
+ | Max sequence length | 512 |
31
+ | Vocab size | 50,304 |
32
+ | FFN activation | SwiGLU |
33
+ | Position encoding | RoPE (θ=500000) |
34
+ | Norm | RMSNorm |
35
+ | Training | Float32, full precision |
36
+
37
+ Key design choices:
38
+ - **Grouped Query Attention (GQA)**: 12 query heads, 4 KV heads for efficient inference
39
+ - **SwiGLU FFN**: Gated activation for better training dynamics
40
+ - **RoPE**: Rotary Position Embeddings for length extrapolation
41
+ - **Tied embeddings**: Input/output embeddings share weights
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ git clone https://huggingface.co/MarcoTesting/nexus-smAll-v1
47
+ cd nexus-smAll-v1
48
+ pip install torch tokenizers
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ### Chat
54
+
55
+ ```python
56
+ from src.model import Nexus
57
+ from src.config import NexusConfig
58
+ from tokenizers import Tokenizer
59
+ import torch
60
+
61
+ config = NexusConfig()
62
+ model = Nexus(config)
63
+
64
+ checkpoint = torch.load("weights/nexus_instruct.pt", map_location="cpu", weights_only=False)
65
+ model.load_state_dict(checkpoint["model_state_dict"])
66
+ model.eval()
67
+
68
+ tokenizer = Tokenizer.from_file("data/tokenizer.json")
69
+
70
+ prompt = "<|user|>\nWhat is Python?\n<|assistant|>\n"
71
+ encoded = tokenizer.encode(prompt)
72
+ tokens = torch.tensor([encoded.ids])
73
+
74
+ output, _ = model.generate(tokens, max_new_tokens=64, temperature=0.2, top_k=40, top_p=0.9)
75
+ reply = tokenizer.decode(output)
76
+
77
+ print(reply)
78
+ ```
79
+
80
+ ### Command line
81
+
82
+ ```bash
83
+ python chat.py --weights weights/nexus_instruct.pt
84
+ ```
85
+
86
+ ## Training
87
+
88
+ - **Phase 1**: 100k steps on WikiText-103 (next-token prediction, ~212k sequences)
89
+ - **Phase 2**: 5k steps on instruction data (Dolly-15k + synthetic QA, ~1500 examples)
90
+
91
+ ## Limitations
92
+
93
+ - 90M parameters is very small by modern standards — outputs may be incoherent
94
+ - Not instruction-tuned on diverse enough data
95
+ - Best used as a learning experiment, not production
96
+
97
+ ## License
98
+
99
+ Apache 2.0