Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -7,110 +7,86 @@ library_name: pytorch
|
|
| 7 |
tags:
|
| 8 |
- text-generation
|
| 9 |
- bilingual
|
| 10 |
-
-
|
| 11 |
- transformer
|
| 12 |
- reasoning
|
| 13 |
- custom-architecture
|
| 14 |
-
-
|
| 15 |
- flash-attention
|
| 16 |
datasets:
|
| 17 |
- eyanchao/echoic-data
|
| 18 |
---
|
| 19 |
|
| 20 |
-
# Echoic
|
| 21 |
|
| 22 |
-
**Bilingual (Chinese/English)
|
| 23 |
|
| 24 |
-
No HuggingFace Transformers dependency
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
| Version | Params | Dim | Layers | Heads | KV Heads | Status |
|
| 29 |
-
|---------|--------|-----|--------|-------|----------|--------|
|
| 30 |
-
| **
|
| 31 |
-
|
|
| 32 |
-
|
|
| 33 |
-
| v26 | ~60M | 512 | 14 | 16 | β | π¦ Archived |
|
| 34 |
|
| 35 |
-
## Architecture (
|
| 36 |
|
| 37 |
| Technique | Description |
|
| 38 |
|-----------|-------------|
|
| 39 |
-
| **
|
| 40 |
-
| **
|
| 41 |
-
| **
|
|
|
|
| 42 |
| **SDPA** | PyTorch fused scaled_dot_product_attention |
|
| 43 |
-
| **RoPE + SwiGLU + RMSNorm** | Llama-style architecture |
|
|
|
|
| 44 |
| **Gradient checkpointing** | Per-layer activation recompute |
|
| 45 |
-
| **torch.compile** | JIT with
|
| 46 |
| **Layer-wise LR decay** | Higher layers learn slower (0.8Γ) |
|
| 47 |
-
| **Dynamic LR** | Auto-half on loss spikes |
|
| 48 |
|
| 49 |
-
## Training
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
| Encyclopedia | 25% | zh-wiki (5 partitions) |
|
| 56 |
-
| Stories | 15% | TinyStories ZH/EN, story_instruct, story_punct |
|
| 57 |
-
| Identity | SFT | Custom dialogs Γ 50 |
|
| 58 |
|
| 59 |
-
##
|
| 60 |
|
| 61 |
```python
|
| 62 |
-
import torch,
|
| 63 |
from huggingface_hub import hf_hub_download
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
tok = torch.load(
|
| 69 |
-
hf_hub_download(REPO, "bilingual-tokenizer.pt"),
|
| 70 |
-
map_location="cpu", weights_only=False
|
| 71 |
-
)
|
| 72 |
-
stoi, itos = tok.stoi, tok.itos
|
| 73 |
-
|
| 74 |
-
# v28 480M (dim=1024, layers=28, heads=32)
|
| 75 |
-
ckpt = torch.load(
|
| 76 |
-
hf_hub_download(REPO, "v28-best-e15.pt"),
|
| 77 |
-
map_location="cpu", weights_only=False
|
| 78 |
-
)
|
| 79 |
-
# See echoic_modal.py for full EchoicLM class definition
|
| 80 |
-
|
| 81 |
-
def encode(s): return [stoi.get(ord(c), 0) for c in s]
|
| 82 |
-
def decode(ids): return "".join(itos.get(k, "?") for k in ids)
|
| 83 |
-
|
| 84 |
-
prompt = "<|user|>δ½ ζ―θ°<|assistant|>"
|
| 85 |
-
x = torch.tensor([encode(prompt)], dtype=torch.long)
|
| 86 |
-
out = model.generate(x, max_new_tokens=100, temperature=0.7, top_k=40)
|
| 87 |
-
print(decode(out[0].tolist()))
|
| 88 |
-
```
|
| 89 |
|
| 90 |
-
#
|
|
|
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
| 95 |
```
|
| 96 |
|
| 97 |
## Files
|
| 98 |
|
| 99 |
| File | Description |
|
| 100 |
|------|-------------|
|
| 101 |
-
| `
|
| 102 |
-
| `
|
| 103 |
-
| `
|
| 104 |
-
| `
|
| 105 |
-
|
| 106 |
-
## Data
|
| 107 |
-
|
| 108 |
-
[eyanchao/echoic-data](https://huggingface.co/datasets/eyanchao/echoic-data)
|
| 109 |
|
| 110 |
## Evolution
|
| 111 |
|
| 112 |
```
|
| 113 |
-
v26 60M β v27 200M β v28 480M β v29 1B β ...
|
|
|
|
| 114 |
```
|
| 115 |
|
| 116 |
-
|
|
|
|
| 7 |
tags:
|
| 8 |
- text-generation
|
| 9 |
- bilingual
|
| 10 |
+
- BPE
|
| 11 |
- transformer
|
| 12 |
- reasoning
|
| 13 |
- custom-architecture
|
| 14 |
+
- GQA
|
| 15 |
- flash-attention
|
| 16 |
datasets:
|
| 17 |
- eyanchao/echoic-data
|
| 18 |
---
|
| 19 |
|
| 20 |
+
# Echoic
|
| 21 |
|
| 22 |
+
**Bilingual (Chinese/English) language model β custom Transformer architecture trained from scratch by [eyanchao](https://huggingface.co/eyanchao).**
|
| 23 |
|
| 24 |
+
No HuggingFace Transformers dependency. Pure PyTorch with SDPA, GQA, QK-Norm, Z-loss.
|
| 25 |
|
| 26 |
+
## Current Model
|
| 27 |
|
| 28 |
+
| Version | Params | Dim | Layers | Heads | KV Heads | Tokenizer | Status |
|
| 29 |
+
|---------|--------|-----|--------|-------|----------|-----------|--------|
|
| 30 |
+
| **v30** | **~1.1B** | 1408 | 32 | 32 | 8 (GQA) | BPE 32k | π Training |
|
| 31 |
+
| ~~v28~~ | ~~480M~~ | ~~1024~~ | ~~28~~ | ~~32~~ | β | ~~char-level~~ | β Retired |
|
| 32 |
+
| ~~v29~~ | ~~1.0B~~ | ~~1408~~ | ~~32~~ | ~~32~~ | 8 (GQA) | ~~char-level~~ | β Retired |
|
|
|
|
| 33 |
|
| 34 |
+
## Architecture (v30)
|
| 35 |
|
| 36 |
| Technique | Description |
|
| 37 |
|-----------|-------------|
|
| 38 |
+
| **BPE Tokenizer** | SentencePiece 32k vocab β compresses Chinese 3:1 |
|
| 39 |
+
| **GQA** | Grouped Query Attention (32Q / 8KV heads) |
|
| 40 |
+
| **QK-Norm** | RMSNorm on Q/K projections |
|
| 41 |
+
| **Z-loss** | Logit L2 regularization |
|
| 42 |
| **SDPA** | PyTorch fused scaled_dot_product_attention |
|
| 43 |
+
| **RoPE + SwiGLU + RMSNorm** | Llama-style pre-norm architecture |
|
| 44 |
+
| **seq_len 512** | Long context for CoT reasoning |
|
| 45 |
| **Gradient checkpointing** | Per-layer activation recompute |
|
| 46 |
+
| **torch.compile** | JIT with TF32 precision + inductor cache |
|
| 47 |
| **Layer-wise LR decay** | Higher layers learn slower (0.8Γ) |
|
| 48 |
+
| **Dynamic LR** | Auto-half on consecutive loss spikes |
|
| 49 |
|
| 50 |
+
## Training
|
| 51 |
|
| 52 |
+
- **Platform**: Modal (serverless A100 40GB)
|
| 53 |
+
- **Data**: [eyanchao/echoic-data](https://huggingface.co/datasets/eyanchao/echoic-data) β 18 files, multi-task mixture
|
| 54 |
+
- Math 40% | Code 20% | Encyclopedia 25% | Stories 15% | Identity SFT
|
| 55 |
+
- **Checkpointing**: Volume + HF Hub dual backup, auto-resume
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
## Usage
|
| 58 |
|
| 59 |
```python
|
| 60 |
+
import torch, sentencepiece as spm
|
| 61 |
from huggingface_hub import hf_hub_download
|
| 62 |
|
| 63 |
+
# Load BPE tokenizer
|
| 64 |
+
sp = spm.SentencePieceProcessor()
|
| 65 |
+
sp.load(hf_hub_download("eyanchao/echoic-lite", "bpe_tokenizer.model"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
# Model: EchoicLM_1B (dim=1408, layers=32, heads=32, kv_heads=8, seq_len=512)
|
| 68 |
+
# See echoic_v30_bpe.ipynb for full class definition
|
| 69 |
|
| 70 |
+
def generate(prompt, model, max_tokens=200, temp=0.8, top_k=50):
|
| 71 |
+
x = torch.tensor([sp.encode(prompt)], dtype=torch.long)
|
| 72 |
+
out = model.generate(x, max_new_tokens=max_tokens, temperature=temp, top_k=top_k)
|
| 73 |
+
return sp.decode(out[0].tolist())
|
| 74 |
```
|
| 75 |
|
| 76 |
## Files
|
| 77 |
|
| 78 |
| File | Description |
|
| 79 |
|------|-------------|
|
| 80 |
+
| `bpe_tokenizer.model` | BPE SentencePiece model (32k vocab) |
|
| 81 |
+
| `bpe_tokenizer.vocab` | BPE vocabulary |
|
| 82 |
+
| `v30-best-e*.pt` | Training checkpoints |
|
| 83 |
+
| `v30-final.pt` | Final weights (after training) |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
## Evolution
|
| 86 |
|
| 87 |
```
|
| 88 |
+
v26 60M β v27 200M β v28 480M β v29 1B β v30 BPE 1B β ...
|
| 89 |
+
β current
|
| 90 |
```
|
| 91 |
|
| 92 |
+
v26-v29 were character-level (98 vocab). v30 switches to BPE 32k vocab with seq_len 512 for serious reasoning capability.
|