First of all, not words but tokens. Most large language models these days use a subword tokenizer to limit the potential size of the vocabulary and avoiding out-of-vocabulary issues.
Using one hot encoding or bag of words is something completely different, for different purposes or architectures. I encourage you to follow the course 16 to better understand how these things work.