ChatGPT generally works by collecting data from varied sources on the internet. That is generally written by common people and further uses computing predictions to answer all questions given by the user. https://www.cromacampus.com/blogs/what-is-chatgpt-and-how-to-use-it/