Instructions to use gulding/EmsyAI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use gulding/EmsyAI with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf gulding/EmsyAI:F32 # Run inference directly in the terminal: llama cli -hf gulding/EmsyAI:F32
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf gulding/EmsyAI:F32 # Run inference directly in the terminal: llama cli -hf gulding/EmsyAI:F32
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf gulding/EmsyAI:F32 # Run inference directly in the terminal: ./build/bin/llama cli -hf gulding/EmsyAI:F32
Use Docker
docker model run hf.co/gulding/EmsyAI:F32
- Llama new
- LM Studio
- Jan
- vLLM
How to use gulding/EmsyAI with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gulding/EmsyAI" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gulding/EmsyAI", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/gulding/EmsyAI:F32
- Ollama
How to use gulding/EmsyAI with Ollama:
ollama run hf.co/gulding/EmsyAI:F32
- Unsloth Desktop
- Docker Model Runner
How to use gulding/EmsyAI with Docker Model Runner:
docker model run hf.co/gulding/EmsyAI:F32
- Lemonade
How to use gulding/EmsyAI with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull gulding/EmsyAI:F32
Run and chat with the model
lemonade run user.EmsyAI-F32
List all available models
lemonade list
- Atomic Chat
Update V4 Model Card
Browse files
README.md
CHANGED
|
@@ -1,120 +1,76 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
pipeline_tag: text-generation
|
| 4 |
-
language:
|
| 5 |
-
- en
|
| 6 |
tags:
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# EmsyAI
|
| 16 |
|
| 17 |
-
|
| 18 |
-
[](https://www.python.org/)
|
| 19 |
-
[](https://pytorch.org/)
|
| 20 |
-
[](https://huggingface.co/gulding/EmsyAI)
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
-
-
|
| 29 |
-
-
|
| 30 |
-
-
|
| 31 |
-
-
|
| 32 |
-
-
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|---|---|---|
|
| 40 |
-
| **Parameters** | 153.8 Million (Tied) | 196 Million (Tied) |
|
| 41 |
-
| **Layers ($L$)** | 16 | 16 |
|
| 42 |
-
| **Hidden Dimension ($d_{\text{model}}$)** | 896 | 1024 |
|
| 43 |
-
| **Attention Heads ($H_q / H_{kv}$)** | 14 Query / 2 KV (GQA 7:1) | 16 Query / 4 KV (GQA 4:1) |
|
| 44 |
-
| **FFN Dimension** | 2,560 (SwiGLU) | 2,816 (SwiGLU) |
|
| 45 |
-
| **Context Window ($T$)** | 4,096 tokens | 4,096 tokens |
|
| 46 |
-
| **Vocabulary Size** | 16,000 (Hybrid BPE) | 16,000 (Hybrid BPE) |
|
| 47 |
-
| **Attention Backend** | FlashAttention-2 | FlashAttention-2 (`is_causal=True`) |
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
```
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
# 1. Clone the repository
|
| 65 |
-
git clone https://github.com/gulding/EmsyAI.git
|
| 66 |
-
cd EmsyAI
|
| 67 |
|
| 68 |
-
|
| 69 |
-
uv sync
|
| 70 |
-
```
|
| 71 |
-
|
| 72 |
-
### 1. Data Engine & Strict Decontamination
|
| 73 |
-
EmsyAI-v4 is trained on a strictly verified, mathematically sterile dataset. We explicitly filter out exact 13-gram overlap sequences against standard coding benchmarks (e.g., HumanEval) at the token level during ingestion.
|
| 74 |
-
```bash
|
| 75 |
-
# Stream and decontaminate 500M tokens from Cosmopedia v2
|
| 76 |
-
uv run python scripts/prepare_v4_data.py
|
| 77 |
|
| 78 |
-
|
| 79 |
-
uv run python scripts/audit_contamination.py
|
| 80 |
-
```
|
| 81 |
|
| 82 |
-
### 2. Pretraining
|
| 83 |
```bash
|
| 84 |
-
#
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
### 3. LoRA Instruction Fine-Tuning (SFT)
|
| 89 |
-
```bash
|
| 90 |
-
# Download 20k CodeAlpaca instruction dataset
|
| 91 |
-
uv run python -m emsyai.training.download_alpaca
|
| 92 |
-
|
| 93 |
-
# Train LoRA adapters across all linear layers
|
| 94 |
-
uv run python -m emsyai.training.finetune --steps 10000
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
### 4. Interactive Chat REPL
|
| 98 |
-
```bash
|
| 99 |
-
uv run python -m emsyai.chat \
|
| 100 |
-
--checkpoint checkpoints_v4/model_step_15000.pt \
|
| 101 |
-
--version v4
|
| 102 |
-
```
|
| 103 |
-
|
| 104 |
-
## 📝 Prompt Template
|
| 105 |
|
| 106 |
-
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
Write a Python function to check if a number is prime.
|
| 111 |
-
[MODEL]
|
| 112 |
```
|
| 113 |
|
| 114 |
-
##
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- pytorch
|
| 6 |
+
- emsyai
|
| 7 |
+
- custom-architecture
|
| 8 |
+
- pretraining
|
| 9 |
+
- lora
|
| 10 |
+
- ollama
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# EmsyAI (V4)
|
| 14 |
|
| 15 |
+
EmsyAI is an open-source, from-scratch 196M parameter Large Language Model built strictly as an educational journey. The goal of this project is to demystify LLM creation by handling every single step locally: writing a custom BPE tokenizer, coding a Llama-style Transformer in pure PyTorch, pretraining on 2 Billion tokens, running LoRA instruction tuning, and finally exporting to GGUF for edge deployment via Ollama.
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
## 🚀 V4 Architecture
|
| 18 |
|
| 19 |
+
The V4 iteration is the most advanced version of EmsyAI yet, scaling to almost 200 Million parameters with a massive 4096-token context window.
|
| 20 |
|
| 21 |
+
- **Parameters:** ~196.7M (Base) + 2.3M (LoRA Adapters)
|
| 22 |
+
- **Training Tokens:** 1.96 Billion
|
| 23 |
+
- **Context Length:** 4096
|
| 24 |
+
- **Dim:** 1024
|
| 25 |
+
- **Layers:** 16
|
| 26 |
+
- **Heads:** 16 (Q), 4 (KV) (Grouped Query Attention)
|
| 27 |
+
- **FFN Dim:** 2816 (SwiGLU)
|
| 28 |
+
- **RoPE Theta:** 10,000.0
|
| 29 |
|
| 30 |
+
## 📈 Pretraining Results
|
| 31 |
|
| 32 |
+
The model was pretrained for 15,000 steps using an aggressive learning rate schedule. Despite running on consumer hardware, the training run achieved a flawlessly smooth exponential decay in both cross-entropy loss and validation perplexity, ultimately converging at a final perplexity of **5.86**.
|
| 33 |
|
| 34 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
## 🧪 Evaluation & Data Contamination
|
| 37 |
|
| 38 |
+
After pretraining, EmsyAI V4 was fine-tuned for 10,000 steps using LoRA adapters on the ~20k `CodeAlpaca` instruction dataset to teach it the standard `[USER]` / `[MODEL]` chat format.
|
| 39 |
|
| 40 |
+
**HumanEval pass@1 Score:** `0.0%`
|
| 41 |
|
| 42 |
+
*Wait, 0.0%? Is that a failure?*
|
| 43 |
+
Actually, this is a massive success! Modern models that ace HumanEval are typically 40x larger (8B+) and trained on 1,500x more data (3T+ tokens). A 196M parameter model scoring 0% is mathematically expected.
|
|
|
|
| 44 |
|
| 45 |
+
More importantly, **we audited the CodeAlpaca instruction dataset for contamination** before fine-tuning. Using an aggressive 13-gram exact match technique, we discovered exactly **1,644 sequences** in the open-source CodeAlpaca dataset that perfectly leaked HumanEval test logic (such as Heron's formula and prime number checks).
|
| 46 |
|
| 47 |
+
Despite this verifiable data leakage, EmsyAI scored 0.0%, proving that the model did not blindly overfit or memorize the test set during the LoRA phase. It remains an honest, baseline 196M model!
|
| 48 |
|
| 49 |
+
## 💻 How to Run (Ollama)
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
EmsyAI V4 has been fused and exported to the highly optimized GGUF format for CPU/GPU inference.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
If you have [Ollama](https://ollama.com/) installed, you can run EmsyAI directly:
|
|
|
|
|
|
|
| 54 |
|
|
|
|
| 55 |
```bash
|
| 56 |
+
# Clone the repository
|
| 57 |
+
git clone https://github.com/gulding/EmsyAI.git
|
| 58 |
+
cd EmsyAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
# Create the Ollama model using the provided Modelfile
|
| 61 |
+
ollama create emsyai-v4 -f Modelfile
|
| 62 |
|
| 63 |
+
# Start chatting!
|
| 64 |
+
ollama run emsyai-v4
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
+
## 🧠 What's Next (V5 Blueprint)
|
| 68 |
|
| 69 |
+
While V4 was a massive success, we are already blueprinting **V5**, which will adopt bleeding-edge insights inspired by the Qwen 3 architecture:
|
| 70 |
+
1. **QK-Norm:** Injecting RMSNorm on the Query and Key states to completely eliminate attention logit exploding (a major instability during V4 scaling).
|
| 71 |
+
2. **Document-Aware Packing:** Upgrading our tokenization pipeline to respect document boundaries instead of blindly concatenating texts, preventing cross-document attention poisoning.
|
| 72 |
+
3. **Tokenizer Rebuild:** Fixing a critical collision where bytes 0-3 currently overlap with special tokens, and expanding the vocabulary to 32K or 64K.
|
| 73 |
+
4. **RoPE Scaling:** Lowering `head_dim` back to 64 and adjusting `rope_theta` to 500,000.0 to better balance high-frequency and low-frequency positional perception at context=4096.
|
| 74 |
|
| 75 |
+
---
|
| 76 |
+
*Built with ❤️ in pure PyTorch.*
|
|
|