SpinHash: An O(1) Encoder for Any Vocabulary

Jia Xu, Jinhua Wang, Constantin F. Aliferis


Abstract
The embedding table is a quiet ceiling of nearly every neural network model. Its size grows with the vocabulary, its rows are tied to a single modality, and unseen inputs require adding parameters. This makes the table prohibitively large at scale, impossible to share across modalities, and unable to represent new tokens without retraining.

We remove this ceiling with SpinHash, an O(1) encoder in the vocabulary size that stays constant at about 0.2M parameters regardless of how many tokens or modalities it serves. Instead of storing a vocabulary dependent table, SpinHash hashes each token into a compact spin code and decodes it with one shared feedforward network. Our hash is not merely a compression mechanism, but also defines the geometry of the representation space, realized by a similarity preserving Spin-SimHash and an antiferromagnetic Ising Spin-Repulse.

Across text, DNA, and clinical codes, SpinHash matches embedding tables with 17 to 283x fewer parameters, reaching parity on IMDB, AG-News, Yelp, and both clinical fusion tasks. For k=22 DNA, where 4^22 table entries are infeasible, SpinHash achieves 98.3% promoter accuracy, outperforming same-size HyenaDNA-tiny and the 1000x larger Nucleotide Transformer.

This work shows that representations need not be tied to a vocabulary, and that we can compute them once and reuse them across vocabularies, modalities, and domains.
Anthology ID:
2026.emnlp-main.574
Volume:
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
EMNLP
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
13165–13180
Language:
URL:
https://aclanthology.org/2026.emnlp-main.574/
DOI:
Bibkey:
Cite (ACL):
Jia Xu, Jinhua Wang, and Constantin F. Aliferis. 2026. SpinHash: An O(1) Encoder for Any Vocabulary. In Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing, pages 13165–13180, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
SpinHash: An O(1) Encoder for Any Vocabulary (Xu et al., EMNLP 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.emnlp-main.574.pdf