Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- tokenizer
|
| 5 |
+
- bpe
|
| 6 |
+
- shell
|
| 7 |
+
- code
|
| 8 |
+
- chatml
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
datasets:
|
| 11 |
+
- bigcode/the-stack-dedup
|
| 12 |
+
- m-a-p/CodeFeedback-Filtered-Instruction
|
| 13 |
+
- HuggingFaceH4/helpful-instructions
|
| 14 |
+
- HuggingFaceFW/fineweb
|
| 15 |
+
- Magpie-Align/Magpie-Reasoning-150K
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# DwarfGoToken
|
| 19 |
+
|
| 20 |
+
A compact **BPE tokenizer** (8,192 tokens) designed for tiny language models that need to understand **shell commands, code snippets, and ChatML-formatted conversations**. Built on top of a custom Go pre‑tokenizer that keeps critical shell tokens (`grep`, `chmod`, `2>&1`, `-rf`, …) atomic, avoiding the fragmentation that kills performance on CPU-bound inference.
|
| 21 |
+
|
| 22 |
+
## Why 8,192 tokens?
|
| 23 |
+
|
| 24 |
+
For a small LM (<20M parameters), a large vocabulary (e.g., 64K) wastes the majority of the model’s parameters on the embedding matrix. With `d_model=256`, the embedding here accounts for only **2.1M parameters (~14%)** — the rest goes into the transformer layers, where it matters most.
|
| 25 |
+
|
| 26 |
+
## Corpus
|
| 27 |
+
|
| 28 |
+
| Source | Domain | Lines |
|
| 29 |
+
|--------|--------|-------|
|
| 30 |
+
| `bigcode/the-stack-dedup/shell` | Shell | 1,500,000 |
|
| 31 |
+
| `bigcode/the-stack-dedup/batchfile` | Batch | 500,000 |
|
| 32 |
+
| `bigcode/the-stack-dedup/python` | Python | 1,000,000 |
|
| 33 |
+
| `bigcode/the-stack-dedup/c` | C | 500,000 |
|
| 34 |
+
| `m-a-p/CodeFeedback-Filtered-Instruction` | Code+Instructions | 200,000 |
|
| 35 |
+
| `HuggingFaceH4/helpful-instructions` | English instructions | 150,000 |
|
| 36 |
+
| `HuggingFaceFW/fineweb/sample-10BT` | Web English | 300,000 |
|
| 37 |
+
| `Magpie-Align/Magpie-Reasoning-150K` | Chain-of-Thought | 200,000 |
|
| 38 |
+
|
| 39 |
+
**Total:** 4,251,427 lines (3.5 GB) — 47% Shell, 40% Code, 9.5% EN, 3.5% CoT.
|
| 40 |
+
|
| 41 |
+
## Special tokens (all atomic)
|
| 42 |
+
|
| 43 |
+
`<s>`, `</s>`, `<unk>`, `<pad>`, `<|system|>`, `<|user|>`, `<|assistant|>`, `<|end|>`, `<|thinking|>`, `<|/thinking|>`, plus **54 Go‑pre‑tokenizer tokens** (e.g., `grep`, `chmod`, `2>&1`, `&&`, `>>`, `-rf`, `--help`).
|
| 44 |
+
|
| 45 |
+
## Quick test
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoTokenizer
|
| 49 |
+
tok = AutoTokenizer.from_pretrained("ThingAI/DwarfGoToken")
|
| 50 |
+
|
| 51 |
+
# Shell commands stay atomic
|
| 52 |
+
tok.tokenize("find /var/log -name '*.gz' | xargs rm -rf")
|
| 53 |
+
# → ['find', '/', 'var', '/', 'log', '-n', 'ame', "'", '*.', 'gz', "'", '|', 'xargs', 'rm', '-rf']
|
| 54 |
+
|
| 55 |
+
# ChatML template
|
| 56 |
+
tok.tokenize("<|user|>\nCosa fa grep?\n<|end|>\n<|assistant|>\n...")
|
| 57 |
+
# → ['<|user|>', 'C', 'os', 'a', 'fa', 'grep', '?', '<|end|>', '<|assistant|>', '...']
|
| 58 |
+
```
|
| 59 |
+
## Usage
|
| 60 |
+
```python
|
| 61 |
+
from transformers import AutoTokenizer
|
| 62 |
+
tokenizer = AutoTokenizer.from_pretrained("ThingAI/DwarfGoToken")
|
| 63 |
+
```
|
| 64 |
+
## Intended use
|
| 65 |
+
*This tokenizer was built to pair with tiny LMs (~10–20M parameters) specialised in command‑line assistance, shell scripting, or code generation. It’s the companion of the Dwarf model family by ThingsAI.*
|
| 66 |
+
## License
|
| 67 |
+
**Apache 2.0** — *use it, modify it, ship it.*
|