# Using nucleus sampling and temperature at the same time

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-nucleus-sampling-and-temperature-at-the-same-time%2F44681%3E%5C
**Category:** Models\
**Created:** [June 27, 2023, 5:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-nucleus-sampling-and-temperature-at-the-same-time%2F44681 "2023-06-27T05:39:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![smfsamir](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@smfsamir](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsmfsamir)%5C
**Post date:** [June 27, 2023, 5:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-nucleus-sampling-and-temperature-at-the-same-time%2F44681%2F1 "2023-06-27T05:39:17Z")

</div>

Hi,

I have a finetuned FlanT5 model and I’m trying to use it for inference with the `model.generate` method. I’m inspecting the behaviour of decoding methods that alter the next-token probability distribution, specifically the `top_p` parameter (for nucleus sampling) and the `temperature` parameter. I was wondering what happens if I specify both `top_p` and `temperature`? Will it first flatten the distribution with a high temperature and then obtain the nucleus of this flattened distribution (i.e., temperature, then nucleus)? Or will it obtain the nucleus and then use the temperature to flatten the distribution (i.e., nucleus, then temperature). Or something else (e.g., only use nucleus, and ignore temperature, or vice versa).

Thank you!
