variations of beam search and sampling.