ScribeTokens: Fixed-Vocabulary Tokenization of Digital Ink
Organizations: Independent Researcher
Abstract
Digital ink -- the coordinate stream captured from stylus or touch input -- lacks a unified representation. Continuous vector representations produce long sequences and suffer from training instability, while existing token representations require large vocabularies, face out-of-vocabulary issues, and underperform vectors on recognition. We propose ScribeTokens, a tokenization that decomposes pen movement into unit pixel steps. Together with two pen-state tokens, this fixed 10-token base vocabulary suffices to represent any digital ink and enables aggressive BPE compression. On handwritten text generation, ScribeTokens dramatically outperforms vectors (17.33% vs. 70.29% CER), showing tokens are far more effective for generation. On recognition, ScribeTokens is the only token representation to outperform vectors without pretraining. We further introduce next-ink-token prediction as a self-supervised pretraining strategy, which consistently improves recognition across all token-based models and accelerates convergence by up to 83x. With pretraining, ScribeTokens achieves the best recognition results across all representations on both datasets (8.27% CER on IAM, 9.83% on DeepWriting).
Figures & tables
| Representation | Value |
|---|---|
| Digital Ink | \color[rgb]{0,0,1}((0,0),(1,0)) , \color[rgb]{1,0,0}((2,1),(4,-1)) |
| Visualization | |
| Point-3 | \color[rgb]{0,0,1}(1,0,1) , \color[rgb]{0.5,0.5,0.5}(1,1,0) , \color[rgb]{1,0,0}(2,-2,1) |
| Point-5 | \color[rgb]{0,0,1}(1,0,1,0,0) , \color[rgb]{0.5,0.5,0.5}(1,1,0,1,0) , \color[rgb]{1,0,0}(2,-2,0,0,1) |
| AbsTokens | [(0, 0)] , [(1, 0)] , [UP] , [(2, 1)] , [(4, -1)] , [UP] |
| RelTokens | [(1, 0)] , [UP] , [(1, 1)] , [(2, -2)] , [UP] |
| IAM | DeepWriting | ||||
| Method | CER (%) | Acc (%) | CER (%) | Acc (%) | |
| Point-5 | |||||
| +PT | (+4.19) | (-12.45) | (-0.69) | (+1.19) | |
| RelTokens | |||||
| +PT | (-3.53) | (+5.65) | (-0.73) | (+1.13) | |
| TextTokens | |||||
| IAM | DeepWriting | ||||
| Method | CER (%) | Acc (%) | CER (%) | Acc (%) | |
| Point-5 | |||||
| +PT | (-53.46) | (+15.93) | (+12.48) | (-19.85) | |
| RelTokens | 12.75 | 73.04 | |||
| +PT | (-13.96) | (+15.90) | (+0.23) | (-0.56) | |
| TextTokens | |||||
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Architecture | |
|---|---|
| Model type | Decoder-only Transformer (LLaMA-style) |
| Parameters | 34 M (token-based) / ${\sim}$21 M (Point-5) |
| Layers | |
| Attention heads | |
| Hidden dimension | |
| Positional encoding | RoPE [ 33 ] |
| IAM | DeepWriting | |||||||
|---|---|---|---|---|---|---|---|---|
| Method | PT Ep. | No PT | +PT | Spd. | PT Ep. | No PT | +PT | Spd. |
| Point-5 | – | – | – | – | ||||
| RelTokens | ||||||||
| TextTokens | 5.0 | |||||||
| ScribeTokens (Ours) | 21.4 | |||||||
| IAM | DeepWriting | |||||||
|---|---|---|---|---|---|---|---|---|
| Method | PT Ep. | No PT | +PT | Spd. | PT Ep. | No PT | +PT | Spd. |
| Point-5 | – | – | ||||||
| RelTokens | 5.4 | |||||||
| TextTokens | ||||||||
| ScribeTokens (Ours) | 83.0 | |||||||
Online Handwriting Recognition
Online Handwriting Recognition turns time-ordered pen movements or sensor signals into characters and words.
See all 18 papers