# topK value not having effect in visualizing multiple completions

**URL:** <https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087>\
**Category:** Transformers in Practice\
**Tags:** week-module-1, course\
**Created:** [September 12, 2026, 12:14pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087 "2026-09-12T12:14:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piyush\_Raut](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/piyush_raut/32/164202_2.png) [@Piyush\_Raut](https://community.deeplearning.ai/u/Piyush_Raut)\
**Post date:** [September 12, 2026, 12:14pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/1 "2026-09-12T12:14:47Z")

</div>

In the **Transformers in Practice course** , I am at **Visualization 1.3: How Sampling Shapes Output**.

I don’t see any difference in the multiple-completion outputs when I set the temperature to 2 and Top-K to 1 or 5.

If Top-K is 1, it should produce the same result across all completions, as per my understanding so far. However, the outputs vary significantly and are not meaningful.

Is the visualization broken, or am I missing something?

---

<div class="post-metadata">

**Author:** ![reinoudbosch](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@reinoudbosch](https://community.deeplearning.ai/u/reinoudbosch)\
**Post date:** [September 12, 2026, 12:47pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/2 "2026-09-12T12:47:02Z")

</div>

Hi Piyush\_Raut,

This can depend on the prompt you are using. The default prompt that is provided leads to a very high probability for ‘The’ as the next token. You can also see this in the multiple-completion when you look at the probability.

See if you can use a prompt that allows for more variability in completion.

As an example, I used ‘How would you respond to a question on a forum?’ which led to very different completions with shifts in Temperature and Top-K.

---

<div class="post-metadata">

**Author:** ![Piyush\_Raut](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/piyush_raut/32/164202_2.png) [@Piyush\_Raut](https://community.deeplearning.ai/u/Piyush_Raut)\
**Post date:** [September 13, 2026, 1:46am UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/3 "2026-09-13T01:46:43Z")

</div>

Thank you! I can now see the difference between the Top-K = 5 and Top-K = 1 responses with different prompts.

However, I still don’t understand why I get different results in multiple-completions when I set **Temperature = 2** and **Top-K = 1**.

Wouldn’t Top-K = 1 restrict the sampling to just the single token with the highest probability? And since temperature doesn’t change the ranking of the tokens, shouldn’t the highest probability token always be selected?

attached image of temp:2, top-K:1 for the prompt:“How would you respond to a question on a forum?”

 ![image](https://global.discourse-cdn.com/dlai/original/3X/6/1/61cbe8c809c7977e807270156f73e109f5637058.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [September 13, 2026, 4:48am UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/4 "2026-09-13T04:48:48Z")

</div>

@Piyush_Raut

the different output after each completion of loop is because the model has randomness introduced probably, so for each loop the token selection is different for the prompt response. Randomness is introduced to avoid repetitive loop of model learning introducing randomness of selection of token in the given set of token, so if you had select top-k as 1 and temperature being 2; the temperature will become more flat and top-k although filtering the single token, for each loop, the randomness must have select any token in the given set of token which must have in the backend codes. this is a standard practice to avoid repetitive loop or token utilisation as the model wouldn’t learn anything with each loop without randomness.

Regards  
Dr. Deepti

---

<div class="post-metadata">

**Author:** ![Piyush\_Raut](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/piyush_raut/32/164202_2.png) [@Piyush\_Raut](https://community.deeplearning.ai/u/Piyush_Raut)\
**Post date:** [September 13, 2026, 11:37am UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/5 "2026-09-13T11:37:35Z")

</div>

Thanks for the reply. Just to make sure I understand, are you saying the backend isn’t actually enforcing the topk = 1 setting?

The way I see it is that with topk= 1, only a single token survives filtering ( 100% probability after renormalization), and since we do sampling after filtering, the choice of sampling strategy becomes irrelevant. whether it’s random sampling or greedy decoding, there’s only one token available to pick. temperature reshapes the distribution but can’t change which token is ranked #1.

---

<div class="post-metadata">

**Author:** ![reinoudbosch](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@reinoudbosch](https://community.deeplearning.ai/u/reinoudbosch)\
**Post date:** [September 13, 2026, 12:00pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/6 "2026-09-13T12:00:06Z")

</div>

Hi Piyush\_Raut,

When I set top-K to 1 I always get ‘When’ as the output token. Did you click reset?

---

<div class="post-metadata">

**Author:** ![Piyush\_Raut](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/piyush_raut/32/164202_2.png) [@Piyush\_Raut](https://community.deeplearning.ai/u/Piyush_Raut)\
**Post date:** [September 13, 2026, 12:39pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/7 "2026-09-13T12:39:03Z")

</div>

Thanks for checking! I think we might be testing different settings though. I am asking about temperature = 2 and topK = 1 set together.

Here’s what I noticed: with that combination, the “Choose Your Own Completion” block gives me “When” as the first token every time, even after multiple runs. But the “Multiple Completions” block still produces different outputs. So maybe that block isn’t applying topK (maybe a bug in that code).

Could you try that exact combination in the “Multiple Completions” block and see if you get “When” as first token in all ?

---

<div class="post-metadata">

**Author:** ![reinoudbosch](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@reinoudbosch](https://community.deeplearning.ai/u/reinoudbosch)\
**Post date:** [September 13, 2026, 3:38pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/8 "2026-09-13T15:38:59Z")

</div>

Here’s what I did and found just now.

- started up the notebook
- skipped the tour
- changed the prompt to: “How would you respond to a question on a forum?”
- moved the slider of the Temperature to 2.0
- moved the slider of Top-K to 1
- click Generate

This gives me ‘When’ with probability 46.3% and weight of 100.0%

- Then I clicked Run Trials

This gave me 8 trials, each of which predicting ‘When’

If you don’t want to restart the notebook, you have to click Reset. But this moves the sliders back to their original position, so you will have to tweak these back to the values you want. This is what I did before I responded to your previous post. This also gave me ‘When’ for both the distribution and the 8 trials.

---

<div class="post-metadata">

**Author:** ![Piyush\_Raut](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/piyush_raut/32/164202_2.png) [@Piyush\_Raut](https://community.deeplearning.ai/u/Piyush_Raut)\
**Post date:** [September 13, 2026, 4:23pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/9 "2026-09-13T16:23:01Z")

</div>

I am still getting same results, couldn’t find reset button. Attaching a screenshot of the same but it’s not needed to continue on this as my doubt is solved.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/d/c/dc065c0760c069eb2636a6d4ed53f6652b1212e5.png)

Thanks for running that detailed testing that it should be starting with “When” always . We can close this.  
Thanks again for confirming this.

---

<div class="post-metadata">

**Author:** ![reinoudbosch](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@reinoudbosch](https://community.deeplearning.ai/u/reinoudbosch)\
**Post date:** [September 13, 2026, 4:51pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/10 "2026-09-13T16:51:11Z")

</div>

The Run Trials button changes into a Reset button.

Anyway, thanks for your questions which may be helpful for others taking the course!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/dlai/original/1X/7ffdac4759e95c8945939943bd85b8aca342d961.png) [@system](https://community.deeplearning.ai/u/system)\
**Post date:** [October 12, 2026, 12:15pm UTC](https://community.deeplearning.ai/t/topk-value-not-having-effect-in-visualizing-multiple-completions/895087/11 "2026-10-12T12:15:04Z")

</div>

This topic was automatically closed after 30 days. New replies are no longer allowed.
