eyanchao commited on
Commit
c129370
Β·
verified Β·
1 Parent(s): ec166a5

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +43 -67
README.md CHANGED
@@ -7,110 +7,86 @@ library_name: pytorch
7
  tags:
8
  - text-generation
9
  - bilingual
10
- - character-level
11
  - transformer
12
  - reasoning
13
  - custom-architecture
14
- - gqa
15
  - flash-attention
16
  datasets:
17
  - eyanchao/echoic-data
18
  ---
19
 
20
- # Echoic-Lite
21
 
22
- **Bilingual (Chinese/English) character-level language model family β€” custom Transformer 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
- ## Models
27
 
28
- | Version | Params | Dim | Layers | Heads | KV Heads | Status |
29
- |---------|--------|-----|--------|-------|----------|--------|
30
- | **v29** | **~1.0B** | 1408 | 32 | 32 | 8 (GQA) | πŸƒ Training |
31
- | **v28** | ~480M | 1024 | 28 | 32 | β€” | βœ… Deployed |
32
- | v27 | ~200M | 768 | 20 | 24 | β€” | πŸ“¦ Archived |
33
- | v26 | ~60M | 512 | 14 | 16 | β€” | πŸ“¦ Archived |
34
 
35
- ## Architecture (v29)
36
 
37
  | Technique | Description |
38
  |-----------|-------------|
39
- | **GQA** | Grouped Query Attention (32Q / 8KV, ~30% VRAM saved) |
40
- | **QK-Norm** | RMSNorm on Q/K projections β€” training stability |
41
- | **Z-loss** | Logit L2 regularization β€” prevents explosion |
 
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 inductor disk cache |
46
  | **Layer-wise LR decay** | Higher layers learn slower (0.8Γ—) |
47
- | **Dynamic LR** | Auto-half on loss spikes |
48
 
49
- ## Training Data Mix
50
 
51
- | Task | Weight | Sources |
52
- |------|--------|---------|
53
- | Math | 40% | mathinstruct, school_math, math_large, math_sft |
54
- | Code | 20% | code_120k, code_large |
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
- ## Quick Start
60
 
61
  ```python
62
- import torch, os
63
  from huggingface_hub import hf_hub_download
64
 
65
- REPO = "eyanchao/echoic-lite"
66
-
67
- # Tokenizer
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
- ## Inference API
 
91
 
92
- ```
93
- POST https://eyanchao--echoic-generate.modal.run
94
- Body: {"prompt": "δ»Žε‰ζœ‰δΈ€δΈͺ", "max_tokens": 200}
 
95
  ```
96
 
97
  ## Files
98
 
99
  | File | Description |
100
  |------|-------------|
101
- | `v28-best-e15.pt` | v28 best (480M, deployed) |
102
- | `v28-final.pt` | v28 final weights |
103
- | `v29-best-e*.pt` | v29 checkpoints (1B, training) |
104
- | `bilingual-tokenizer.pt` | Tokenizer |
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
- Weight expansion from v26β†’v28. v29 trained from scratch with GQA architecture.
 
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.