无花果吃多了有什么坏处| 下饭是什么意思| 做梦梦见马是什么意思| pct是什么意思| 梦到和婆婆吵架是什么意思| 下雨天适合穿什么衣服| 家里狗死了预示着什么| 圆脸适合什么发型男| 二氧化碳分压高说明什么| ea是什么单位| 孙膑是什么学派| 吃什么补钙快| 转氨酶异常有什么症状| 心肌损伤是什么意思| 金字旁和什么有关| 蚯蚓用什么呼吸| 舌吻有什么好处| 虎头虎脑是什么生肖| 甲亢平时要注意什么| 才高八斗是什么生肖| 结肠炎吃什么药效果最好| 为什么要拔掉智齿| 为什么总是梦见一个人| 过敏性鼻炎吃什么药能快速缓解| 贵族是什么意思啊| ab什么意思| 舌苔发黑是什么原因| 忘忧草是什么意思| 排尿带血是什么原因| 旖旎风光是什么意思| 示字旁与什么有关| 造势是什么意思| 发烧输液输的是什么药| 怀孕前三个月吃什么好| 本事是什么意思| 清宫后需要注意什么| 志趣相投是什么意思| 呼吸内科主要看什么病| 数不胜数是什么生肖| 晚上十一点半是什么时辰| 出品人是干什么的| 吸氧机什么牌子好| 湿疹可以吃什么药| 红豆为什么代表相思| 什么是闺蜜| est是什么意思| 朗格手表什么档次| 压疮是什么| 维生素b吃多了有什么副作用| 什么时辰出生的人命好| a型血的孩子父母是什么血型| 男孩子送什么礼物| 大力丸是什么| 五行属木缺什么| 暑假让孩子学点什么好| 三白眼是什么意思| 女人手脚发热吃什么药| 为什么老是打喷嚏| 甘油三酯高吃什么食物降得快| 秦始皇的母亲叫什么名字| 磨牙吃什么药能治好| momax是什么牌子| vd是什么| 吃的少还胖什么原因| 腹泻恶心想吐是什么原因| b型血为什么叫贵族血| 中暑的症状是什么| 早射吃什么药可以调理| 船只是什么意思| 刻骨铭心是什么意思| 什么食物对肺有好处| 饱和什么意思| 土耳其烤肉是用什么肉| 清华大学校长什么级别| 心梗是什么症状| 幼儿贫血吃什么补血最快| 海纳百川什么意思| 翡翠和玉有什么不同| 西洋菜俗称叫什么| 海南简称是什么| 秋葵有什么功效| 座驾是什么意思| 神戳戳是什么意思| 八月二十六是什么星座| 核桃什么时候成熟| 坐久了脚肿是什么原因| 什么是2B铅笔| 屁股胀痛什么原因| 海绵是什么材料做的| 科技馆里面有什么| 身体游走性疼痛什么病| 生理期可以吃什么| 下一个台风什么时候来| 仲夏夜是什么时候| 胃受凉了吃什么药| gi值是什么意思| 1981年是什么年| 为什么要拔掉智齿| 翻车鱼为什么叫翻车鱼| 金玉良缘是什么生肖| 胎盘可以治什么病| b超检查前要注意什么| 天行健的下一句是什么| 糖丸是什么疫苗| 一条什么| 法官是干什么的| 睡眠不好用什么泡脚助于睡眠| 无名指麻木是什么原因| 伤食是什么意思| 梦到妈妈怀孕什么预兆| 喝什么养肝护肝| 为什么用英语怎么说| 竹棉和纯棉有什么区别| 番茄和蕃茄有什么区别| 手经常发麻是什么原因| 说话不清楚去医院挂什么科| cba什么时候开始比赛| 中午吃什么不会胖| 什么是企业年金| 祸起萧墙的萧墙指什么| 脖子上长个包挂什么科| 为什么会得阴虱| 美国为什么打朝鲜| 超声波是什么| 10086查话费发什么短信| 眉梢有痣代表什么| 什么叫滑精| 知了猴是什么东西| 怡字五行属什么的| 庚寅五行属什么| 14是什么意思| 身体突然消瘦是什么原因| 淋巴转移什么意思| 钙不能和什么一起吃| skp是什么品牌| 为什么出汗特别多| 七月22号是什么星座| 为什么特别招蚊子| 什么是gdp| 乌云为什么是黑色的| 葡萄上的白霜是什么| 来福是什么意思| 白化病是什么原因引起的| 笋壳鱼是什么鱼| loaf是什么意思| 辣木籽是什么| 什么东西倒立后会增加一半| 朴树是什么树| 郡肝是什么| 早上左眼跳是什么预兆| 装腔作势是什么意思| 阴干吃什么补雌激素| 玻尿酸面膜有什么功效| 15号来月经排卵期是什么时候| 硒是什么元素| 祎字五行属什么| 吃什么补气血最快最好| 1989年是什么蛇| 乳腺囊实性结节是什么意思| 1度房室传导阻滞是什么意思| 美人是什么生肖| 玛尼石是什么意思| 真菌涂片检查是查什么| 占有欲是什么意思| 大豆是什么豆| 痔疮是什么感觉| 95棉5氨纶是什么面料| 自给自足是什么意思| 985高校是什么意思| 荷花和睡莲有什么区别| 4月25号什么星座| 酒干倘卖无什么意思| 1939年中国发生了什么| 静五行属什么| 不自觉是什么意思| 吃什么减肥最快| 1953年属蛇的是什么命| 转注是什么意思| 旭五行属性是什么| 痔疮是什么意思| 定制和订制有什么区别| 吃了兔子肉不能吃什么| 多走路有什么好处| 间歇脉多见于什么病| 及是什么意思| 补办结婚证需要什么手续| 秉着是什么意思| 颈椎病吃什么药效果好| 私生是什么意思| 白血病是什么症状| burberry是什么档次| 为什么总是犯困| hrd是什么| 维生素b3又叫什么| afi是胎儿的什么意思| 买碗有什么讲究| 肺部占位性的病变指什么| 操姓氏读什么| 棉麻是什么面料| 肠粘连吃什么药| 晚的反义词是什么| 抑制是什么意思| 甲状腺肿是什么意思| 六三年属什么生肖| 乙酰氨基酚片是什么药| 基诺浦鞋属于什么档次| 子宫切除对女人有什么影响| 肝在什么位置图片| 沙悟净是什么生肖| 红花和藏红花有什么区别| 免贵姓是什么意思| 身体水肿是什么原因引起的| 肩膀发麻是什么原因| 记字五行属什么| 聊是什么意思| 妾是什么意思| 棒打鸳鸯什么意思| 白头翁代表什么生肖| 什么是公历年份| 片仔癀是什么| 肝内囊性灶什么意思| 枭神夺食会发生什么| 一月十二号是什么星座| 葛根是什么植物的根| 吃什么可以降胆固醇| 母女丼什么意思| 拉钩为什么要上吊| navy什么意思| 梦见下大雨是什么预兆| 头皮发红是什么原因| 腺肌症是什么意思| 势利是什么意思| 心律不齐吃什么食物好| ldpe是什么材料| 3月2号什么星座| 氯读什么拼音| 溥仪什么时候去世的| 为什么发烧| 骨髓穿刺是检查什么病| 脾肾阳虚吃什么中成药最好| 左氧氟沙星是什么药| 桃花灼灼什么意思| pc是什么| 心脏早搏是什么原因| 离岗是什么意思| 肝气郁结吃什么中药| 一纸空文是什么意思| 心肌缺血吃什么食物| 痈疽是什么意思| 鲁蛇是什么意思| 尿白细胞定量高是什么意思| 流鼻涕吃什么药好得快| 吃什么降尿酸最快| 丁克夫妻是什么意思| 世外桃源什么意思| 肚脐叫什么穴位| 肺气肿吃什么药最有效| 肺炎挂什么科| 出来混迟早要还的什么意思| 翡翠有什么作用与功效| 吃什么补硒最快最好| 十全十美指什么生肖| 四方八面是什么生肖| 百分点是什么意思| 百度Jump to content

中国公路学会养护与管理分会第七届学术年会即将召开

From Wikipedia, the free encyclopedia
(Redirected from Byte pair encoding)
百度 今年美债和美元的动态组合成为关键,美债收益率超预期上行、美元超预期强势的组合可能是国内利率最大的上行风险所在。

In computing, byte-pair encoding (BPE),[1][2] or digram coding,[3] is an algorithm, first described in 1994 by Philip Gage, for encoding strings of text into smaller strings by creating and using a translation table.[4] A slightly modified version of the algorithm is used in large language model tokenizers.

The original version of the algorithm focused on compression. It replaces the highest-frequency pair of bytes with a new byte that was not contained in the initial dataset. A lookup table of the replacements is required to rebuild the initial dataset. The modified version builds "tokens" (units of recognition) that match varying amounts of source text, from single characters (including single digits or single punctuation marks) to whole words (even long compound words).[5][6][7]

Original algorithm

[edit]

The original BPE algorithm operates by iteratively replacing the most common contiguous sequences of characters in a target text with unused 'placeholder' bytes. The iteration ends when no sequences can be found, leaving the target text effectively compressed. Decompression can be performed by reversing this process, querying known placeholder terms against their corresponding denoted sequence, using a lookup table. In the original paper, this lookup table is encoded and stored alongside the compressed text.

Example

[edit]

Suppose the data to be encoded is:[8]

aaabdaaabac

The byte pair "aa" occurs most often, so it will be replaced by a byte that is not used in the data, such as "Z". Now there is the following data and replacement table:

ZabdZabac
Z=aa

Then the process is repeated with byte pair "ab", replacing it with "Y":

ZYdZYac
Y=ab
Z=aa

The only literal byte pair left occurs only once, and the encoding might stop here. Alternatively, the process could continue with recursive byte-pair encoding, replacing "ZY" with "X":

XdXac
X=ZY
Y=ab
Z=aa

This data cannot be compressed further by byte-pair encoding because there are no pairs of bytes that occur more than once.

To decompress the data, simply perform the replacements in the reverse order.

Modified algorithm

[edit]

The original BPE algorithm is modified for use in language modeling, especially for large language models based on neural networks. Compared to the original BPE, the modified BPE does not aim to maximally compress text, but rather, to encode plaintext into "tokens", which are natural numbers.[9] All the unique tokens found in a corpus are listed in a token vocabulary, the size of which, in the case of GPT-3.5 and GPT-4, is 100256.[10]

The modified tokenization algorithm initially treats the set of unique characters as 1-character-long n-grams (the initial tokens). Then, successively, the most frequent pair of adjacent tokens is merged into a new, longer n-gram and all instances of the pair are replaced by this new token. This is repeated until a vocabulary of prescribed size is obtained. Note that new words can always be constructed from final vocabulary tokens and initial-set characters.[11]

This modified BPE approach has been extended from spoken language to sign language in recent years.[12]

Example

[edit]

Suppose we are encoding the previous example of "aaabdaaabac", with a specified vocabulary size of 6, then it would first be encoded as "0, 0, 0, 1, 2, 0, 0, 0, 1, 0, 3" with a vocabulary of "a=0, b=1, d=2, c=3". Then it would proceed as before, and obtain "4, 5, 2, 4, 5, 0, 3" with a vocabulary of "a=0, b=1, d=2, c=3, aa=4, ab=5".

So far this is essentially the same as before. However, if we only had specified a vocabulary size of 5, then the process would stop at vocabulary "a=0, b=1, d=2, c=3, aa=4", so that the example would be encoded as "4, 0, 1, 2, 4, 0, 1, 0, 3". Conversely, if we had specified a vocabulary size of 8, then it would be encoded as "7, 6, 0, 3", with a vocabulary of "a=0, b=1, d=2, c=3, aa=4, ab=5, aaab=6, aaabd=7". This is not maximally efficient, but the modified BPE does not aim to maximally compress a dataset, but aim to encode it efficiently for language model training.[13]

Byte-level BPE

[edit]

In the above example, the output of the BPE is a vocabulary, which can be used to encode any text that is written with the letters "abcd". It will not be able to encode text containing other symbols, such as "no". Even giving each of the 26 letters an entry in the vocabulary, since there are many languages in the world using many different scripts, inevitably some symbols would be unencodable by such a vocabulary.

One solution is to replace any unencodable symbol with a special symbol named UNK ("unknown").

The byte-level BPE is another approach. It simply converts the text into UTF-8 first, and treat it as a stream of bytes. This guarantees that any text encoded in UTF-8 can be encoded by the BPE. This has been used in BERT-like models like RoBERTa, BART, and DeBERTa, and GPT-like models like GPT-2.[14][15][16]

See also

[edit]

References

[edit]
  1. ^ Gage, Philip (1994). "A New Algorithm for Data Compression". The C User Journal.
  2. ^ "A New Algorithm for Data Compression". Dr. Dobb's Journal. 1 February 1994. Retrieved 10 August 2020.
  3. ^ Witten, Ian H.; Moffat, Alistair; Bell, Timothy C. (1994). Managing Gigabytes. New York: Van Nostrand Reinhold. ISBN 978-0-442-01863-4.
  4. ^ "Byte Pair Encoding". Archived from the original on 2025-08-06.
  5. ^ Sennrich, Rico; Birch, Alexandra; Haddow, Barry (2025-08-06). "Neural Machine Translation of Rare Words with Subword Units". arXiv:1508.07909 [cs.CL].
  6. ^ Brown, Tom B.; Mann, Benjamin; Ryde r, Nick; Subbiah, Melanie; Kaplan, Jared; Dhariwal, Prafulla; Neelakantan, Arvind; Shyam, Pranav; Sastry, Girish; Askell, Amanda; Agarwal, Sandhini (2025-08-06). "Language Models are Few-Shot Learners". arXiv:2005.14165 [cs.CL].
  7. ^ "google/sentencepiece". Google. 2025-08-06. Retrieved 2025-08-06.
  8. ^ Campesato, Oswald (2025-08-06). Large Language Models for Developers: A Prompt-based Exploration of LLMs. Walter de Gruyter GmbH. ISBN 978-1-5015-2095-2.
  9. ^ Zhang, Xiang; Cao, Juntai; You, Chenyu (2024). "Counting Ability of Large Language Models and Impact of Tokenization". arXiv:2410.19730 [cs.CL].
  10. ^ Raschka, Sebastian (2025-08-06). "Implementing A Byte Pair Encoding (BPE) Tokenizer From Scratch". Sebastian Raschka, PhD. Retrieved 2025-08-06.
  11. ^ Paa?, Gerhard; Giesselbach, Sven (2022). "Pre-trained Language Models". Foundation Models for Natural Language Processing. Artificial Intelligence: Foundations, Theory, and Algorithms. pp. 19–78. doi:10.1007/978-3-031-23190-2_2. ISBN 9783031231902.
  12. ^ Taro Miyazaki, Sihan Tan, Tsubasa Uchida, Hiroyuki Kaneko (May 25, 2024). "Sign Language Translation with Gloss Pair Encoding" (PDF). Proceedings of the 11th Workshop on the Representation and Processing of Sign Languages.{{cite journal}}: CS1 maint: multiple names: authors list (link)
  13. ^ Pai, Suhas (2025-08-06). Designing Large Language Model Applications: A Holistic Approach to LLMs. O'Reilly Media. ISBN 978-1-0981-5046-4.
  14. ^ "Byte-Pair Encoding tokenization". Hugging Face NLP Course. Retrieved 2025-08-06.
  15. ^ Y?ld?r?m, Sava?; Chenaghlu, Meysam Asgari (2025-08-06). Mastering Transformers: Build state-of-the-art models from scratch with advanced natural language processing techniques. Packt Publishing Ltd. ISBN 978-1-80107-889-4.
  16. ^ Wang, Changhan; Cho, Kyunghyun (2025-08-06). "Neural Machine Translation with Byte-Level Subwords". Proceedings of the AAAI Conference on Artificial Intelligence. 34 (5): 9154–9160. arXiv:1909.03341. doi:10.1609/aaai.v34i05.6451. ISSN 2374-3468.
上善若水是什么意思 小便发黄是什么症状 尿检是检查什么的 猫字五行属什么 血糖高可以吃什么主食
梦见割草是什么意思 正月十六是什么星座 婴儿第一次理发有什么讲究吗 老人头晕是什么原因引起的 转念是什么意思
雨像什么 吃什么药提高免疫力 处级上面是什么级别 钛色是什么颜色 什么是心脏病
魂牵梦绕是什么意思 em什么意思 什么叫转基因 头发不长是什么原因 你想成为什么样的人
八岁属什么生肖hcv8jop6ns0r.cn 肝结节是什么病严重吗hcv7jop9ns2r.cn ibm是什么96micro.com ab和o型血生的孩子是什么血型hcv8jop8ns1r.cn 互粉是什么意思hcv7jop7ns4r.cn
海绵体充血不足吃什么药hcv9jop3ns4r.cn 广西狗肉节是什么时候hcv9jop6ns0r.cn hpv是什么病hcv7jop9ns1r.cn 骨感是什么意思hcv7jop9ns7r.cn 官杀混杂是什么意思hcv8jop8ns9r.cn
发难是什么意思hcv8jop4ns0r.cn 滑肠是什么意思hcv8jop0ns7r.cn 排斥是什么意思96micro.com 追什么zhongyiyatai.com 曲高和寡什么意思hcv8jop2ns5r.cn
突然晕倒是什么原因造成的hcv7jop6ns3r.cn 天蝎座和什么座最配对hcv8jop9ns7r.cn 头疼喝什么饮料hcv7jop6ns1r.cn 4个火读什么hcv9jop4ns0r.cn 塔罗牌是什么hcv9jop2ns0r.cn
百度