refactor language model generator to use language model class