Since one-hot encoding uses hashing, there is a probability of collisions where different words are assigned the same index. The probability of collision increases with the vocabulary size. However, a larger vocabulary can also improve the representation of distinct words. Jason Brownlee suggests using a vocabulary size about 25% larger than the number of unique words to balance collision risk and representation quality. By increasing the vocabulary size in the provided code, the numerical representation of the text changes, resulting in different encoded values.Please refer this gist