To train ChatGPT, a large dataset of text is used to train the model. The model learns to predict the next word in a sentence based on the previous words. The model is then fine-tuned on a specific task such as conversation or text completion.