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
|
@@ -12,48 +12,87 @@ tags:
|
|
| 12 |
|
| 13 |
# EmsyAI ๐ง
|
| 14 |
|
| 15 |
-
EmsyAI is a
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
- **
|
| 34 |
-
- **
|
| 35 |
-
- **
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
Because EmsyAI follows the standard Llama architecture, we exported it to GGUF format! You can run it instantly on your local machine using Ollama without installing any Python dependencies:
|
| 46 |
|
| 47 |
```bash
|
| 48 |
ollama run hf.co/gulding/EmsyAI
|
| 49 |
```
|
| 50 |
|
| 51 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
##
|
| 59 |
-
|
|
|
|
|
|
| 12 |
|
| 13 |
# EmsyAI ๐ง
|
| 14 |
|
| 15 |
+
EmsyAI is a complete, educational, decoder-only Transformer Language Model built entirely from scratch in pure PyTorch. The goal of this project is to demystify how modern Large Language Models (like Llama 3, Qwen, and GPT) work under the hood.
|
| 16 |
+
|
| 17 |
+
This is not a wrapper around the `transformers` library. **Every single component was built from scratch:**
|
| 18 |
+
- Hand-rolled Byte-Pair Encoding (BPE) Tokenizer
|
| 19 |
+
- Rotary Positional Embeddings (RoPE)
|
| 20 |
+
- Grouped Query Attention (GQA)
|
| 21 |
+
- SwiGLU Feed-Forward Networks
|
| 22 |
+
- RMSNorm Pre-Normalization
|
| 23 |
+
- KV Caching Autoregressive Inference
|
| 24 |
+
- Low-Rank Adaptation (LoRA) Fine-tuning
|
| 25 |
+
|
| 26 |
+
## ๐๏ธ Architecture
|
| 27 |
+
|
| 28 |
+
The architecture heavily mirrors modern LLM designs (specifically Llama 3):
|
| 29 |
+
- **Parameters**: ~89 Million (120M class with weight tying)
|
| 30 |
+
- **Layers**: 12
|
| 31 |
+
- **Hidden Dimension**: 768
|
| 32 |
+
- **Attention Heads**: 12 Query, 4 KV (GQA)
|
| 33 |
+
- **FFN Hidden Dimension**: 2048
|
| 34 |
+
- **Context Length**: 1024
|
| 35 |
+
- **Vocab Size**: 16000
|
| 36 |
+
- **Attention Kernel**: PyTorch Native FlashAttention-2 (SDPA)
|
| 37 |
+
|
| 38 |
+
## ๐ Getting Started
|
| 39 |
+
|
| 40 |
+
This project uses `uv` for lightning-fast dependency management.
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
# Install dependencies
|
| 44 |
+
uv sync
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
### โก Run Natively with Ollama
|
| 48 |
Because EmsyAI follows the standard Llama architecture, we exported it to GGUF format! You can run it instantly on your local machine using Ollama without installing any Python dependencies:
|
| 49 |
|
| 50 |
```bash
|
| 51 |
ollama run hf.co/gulding/EmsyAI
|
| 52 |
```
|
| 53 |
|
| 54 |
+
### 1. Tokenizer Training
|
| 55 |
+
The pure-Python BPE tokenizer is trained on the CPython source code.
|
| 56 |
+
```bash
|
| 57 |
+
# Download CPython source code
|
| 58 |
+
uv run python data/download_v2.py
|
| 59 |
|
| 60 |
+
# Train the BPE Tokenizer (creates dataset/tokenizer.json)
|
| 61 |
+
uv run python scripts/train_tokenizer.py
|
| 62 |
+
```
|
| 63 |
|
| 64 |
+
### 2. Base Model Pretraining
|
| 65 |
+
The training loop features AdamW, Cosine Learning Rate decay with linear warmup, Gradient Accumulation, and `bfloat16` Mixed Precision.
|
| 66 |
+
|
| 67 |
+
```bash
|
| 68 |
+
uv run python -m emsyai.training.train
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
### 3. LoRA Instruction Fine-Tuning
|
| 72 |
+
A custom LoRA implementation targets all linear layers (Q, K, V, O, w1, w2, w3) to fine-tune the base model on a subset of CodeAlpaca.
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
# Download 20k CodeAlpaca instruction pairs
|
| 76 |
+
uv run python -m emsyai.training.download_alpaca
|
| 77 |
+
|
| 78 |
+
# Train the LoRA adapters
|
| 79 |
+
uv run python -m emsyai.training.finetune --steps 10000
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
### 4. Exporting to GGUF
|
| 83 |
+
We include a custom `export_gguf.py` script that merges the base weights with the LoRA matrices and exports the full PyTorch model directly to a `.gguf` file compatible with `llama.cpp`.
|
| 84 |
+
|
| 85 |
+
```bash
|
| 86 |
+
uv run python scripts/export_gguf.py
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
### 5. Chat Interface
|
| 90 |
+
You can interact with the instruction-tuned model via a command-line REPL. It implements KV caching, top-k/top-p sampling, and repetition penalties.
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
uv run python -m emsyai.chat_instruct --lora_checkpoint checkpoints_v2/lora/instruct_lora_step_10000.pt
|
| 94 |
+
```
|
| 95 |
|
| 96 |
+
## ๐ ๏ธ Verification & Benchmarking
|
| 97 |
+
- Run `scripts/verify_model.py` to cryptographically prove that the Causal Mask prevents future token leakage, and that the KV Cache accurately matches standard autoregressive generation.
|
| 98 |
+
- Run `uv run python -m emsyai.benchmark` to test the base model's syntax generation capabilities using Python's AST parser.
|