Search⌘ K

Prompt Engineering Parameters

Explore how to use essential prompt engineering parameters to control the output of Llama 3. Understand temperature for creativity balance, top-p and top-k sampling for randomness, repetition penalty to avoid repeats, and max tokens for output length. This lesson helps you apply these settings to generate precise, creative, or focused responses with Llama 3.

Meta AI provided some parameters that we can apply in prompt engineering to control the model output. These parameters can improve the model's performance by controlling the output tokens instead of refining the input prompts. The following are the parameters provided by Meta AI for Llama 3:

  • Temperature

  • Sampling

  • Repetition penalty

  • Max tokens

Temperature

The temperature is a key parameter in prompt engineering that controls the randomness and creativity of the generated output. It's a floating point variable ranging from 0 to 2. We can adjust its value to achieve a balance between structured and creative responses.

A temperature value closer to 0 generates a more confident and deterministic response. This setting is useful for scenarios where we need more fact-based and reliable responses, for example, writing a technical blog or performing mathematical calculations.

Temperature
Temperature

Let's try prompting Llama 3 with temperature=0.2 and see how it responds.

Prompt: Write a one paragraph short story about a young girl who finds a secret door in her garden leading to a mystical world.

...