TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Can tokenizers go from fixed length tokens to varying length?

3 点作者 jinen839 个月前
I am going through a workshop on building LLM grounds up. While I am studying tokenizers like BPE - I was curious why not use ideas from encoding techniques like huffman and make better optimized encoders. So a token like '.' also has same sie token as the word 'Algorithm'. Their frequency of occurence and their size could save us some GPUs?

2 条评论

PaulHoule9 个月前
The token number is the index for an embedding. If there are 50,000 distinct tokens then there are 50,000 different embedding that could be presented to the input of the neural networks. I suppose you could compress a list of tokens with Huffman or gzip or some similar algorithm but so far as the neural network one token is one slot of input to the network so you wouldn’t save anything once you got into the network.
pizza9 个月前
In a way, some things like this are possible&#x2F;have been explored.<p>In Huffman coding, the code length is log2(length of path in binary tree to x) ~ log2(1&#x2F;p(x)).<p>BPE works by combining the most frequent pair of adjacent tokens into a new token. So generally speaking, the most frequent token end up being earliest in the vocab, having a lower index. The number of bits to encode that index is log2(i(x)). In theory if you could have variable width int indices, then shorter indices would correspond with the more frequent tokens, so log2(i(x)) would correlate somewhat with log2(1&#x2F;p(x)) and you would end up getting some compression.<p>Finally, it&#x27;s also worth mentioning that somebody did try doing an LLM over entropy compressed tokens - there were some compute efficiency gains, but it didn&#x27;t really help language modeling:<p><i>In this paper, we explore the idea of training large language models (LLMs) over highly compressed text. While standard subword tokenizers compress text by a small factor, neural text compressors can achieve much higher rates of compression. If it were possible to train LLMs directly over neurally compressed text, this would confer advantages in training and serving efficiency, as well as easier handling of long text spans. The main obstacle to this goal is that strong compression tends to produce opaque outputs that are not well-suited for learning. In particular, we find that text naïvely compressed via Arithmetic Coding is not readily learnable by LLMs. To overcome this, we propose Equal-Info Windows, a novel compression technique whereby text is segmented into blocks that each compress to the same bit length. Using this method, we demonstrate effective learning over neurally compressed text that improves with scale, and outperforms byte-level baselines by a wide margin on perplexity and inference speed benchmarks. While our method delivers worse perplexity than subword tokenizers for models trained with the same parameter count, it has the benefit of shorter sequence lengths. Shorter sequence lengths require fewer autoregressive generation steps, and reduce latency. Finally, we provide extensive analysis of the properties that contribute to learnability, and offer concrete suggestions for how to further improve the performance of high-compression tokenizers.</i><p><a href="https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;2404.03626" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;2404.03626</a>
评论 #41488867 未加载