Loading...
Implement a single step of the Byte Pair Encoding (BPE) merge algorithm.
Given a list of tokens (strings) and a merge pair (two consecutive tokens to merge), scan through the token list and merge every adjacent occurrence of the pair into a single token.
Example:
Multiple occurrences should all be merged in a single pass (left to right).
l o w e r l o
lo w e r
["l", "o", "w", "e", "r"] and a merge pair: ("l", "o")("l", "o")"lo"["lo", "w", "e", "r"], which is then joined into a string to produce the output: lo w e r