A beginning-of-sequence token marks the start of a sequence. In generation, it prompts the decoder to produce a suitable first token. Common spellings include `<SOS>` and `<s>`. section 9.2.3
For translation, register the marker as a special token with the tokenizer. Choose a spelling that does not occur as ordinary text in the dataset. An end-of-sequence token serves a different purpose: it tells the decoder when to stop generating. section 9.2.3
>>> SRC = 'en' #1 >>> TGT = 'de' #2 >>> SOS, EOS = '<s>', '</s>' >>> PAD, UNK, MASK = '<pad>', '<unk>', '<mask>' >>> SPECIAL_TOKS = [SOS, PAD, EOS, UNK, MASK] >>> VOCAB_SIZE = 10_000 ... >>> from tokenizers import ByteLevelBPETokenizer #3 >>> tokenize_src = ByteLevelBPETokenizer() >>> tokenize_src.train_from_iterator( ... [x[SRC] for x in sents['train']['translation']], ... vocab_size=10000, min_frequency=2, ... special_tokens=SPECIAL_TOKS) >>> PAD_IDX = tokenize_src.token_to_id(PAD) ... >>> tokenize_tgt = ByteLevelBPETokenizer() >>> tokenize_tgt.train_from_iterator( ... [x[TGT] for x in sents['train']['translation']], ... vocab_size=10000, min_frequency=2, ... special_tokens=SPECIAL_TOKS) >>> assert PAD_IDX == tokenize_tgt.token_to_id(PAD)
The tokenizer setup registers `<s>` alongside end, padding, unknown, and mask tokens for separate source and target languages. section 9.2.3


