Question 2
Consider the following code where a tokenizer is created using the BPE model:
from tokenizers import Tokenizerfrom tokenizers.models import BPEfrom tokenizers.trainers import BpeTrainerfrom tokenizers.normalizers import Lowercasefrom tokenizers.pre_tokenizers import Whitespace
data = ["existent", "non", "exist", "word"]
# Create a tokenizer with BPE model without specifying the unk_tokenmodel = BPE()tokenizer = Tokenizer(model)
# Normalizer and Pre-tokenizertokenizer.normalizer = Lowercase()tokenizer.pre_tokenizer = Whitespace()
# Train the tokenizertrainer = BpeTrainer(vocab_size=5000, special_tokens=["<s>", "</s>", "<pad>"])tokenizer.train_from_iterator(data, trainer)
# Access the tokenizer's vocabularyvocab = tokenizer.get_vocab()
# Test tokenization with a word not present in the vocabulary
tokens = tokenizer.encode("nonexistentword").tokensprint("Tokens:", tokens)Which of the following statements is correct about the tokenization output when the word "nonexistentword" is encountered?
The tokenizer will output the token [UNK] because "nonexistentword" is not in the vocabulary.
The tokenizer will output the word "nonexistentword" as a single token.
The tokenizer will output "non", "existent", "word" as separate tokens since it has split the word into known subwords.
The tokenizer will output "non", "exist", "ent", "word" as separate tokens since it has split the word into known subwords.
The tokenizer will output an error because "nonexistentword" is not present in the vocabulary and the unk_token was not defined.