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
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,117 +1,106 @@
|
|
|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 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
```
|
| 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).*
|
|
|
|
| 1 |
+
# EmsyAI π§
|
| 2 |
+
|
| 3 |
+
[](https://opensource.org/licenses/MIT)
|
| 4 |
+
[](https://www.python.org/)
|
| 5 |
+
[](https://pytorch.org/)
|
| 6 |
+
[](https://huggingface.co/gulding/EmsyAI)
|
| 7 |
+
|
| 8 |
+
EmsyAI is a complete, educational, decoder-only Transformer Language Model built entirely from mathematical first principles in pure PyTorch. The goal of this project is to demystify how modern LLMs (like Llama 3, Qwen 2.5, and DeepSeek) operate under the hood.
|
| 9 |
+
|
| 10 |
+
This is **not** a wrapper around the `transformers` library. **Every single component was built from scratch:**
|
| 11 |
+
|
| 12 |
+
- βοΈ **Hand-rolled Byte-Pair Encoding (BPE)** Tokenizer with native special token isolation (`<|eos|>`, `<|bos|>`, `<|pad|>`)
|
| 13 |
+
- π **Rotary Positional Embeddings (RoPE)** via complex polar tensor rotations
|
| 14 |
+
- β‘ **Grouped Query Attention (GQA)** with fused FlashAttention-2 (PyTorch SDPA)
|
| 15 |
+
- πͺ **SwiGLU Feed-Forward Networks** (3-matrix gated layout: $W_1, W_2, W_3$)
|
| 16 |
+
- βοΈ **RMSNorm Pre-Normalization** with numerical float32 upcasting
|
| 17 |
+
- πΎ **Step-by-Step KV Caching** for high-throughput autoregressive inference
|
| 18 |
+
- π― **Multi-Layer Low-Rank Adaptation (LoRA)** fine-tuning across all 7 linear projections
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## ποΈ Architecture Specifications
|
| 23 |
+
|
| 24 |
+
| Specification | EmsyAI-v3 Titan | EmsyAI-v4 (Current Training) |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| **Parameters** | 153.8 Million (Tied) | 196 Million (Tied) |
|
| 27 |
+
| **Layers ($L$)** | 16 | 16 |
|
| 28 |
+
| **Hidden Dimension ($d_{\text{model}}$)** | 896 | 1024 |
|
| 29 |
+
| **Attention Heads ($H_q / H_{kv}$)** | 14 Query / 2 KV (GQA 7:1) | 16 Query / 4 KV (GQA 4:1) |
|
| 30 |
+
| **FFN Dimension** | 2,560 (SwiGLU) | 2,816 (SwiGLU) |
|
| 31 |
+
| **Context Window ($T$)** | 4,096 tokens | 4,096 tokens |
|
| 32 |
+
| **Vocabulary Size** | 16,000 (Hybrid BPE) | 16,000 (Hybrid BPE) |
|
| 33 |
+
| **Attention Backend** | FlashAttention-2 | FlashAttention-2 (`is_causal=True`) |
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## π Quickstart: Run in 5 Seconds via Ollama
|
| 38 |
+
|
| 39 |
+
You can run EmsyAI natively without installing PyTorch or GPU drivers:
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
ollama run hf.co/gulding/EmsyAI
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## π» Developer & Training Pipeline
|
| 46 |
+
|
| 47 |
+
This project uses [uv](https://github.com/astral-sh/uv) for fast dependency management.
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
# 1. Clone the repository
|
| 51 |
+
git clone https://github.com/gulding/EmsyAI.git
|
| 52 |
+
cd EmsyAI
|
| 53 |
+
|
| 54 |
+
# 2. Install dependencies (PyTorch with CUDA 12.1)
|
| 55 |
+
uv sync
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### 1. Data Engine & Strict Decontamination
|
| 59 |
+
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.
|
| 60 |
+
```bash
|
| 61 |
+
# Stream and decontaminate 500M tokens from Cosmopedia v2
|
| 62 |
+
uv run python scripts/prepare_v4_data.py
|
| 63 |
+
|
| 64 |
+
# Verify the dataset is 100% sterile
|
| 65 |
+
uv run python scripts/audit_contamination.py
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### 2. Pretraining
|
| 69 |
+
```bash
|
| 70 |
+
# Pretrain EmsyAI-v4 (196M Model @ 4,096 Context)
|
| 71 |
+
uv run python -m emsyai.training.train_v4
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### 3. LoRA Instruction Fine-Tuning (SFT)
|
| 75 |
+
```bash
|
| 76 |
+
# Download 20k CodeAlpaca instruction dataset
|
| 77 |
+
uv run python -m emsyai.training.download_alpaca
|
| 78 |
+
|
| 79 |
+
# Train LoRA adapters across all linear layers
|
| 80 |
+
uv run python -m emsyai.training.finetune --steps 10000
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
### 4. Interactive Chat REPL
|
| 84 |
+
```bash
|
| 85 |
+
uv run python -m emsyai.chat \
|
| 86 |
+
--checkpoint checkpoints_v4/model_step_15000.pt \
|
| 87 |
+
--version v4
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
## π Prompt Template
|
| 91 |
+
|
| 92 |
+
When querying the instruction model, use the exact role tags:
|
| 93 |
+
|
| 94 |
+
```text
|
| 95 |
+
[USER]
|
| 96 |
+
Write a Python function to check if a number is prime.
|
| 97 |
+
[MODEL]
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
## π¬ Mathematical Verification Suite
|
| 101 |
+
|
| 102 |
+
Run our verification suite to mathematically validate attention causality and KV-cache consistency:
|
| 103 |
+
|
| 104 |
+
```bash
|
| 105 |
+
uv run python scripts/verify_model.py
|
| 106 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|