<s>
Byte	B-Algorithm
pair	I-Algorithm
encoding	I-Algorithm
(	O
BPE	O
)	O
or	O
digram	B-Algorithm
coding	I-Algorithm
is	O
a	O
simple	O
and	O
robust	O
form	O
of	O
data	B-General_Concept
compression	I-General_Concept
in	O
which	O
the	O
most	O
common	O
pair	O
of	O
contiguous	O
bytes	B-Application
of	O
data	O
in	O
a	O
sequence	O
are	O
replaced	O
with	O
a	O
byte	B-Application
that	O
does	O
not	O
occur	O
within	O
the	O
sequence	O
.	O
</s>
<s>
A	O
lookup	B-Data_Structure
table	I-Data_Structure
of	O
the	O
replacements	O
is	O
required	O
to	O
rebuild	O
the	O
original	O
data	O
.	O
</s>
<s>
The	O
algorithm	O
was	O
first	O
described	O
publicly	O
by	O
Philip	O
Gage	O
in	O
a	O
February	O
1994	O
article	O
"	O
A	O
New	O
Algorithm	O
for	O
Data	B-General_Concept
Compression	I-General_Concept
"	O
in	O
the	O
C	O
Users	O
Journal	O
.	O
</s>
<s>
A	O
variant	O
of	O
the	O
technique	O
has	O
shown	O
to	O
be	O
useful	O
in	O
several	O
natural	B-Language
language	I-Language
processing	I-Language
(	O
NLP	B-Language
)	O
domains	O
,	O
for	O
applications	O
such	O
as	O
tokenisation	B-Application
,	O
as	O
seen	O
in	O
Google	B-Application
's	I-Application
SentencePiece	O
and	O
OpenAI	O
's	O
GPT-3	B-General_Concept
.	O
</s>
<s>
Here	O
,	O
the	O
goal	O
is	O
not	O
data	B-General_Concept
compression	I-General_Concept
,	O
but	O
tokenisation	B-Application
of	O
text	O
in	O
a	O
given	O
language	O
to	O
produce	O
a	O
variable	O
sequence	O
of	O
terms	O
from	O
a	O
fixed-size	O
vocabulary	O
of	O
tokens	O
.	O
</s>
<s>
This	O
translation	O
of	O
text	O
into	O
tokens	O
can	O
be	O
found	O
by	O
variants	O
of	O
byte	B-Algorithm
pair	I-Algorithm
encoding	I-Algorithm
,	O
such	O
as	O
subword	O
units	O
.	O
</s>
<s>
Byte	B-Algorithm
pair	I-Algorithm
encoding	I-Algorithm
lends	O
itself	O
to	O
NLP	B-Language
tasks	O
due	O
to	O
its	O
simplicity	O
and	O
speed	O
;	O
BPE	O
is	O
suitably	O
effective	O
for	O
the	O
tokenisation	B-Application
of	O
terms	O
,	O
does	O
not	O
require	O
large	O
computational	O
overheads	O
,	O
and	O
remains	O
consistent	O
,	O
making	O
it	O
reliable	O
.	O
</s>
<s>
Byte	B-Algorithm
pair	I-Algorithm
encoding	I-Algorithm
operates	O
by	O
iteratively	O
replacing	O
the	O
most	O
common	O
contiguous	O
sequences	O
of	O
characters	O
in	O
a	O
target	O
piece	O
of	O
text	O
with	O
unused	O
'	O
placeholder	O
 '	O
bytes	B-Application
.	O
</s>
<s>
Decompression	O
can	O
be	O
performed	O
by	O
reversing	O
this	O
process	O
,	O
querying	O
known	O
placeholder	O
terms	O
against	O
their	O
corresponding	O
denoted	O
sequence	O
,	O
per	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
.	O
</s>
<s>
In	O
the	O
original	O
paper	O
,	O
this	O
lookup	B-Data_Structure
table	I-Data_Structure
is	O
encoded	O
and	O
stored	O
alongside	O
the	O
compressed	O
text	O
.	O
</s>
<s>
The	O
byte	B-Application
pair	O
"	O
aa	O
"	O
occurs	O
most	O
often	O
,	O
so	O
it	O
will	O
be	O
replaced	O
by	O
a	O
byte	B-Application
that	O
is	O
not	O
used	O
in	O
the	O
data	O
,	O
such	O
as	O
"	O
Z	O
"	O
.	O
</s>
<s>
Then	O
the	O
process	O
is	O
repeated	O
with	O
byte	B-Application
pair	O
"	O
ab	O
"	O
,	O
replacing	O
it	O
with	O
"	O
Y	O
"	O
:	O
</s>
<s>
The	O
only	O
literal	O
byte	B-Application
pair	O
left	O
occurs	O
only	O
once	O
,	O
and	O
the	O
encoding	O
might	O
stop	O
here	O
.	O
</s>
<s>
Alternatively	O
,	O
the	O
process	O
could	O
continue	O
with	O
recursive	O
byte	B-Algorithm
pair	I-Algorithm
encoding	I-Algorithm
,	O
replacing	O
"	O
ZY	O
"	O
with	O
"	O
X	O
"	O
:	O
</s>
<s>
This	O
data	O
cannot	O
be	O
compressed	O
further	O
by	O
byte	B-Algorithm
pair	I-Algorithm
encoding	I-Algorithm
because	O
there	O
are	O
no	O
pairs	O
of	O
bytes	B-Application
that	O
occur	O
more	O
than	O
once	O
.	O
</s>
