They don't "know" anything. Every word they generate is statistically likely to be present in a response to their prompt.