Generative AI works by using language modeling to predict the next word in a sequence of words.Language modeling is a core task in NLP (Natural Language Processing).The language model predicts the next words along with their probability of occurrence.Training the language model involves counting the occurrence of certain words together to determine their probability.