We first estimate the topic distribution for each document in training data, and assign those topic probabilities to each sentence, then, we train a topic-specific n-gram LM for each topic based on those topic probabilities.
the "bag-of-words" assumption is an unrealistic oversimplification in language model case because it ignores the order of words which is critical in estimating n-gram probabilities.