Like all deep learning, ChatGPT makes statistical inference from big data. It interpolates into a multidimensional hyperspace that is partially filled but nonetheless mostly well sampled. If you write prompts based on that perspective, you can engineer very good responses.