gulding commited on
Commit
1fc66ec
Β·
verified Β·
1 Parent(s): c4acedd

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +117 -99
README.md CHANGED
@@ -1,99 +1,117 @@
1
- ---
2
- license: mit
3
- pipeline_tag: text-generation
4
- language:
5
- - en
6
- tags:
7
- - gguf
8
- - llama.cpp
9
- - ollama
10
- - from-scratch
11
- - educational
12
- - pytorch
13
- ---
14
-
15
- # EmsyAI πŸš€
16
-
17
- EmsyAI is a small, decoder-only transformer language model built entirely from scratch in pure PyTorch β€” no `transformers` library, no pre-built blocks. It's an educational project: the goal is to demystify how models like Llama 3, Qwen 2.5, and DeepSeek work internally by actually building every piece β€” tokenizer, attention, RoPE, KV cache, LoRA β€” by hand.
18
-
19
- Full training code, data pipeline, and developer docs live on [GitHub](https://github.com/gulding/EmsyAI). This page is about the model artifact itself: what it is, how to run it, and what to expect.
20
-
21
- > [!WARNING]
22
- > **Read this before you run it:** EmsyAI is a small model (V3 Titan is 154M parameters) trained on a small, narrow dataset. It is not a general-purpose assistant and won't behave like one β€” treat it as a working demonstration of a from-scratch LLM pipeline, not a production model. See [Limitations](#limitations).
23
-
24
- ### Built from scratch:
25
- - 🧩 **Hand-rolled byte-pair encoding (BPE)** tokenizer
26
- - πŸ”„ **Rotary position embeddings (RoPE)** via complex tensor rotation
27
- - 🎯 **Grouped-query attention (GQA)**, fused via `F.scaled_dot_product_attention`
28
- - 🧠 **SwiGLU** feed-forward layers
29
- - πŸ“ **RMSNorm** pre-normalization
30
- - πŸ’Ύ **KV caching** for autoregressive inference
31
- - 🎨 **LoRA fine-tuning** across all seven linear projections per block
32
-
33
- ## Quickstart
34
-
35
- By default, we serve the latest **V3 Titan** architecture (154M parameters, 4,096-token context window).
36
-
37
- ```bash
38
- ollama run hf.co/gulding/EmsyAI
39
- ```
40
-
41
- or with `llama.cpp`:
42
- ```bash
43
- llama-cli -hf gulding/EmsyAI:F32
44
- ```
45
-
46
- > **Note:** If you are looking for the older **V2** architecture (88M params, 1,024-token context), the `emsyai-v2-instruct-f32.gguf` file is still available in the Files tab.
47
-
48
- ## Prompt format
49
-
50
- ```text
51
- [USER]
52
- Write a Python function to check if a number is prime.
53
- [MODEL]
54
- ```
55
-
56
- ## What's in this repo
57
-
58
- | File | What it is | Do you need it? |
59
- |---|---|---|
60
- | `emsyai-v3-titan-instruct-f32.gguf` | **v3 Titan** base model + LoRA adapter, merged and exported to GGUF | **Yes.** This is what Ollama / llama.cpp actually run by default |
61
- | `emsyai-v2-instruct-f32.gguf` | **v2** base model + LoRA adapter, merged and exported to GGUF | Optional. Legacy 88M architecture |
62
- | `base_model_154M_step_5000.pt` | Raw PyTorch inference weights | Only if loading it back into the [training code](https://github.com/gulding/EmsyAI) |
63
- | `tokenizer.json` | The trained 16k-vocab BPE tokenizer | Only needed for the PyTorch path, not GGUF |
64
- | `Modelfile` | Ollama configuration β€” prompt template, stop token, temperature | Used automatically by `ollama run` |
65
-
66
- *(GGUF export maps the model's tensors onto llama.cpp's naming convention for Ollama/llama.cpp compatibility β€” that's why the architecture shows as `llama` in the metadata above. The training-time implementation itself is fully custom, not derived from Llama's code.)*
67
-
68
- ## Model Details
69
-
70
- | Specification | EmsyAI-v3 "Titan" (Latest) | EmsyAI-v2 (Legacy) |
71
- |---|---|---|
72
- | Parameters | 153.8M (tied embeddings) | 88.1M (tied embeddings) |
73
- | Layers | 16 | 12 |
74
- | Hidden dim | 896 | 768 |
75
- | Attention heads | 14 Query / 2 KV (GQA 7:1) | 12 Query / 4 KV (GQA 3:1) |
76
- | FFN dim | 2,560 (SwiGLU) | 2,048 (SwiGLU) |
77
- | Context window | 4,096 tokens | 1,024 tokens |
78
- | Vocab size | 16,000 (custom BPE) | 16,000 (custom BPE) |
79
- | Position encoding | RoPE | RoPE |
80
-
81
- **Training data (V3 Titan):** a ~150M-token hybrid of Cosmopedia v2 (synthetic educational text) and a Python code subset, tokenized with the project's own BPE tokenizer. Strict 10-gram decontamination was run against HumanEval and MBPP. Instruction-tuned with LoRA (rank 8, alpha 16) on ~20k CodeAlpaca examples with masked prompt loss.
82
-
83
- ## Project status
84
-
85
- **V3 Titan is complete.** The model successfully converged during 5,000 steps of pretraining on the 150M-token corpus, followed by 10,000 steps of LoRA instruction tuning. Prompt loss masking (-100) successfully eliminated base-model "topic drift", resulting in a model that strictly outputs the desired python format.
86
-
87
- ## Limitations
88
-
89
- - **Small model, small data.** 154M active parameters trained on ~150M tokens β€” closer in scale to early GPT-2-class experiments than to a modern assistant model.
90
- - **No RLHF or preference tuning** β€” only supervised LoRA fine-tuning on instruction-following examples. Expect repetitive, sometimes factually wrong, or off-topic output, especially past a few sentences.
91
- - **Code it writes may not run.** This project's own benchmark only checks that generated Python parses, not that it's logically correct β€” don't assume otherwise.
92
- - **English only**, and narrow in domain (educational text and Python code).
93
-
94
- ## License
95
- MIT β€” see [LICENSE](https://github.com/gulding/EmsyAI/blob/main/LICENSE).
96
-
97
- ## Links
98
- - πŸ’» [Source code, training pipeline, and full docs](https://github.com/gulding/EmsyAI)
99
- - πŸ’¬ [Issues / discussions](https://github.com/gulding/EmsyAI/issues)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: text-generation
4
+ language:
5
+ - en
6
+ tags:
7
+ - gguf
8
+ - llama.cpp
9
+ - ollama
10
+ - from-scratch
11
+ - educational
12
+ - pytorch
13
+ ---
14
+
15
+ # EmsyAI πŸš€
16
+
17
+ EmsyAI is a small, decoder-only transformer language model built entirely from scratch in pure PyTorch β€” no `transformers` library, no pre-built blocks. It's an educational project: the goal is to demystify how models like Llama 3, Qwen 2.5, and DeepSeek work internally by actually building every piece β€” tokenizer, attention, RoPE, KV cache, LoRA β€” by hand.
18
+
19
+ Full training code, data pipeline, and developer docs live on [GitHub](https://github.com/gulding/EmsyAI). This page is about the model artifact itself: what it is, how to run it, and what to expect.
20
+
21
+ > [!WARNING]
22
+ > **Read this before you run it:** EmsyAI is a small model (V3 Titan is 154M parameters) trained on a small, narrow dataset. It is not a general-purpose assistant and won't behave like one β€” treat it as a working demonstration of a from-scratch LLM pipeline, not a production model. See [Limitations](#limitations).
23
+
24
+ ### Built from scratch:
25
+ - 🧩 **Hand-rolled byte-pair encoding (BPE)** tokenizer
26
+ - πŸ”„ **Rotary position embeddings (RoPE)** via complex tensor rotation
27
+ - 🎯 **Grouped-query attention (GQA)**, fused via `F.scaled_dot_product_attention`
28
+ - 🧠 **SwiGLU** feed-forward layers
29
+ - πŸ“ **RMSNorm** pre-normalization
30
+ - πŸ’Ύ **KV caching** for autoregressive inference
31
+ - 🎨 **LoRA fine-tuning** across all seven linear projections per block
32
+
33
+ ## Quickstart
34
+
35
+ By default, we serve the latest **V3 Titan** architecture (154M parameters, 4,096-token context window).
36
+
37
+ ```bash
38
+ ollama run hf.co/gulding/EmsyAI
39
+ ```
40
+
41
+ or with `llama.cpp`:
42
+ ```bash
43
+ llama-cli -hf gulding/EmsyAI:F32
44
+ ```
45
+
46
+ > **Note:** If you are looking for the older **V2** architecture (88M params, 1,024-token context), the `emsyai-v2-instruct-f32.gguf` file is still available in the Files tab.
47
+
48
+ ## Prompt format
49
+
50
+ ```text
51
+ [USER]
52
+ Write a Python function to check if a number is prime.
53
+ [MODEL]
54
+ ```
55
+
56
+ ## What's in this repo
57
+
58
+ | File | What it is | Do you need it? |
59
+ |---|---|---|
60
+ | `emsyai-v3-titan-instruct-f32.gguf` | **v3 Titan** base model + LoRA adapter, merged and exported to GGUF | **Yes.** This is what Ollama / llama.cpp actually run by default |
61
+ | `emsyai-v2-instruct-f32.gguf` | **v2** base model + LoRA adapter, merged and exported to GGUF | Optional. Legacy 88M architecture |
62
+ | `base_model_154M_step_5000.pt` | Raw PyTorch inference weights | Only if loading it back into the [training code](https://github.com/gulding/EmsyAI) |
63
+ | `tokenizer.json` | The trained 16k-vocab BPE tokenizer | Only needed for the PyTorch path, not GGUF |
64
+ | `Modelfile` | Ollama configuration β€” prompt template, stop token, temperature | Used automatically by `ollama run` |
65
+
66
+ *(GGUF export maps the model's tensors onto llama.cpp's naming convention for Ollama/llama.cpp compatibility β€” that's why the architecture shows as `llama` in the metadata above. The training-time implementation itself is fully custom, not derived from Llama's code.)*
67
+
68
+ ## Model Details
69
+
70
+ | Specification | EmsyAI-v3 "Titan" (Latest) | EmsyAI-v2 (Legacy) |
71
+ |---|---|---|
72
+ | Parameters | 153.8M (tied embeddings) | 88.1M (tied embeddings) |
73
+ | Layers | 16 | 12 |
74
+ | Hidden dim | 896 | 768 |
75
+ | Attention heads | 14 Query / 2 KV (GQA 7:1) | 12 Query / 4 KV (GQA 3:1) |
76
+ | FFN dim | 2,560 (SwiGLU) | 2,048 (SwiGLU) |
77
+ | Context window | 4,096 tokens | 1,024 tokens |
78
+ | Vocab size | 16,000 (custom BPE) | 16,000 (custom BPE) |
79
+ | Position encoding | RoPE | RoPE |
80
+
81
+ **Training data (V3 Titan):** a ~150M-token hybrid of Cosmopedia v2 (synthetic educational text) and a Python code subset, tokenized with the project's own BPE tokenizer. Strict 10-gram decontamination was run against HumanEval and MBPP. Instruction-tuned with LoRA (rank 8, alpha 16) on ~20k CodeAlpaca examples with masked prompt loss.
82
+
83
+ ## Project status
84
+
85
+ **V3 Titan is complete.** The model successfully converged during 5,000 steps of pretraining on the 150M-token corpus, followed by 10,000 steps of LoRA instruction tuning. Prompt loss masking (-100) successfully eliminated base-model "topic drift", resulting in a model that strictly outputs the desired python format.
86
+
87
+ ## Limitations
88
+
89
+ - **Small model, small data.** 154M active parameters trained on ~150M tokens β€” closer in scale to early GPT-2-class experiments than to a modern assistant model.
90
+ - **No RLHF or preference tuning** β€” only supervised LoRA fine-tuning on instruction-following examples. Expect repetitive, sometimes factually wrong, or off-topic output, especially past a few sentences.
91
+ - **Code it writes may not run.** This project's own benchmark only checks that generated Python parses, not that it's logically correct β€” don't assume otherwise.
92
+ - **English only**, and narrow in domain (educational text and Python code).
93
+
94
+ ## License
95
+ MIT β€” see [LICENSE](https://github.com/gulding/EmsyAI/blob/main/LICENSE).
96
+
97
+ ## Links
98
+ - πŸ’» [Source code, training pipeline, and full docs](https://github.com/gulding/EmsyAI)
99
+ - πŸ’¬ [Issues / discussions](https://github.com/gulding/EmsyAI/issues)
100
+
101
+
102
+ Prompt loss masking successfully eliminated base-model "topic drift" (the model attempts to output Python blocks rather than continuing the prompt), but the underlying logic is still heavily limited by the 154M parameter count.
103
+
104
+ Here is a raw, unedited transcript from the model demonstrating its capabilities (and limitations):
105
+
106
+ ```python
107
+ [USER]
108
+ Write the function def is_prime(n):
109
+ [MODEL]
110
+ def is_prime(n):
111
+ if n <= 1:
112
+ return False
113
+
114
+ for i in range(2, int(n-1)+"):
115
+ print("Fizz")
116
+ ```
117
+ *Note: As seen above, while the model attempts to generate Python, it frequently hallucinates syntax errors or drifts into unrelated coding topics (like FizzBuzz).*