Small speedup for text model sampling. (#14773)