Temperature, top-p nucleus sampling, top-k, repetition penalty, frequency penalty, presence penalty, max tokens, and stop sequences.
Key vocabulary
Temperature — controls randomness; low values (e.g., 0.1) make output more deterministic, high values (e.g., 1.2) make it more creative and varied.
Top-p (nucleus sampling) — restricts sampling to the smallest set of tokens whose cumulative probability exceeds p; balances diversity and coherence.
Top-k sampling — restricts sampling to the k most probable next tokens at each step.
Repetition penalty — reduces the probability of tokens that have already appeared in the output, discouraging repetitive text.
Stop sequences — strings that cause the model to halt generation when encountered (e.g., "\n\n", "END").
0 / 14 completed
1 / 14
A colleague sets temperature = 0.1 for a code generation task. What effect does this have?
Temperature scales the logits before the softmax step. A low temperature (near 0) sharpens the distribution, making the model almost always pick the highest-probability token — producing consistent, predictable output. This is ideal for code generation, data extraction, and structured tasks. High temperature (above 1) flattens the distribution, encouraging more diverse and creative but potentially less accurate responses.
2 / 14
What does top-p = 0.9 (nucleus sampling) mean in practice?
Top-p nucleus sampling (Holtzman et al., 2020) dynamically adjusts the candidate set. With top-p = 0.9, the model sorts tokens by probability and keeps adding them until the cumulative probability hits 0.9, then samples from that nucleus. This adapts to the model's confidence: when it is very sure, only a few tokens form the nucleus; when uncertain, more tokens are included.
3 / 14
A developer sets a high repetition penalty. What problem are they solving?
A repetition penalty discounts the probability of tokens that have already appeared in the generated text. This prevents the degenerate "looping" behaviour where models get stuck repeating the same phrase. The frequency penalty and presence penalty in the OpenAI API are variants: frequency penalty scales with how often a token has appeared; presence penalty applies a flat discount to any token seen at least once.
4 / 14
What are stop sequences used for in LLM API calls?
Stop sequences are strings you pass in the API call (e.g., stop=["\n\n", "User:"]). When the model generates one of these strings, generation halts immediately. They are critical for structured output tasks: for example, stopping at "\n" to get a single-line completion, or stopping at "```" to close a code block. They complement max_tokens for output length control.
5 / 14
How does top-k sampling differ from top-p (nucleus) sampling?
Top-k keeps only the k most probable tokens regardless of their probability values — so if k=40, you always get exactly 40 candidates. Top-p adapts: if the model is very confident, the nucleus might contain only 3 tokens; if uncertain, it might include 200. In practice, many systems combine both (e.g., top-k=40 AND top-p=0.9), applying whichever is more restrictive.
6 / 14
Sarah: 'I'm using a temperature of 0.1 for this code generation model. It's producing incredibly consistent output – almost like it's always generating the exact same thing! What's going on here?'. Which statement best explains Sarah's observation?
Lowering the temperature in a sampling process reduces randomness. This means the model will consistently favor the most probable tokens at each step, leading to predictable and repetitive output. A higher temperature introduces more variation, while a temperature of 0 effectively removes all randomness, resulting in the same token being selected repeatedly.
7 / 14
David writes: 'I'm using top-p sampling with a value of 0.9. I've noticed that the model sometimes generates outputs that feel a little…unfocused. It keeps jumping between different ideas.' What is David likely encountering, and how does top-p relate to this?
Top-p (nucleus sampling) selects tokens based on their cumulative probability. A value of 0.9 means that the model will consider only the smallest set of tokens whose probabilities add up to 0.9. This dynamic adjustment can lead to context shifts if the model starts considering less relevant tokens as it progresses, resulting in unfocused outputs. The key is its adaptive nature.
8 / 14
John: 'I'm using a temperature of 0.7 for this LLM. The outputs are pretty diverse and creative—great for brainstorming! But sometimes they're just completely nonsensical.' What does the 'temperature' parameter primarily control in this context?
Temperature directly affects the randomness of the LLM's output. A lower value (like 0.7) makes the model more deterministic and predictable, focusing on the most likely tokens. Conversely, a higher temperature introduces more diversity and unpredictability, which can lead to creative but potentially nonsensical results.
9 / 14
Maria writes in a Slack channel: 'I'm experimenting with top_p=0.8 for this text generation task. I've noticed some really interesting and nuanced responses, but occasionally the output feels a bit… disjointed.' What is Maria most likely observing about the effect of using top_p?
top_p (nucleus sampling) dynamically adjusts the probability distribution based on cumulative probability. It considers only the tokens whose probabilities add up to 0.8, effectively pruning less likely options. This leads to a balance between diversity and coherence – allowing for richer outputs than strict greedy decoding but potentially introducing some disjointedness if the chosen sequence isn't perfectly aligned.
10 / 14
During a code review of an LLM-generated function, Liam notes the following: 'The model consistently returns the same response to slightly different prompts. This is highly predictable and doesn't seem very flexible.' Which sampling parameter setting most likely contributed to this observed behavior?
A low repetition penalty allows the model to repeat previously generated tokens more frequently, leading to predictable and often identical outputs when prompted with similar inputs. Higher temperatures introduce more randomness, but a very low repetition penalty overrides this effect. Setting top-p close to 1.0 ensures that only the most probable next token is considered.
11 / 14
Alex is adjusting parameters for a text generation API call and wants to encourage more diverse output while still avoiding completely nonsensical results. He increases the 'temperature' parameter. What is the primary effect of this change?
Increasing the temperature parameter in an LLM API call boosts randomness. A higher temperature makes the model more willing to sample from a wider range of possible next tokens, even if those tokens are less probable. This results in greater diversity but also increases the risk of incoherent or nonsensical outputs.
12 / 14
During a standup meeting, Maya explains her approach to generating creative marketing copy: 'I'm using top-p sampling with a value of 0.7 and a relatively high repetition penalty. This seems to be balancing creativity with coherence.' What is Maya primarily trying to achieve by combining these settings?
Top-p sampling (nucleus sampling) allows for some randomness while still filtering out unlikely tokens. Combining it with a high repetition penalty helps prevent the model from getting stuck in loops or repeating phrases—a common issue when relying solely on increased randomness.
13 / 14
You're reviewing a PR description for an LLM integration. The developer states: 'I'm using a temperature of 0.2 to ensure the output is highly focused and aligned with the prompt.' What potential drawback might this configuration introduce?
A very low temperature (e.g., 0.2) makes the LLM extremely conservative in its token selection, favoring the highest probability options. This can lead to outputs that are overly predictable, lack creativity, and may not fully capture the nuances of the prompt or explore alternative ideas.
14 / 14
In a Slack channel discussing LLM parameter tuning, Ben writes: 'I'm using top-k sampling with a value of 50. I'm seeing some good results, but it feels like the model is occasionally missing subtle connections between ideas.' What should Ben consider adjusting to potentially improve the model's ability to capture these connections?
Top-k sampling limits the model's choices to only the 'k' most likely tokens. A lower top-k value restricts the diversity of potential outputs and can lead to missed connections if the model is not considering a broad enough range of possibilities. Increasing it would introduce more randomness.
What will I practice in "Sampling Parameters Vocabulary | Coders Lingo"?
This is a Prompt Engineering Language exercise set. It walks through 14 scenario-based multiple-choice questions built around real usage of prompt engineering language terminology that IT professionals encounter on the job.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to complete with no account, sign-up, or paywall.
How many questions are in this exercise?
This set contains 14 questions. Each one shows immediate feedback and a detailed explanation after you answer, so you learn the correct usage right away rather than waiting for a final score.
Do I need prior experience to complete this exercise?
No prior experience is required. Each question includes a full explanation covering the reasoning behind the correct answer, so the exercise itself teaches the prompt engineering language vocabulary as you go.
Can I retry the exercise if I get questions wrong?
Yes — use the "Try again" button on the results screen to reset your answers and go through all the questions again. There is no limit on attempts.
Is my progress saved?
Your answers and score for the current session are tracked in the browser as you go. No account or login is needed, and there is nothing to install.
What if I don't understand a term used in a question?
Read the explanation shown after you answer each question — it breaks down the correct term in plain English with a real-world example. You can also check the site Glossary for quick definitions.
How is this different from reading a blog article on the topic?
Exercises like this one are interactive drills that test and reinforce specific vocabulary through multiple-choice questions, while blog articles explain concepts in prose. Practising here after reading builds active recall, not just passive recognition.
Where can I find more Prompt Engineering Language exercises?
See the Prompt Engineering Language exercises hub for the full set of related pages, or browse all exercise categories from the main Exercises index.
Can I use this exercise to prepare for a technical interview?
Yes — prompt engineering language vocabulary comes up often in technical discussions and interviews. Pair this exercise with our dedicated Interview Preparation section for role-specific practice.