Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Huggingeface model generator method do_sample parameter

What does do_sample parameter of the generate method of the Hugging face model do?

Generates sequences for models with a language modeling head. The method currently supports greedy decoding, multinomial sampling, beam-search decoding, and beam-search multinomial sampling.

do_sample (bool, optional, defaults to False) – Whether or not to use sampling; 
use greedy decoding otherwise.

When the Beam search length is 1, it can be called greedy. Does do_sample=False mean the same?

like image 841
mon Avatar asked Apr 09 '26 01:04

mon


1 Answers

If your do_sample=True, your generate method will use Sample Decoding. You can look at the different decoding strategies here. You can also play with the temperature parameter.

Now, if do_sample=False and num_beams=1, then your generate method will use greedy decoding.

like image 162
Sifat Muhammad Abdullah Avatar answered Apr 11 '26 02:04

Sifat Muhammad Abdullah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!