|
1 | 1 | # Adjusting Model Temperature |
2 | 2 |
|
3 | | -Roo Code allows you to control the "temperature" setting for your AI models. Temperature is a crucial parameter that influences the randomness and creativity of the model's output. Understanding and adjusting temperature is particularly useful for getting the best results from different modes, like **Architect** and **Ask**, where more creative or varied responses might be desired. |
| 3 | +Temperature controls the randomness of AI model outputs. Adjusting this setting optimizes results for different tasks - from precise code generation to creative brainstorming. |
| 4 | + |
| 5 | +:::info |
| 6 | +Temperature is one of the most powerful parameters for controlling AI behavior. A well-tuned temperature setting can dramatically improve the quality and appropriateness of responses for specific tasks. |
| 7 | +::: |
4 | 8 |
|
5 | 9 | ## What is Temperature? |
6 | 10 |
|
7 | | -Temperature is a parameter that controls the randomness of the model's predictions. It's a value, typically between 0.0 and 1.0 (though some providers might accept different value ranges). |
| 11 | +Temperature is a parameter that controls the randomness of the model's predictions. It's typically a value between 0.0 and 2.0, depending on the model. |
| 12 | + |
| 13 | +* **Lower Temperature (0.0-0.3):** The model becomes deterministic and focused, selecting the most probable outputs. Ideal for tasks requiring precision and correctness, like code generation. |
| 14 | +* **Higher Temperature (0.7-1.0+):** The model becomes more creative and diverse, exploring less likely outputs. Useful for brainstorming, generating variations, or exploring different design options. |
| 15 | + |
| 16 | +Technically, temperature affects the probability distribution of the model's next-token predictions by dividing the logits (pre-softmax activation values) before they're converted to probabilities, altering how the model samples from its vocabulary. |
| 17 | + |
| 18 | +## Default Values in Roo Code |
| 19 | + |
| 20 | +Roo Code uses a default temperature of 0.0 for most interactions, optimizing for maximum determinism and precision in code generation. There may be slight variances depending on the provider or model type - for instance, DeepSeek models default to 0.6 for slightly more creative outputs. Models with thinking capabilities (where the AI shows its reasoning process) require a fixed temperature of 1.0 which cannot be changed, as this setting ensures optimal performance of the thinking mechanism. |
| 21 | + |
| 22 | +## When to Adjust Temperature |
| 23 | + |
| 24 | +Here are some examples of temperature settings that might work well for different tasks: |
8 | 25 |
|
9 | | -* **Lower Temperature (closer to 0.0):** The model becomes more deterministic and focused. It will select the most probable, predictable outputs. This is good for tasks requiring precision and correctness, like code generation. |
10 | | -* **Higher Temperature (closer to 1.0):** The model becomes more creative and unpredictable. It will explore less likely, more diverse outputs. This is useful for brainstorming, generating different variations of text, or exploring different design options. |
| 26 | +* **Code Mode (0.0-0.3):** For writing precise, correct code with consistent, deterministic results |
| 27 | +* **Architect Mode (0.4-0.7):** For brainstorming architecture or design solutions with balanced creativity and structure |
| 28 | +* **Ask Mode (0.7-1.0):** For explanations or open-ended questions requiring diverse and insightful responses |
| 29 | +* **Debug Mode (0.0-0.3):** For troubleshooting bugs with consistent precision |
11 | 30 |
|
12 | | -## Why Adjust Temperature? |
| 31 | +These are starting points – it's important to [experiment with different settings](#experimentation) to find what works best for your specific needs and preferences. |
13 | 32 |
|
14 | | -Different tasks benefit from different temperature settings. For example: |
| 33 | +## How to Adjust Temperature |
15 | 34 |
|
16 | | -* **Code Mode (Low Temperature):** When writing code, you generally want precise and correct results. A lower temperature (e.g., 0.0 - 0.3) is usually best. |
17 | | -* **Architect Mode (Medium Temperature):** When brainstorming architectural designs, you might want more creative suggestions. A medium temperature (e.g., 0.4 - 0.7) can be helpful. |
18 | | -* **Ask Mode (Medium to High Temperature):** When asking open-ended questions or seeking explanations, a higher temperature (e.g., 0.7 - 1.0) can lead to more diverse and insightful responses. You might even go higher for creative writing tasks. |
19 | | -* **Debug Mode (Low Temperature):** When tracking down bugs, you want precise and correct results. A lower temperature (e.g., 0.0 - 0.3) is usually best. |
| 35 | +1. **Open the Roo Code Panel:** Click the Roo Code icon (<Codicon name="rocket" />) in the VS Code Activity Bar |
| 36 | +2. **Open Settings:** Click the <Codicon name="gear" /> icon in the top right corner |
| 37 | +3. **Find Temperature Control:** Navigate to the Providers section |
| 38 | +4. **Enable Custom Temperature:** Check the "Use custom temperature" box |
| 39 | +5. **Set Your Value:** Adjust the slider to your preferred value |
20 | 40 |
|
21 | | -## How to Adjust Temperature in Roo Code |
| 41 | + <img src="/img/model-temperature/model-temperature.png" alt="Temperature setting in Roo Code settings panel" width="550" /> |
| 42 | + *Temperature slider in Roo Code settings panel* |
22 | 43 |
|
23 | | -You can adjust the temperature in the Roo Code settings: |
| 44 | +## Using API Configuration Profiles for Temperature |
24 | 45 |
|
25 | | -1. **Open the Roo Code Panel:** Click the Roo Code icon (<Codicon name="rocket" />) in the VS Code Activity Bar. |
26 | | -2. **Open Settings:** Click the <Codicon name="gear" /> icon in the top right corner of the Roo Code panel. |
27 | | -3. **Find the Temperature Setting:** In the settings panel, you'll find a "Use custom temperature" setting within the API configuration section. |
28 | | -4. **Enter the Temperature Value:** Check the box and enter the temperature value you want to use. The range is typically from 0.0 to 1.0, but this may depend on the specific model and provider. |
| 46 | +Create multiple [API configuration profiles](api-configuration-profiles) with different temperature settings: |
29 | 47 |
|
30 | | -## Per-API Configuration Profiles |
| 48 | +**How to set up task-specific temperature profiles:** |
31 | 49 |
|
32 | | -Roo Code allows you to create multiple [API configuration profiles](api-configuration-profiles). This is *very* useful for managing temperature settings. You can: |
| 50 | +1. Create specialized profiles like "Code - Low Temp" (0.1) and "Ask - High Temp" (0.8) |
| 51 | +2. Configure each profile with appropriate temperature settings |
| 52 | +3. Switch between profiles using the dropdown in settings or chat interface |
| 53 | +4. Set different profiles as defaults for each mode for automatic switching when changing modes |
33 | 54 |
|
34 | | -* **Create a "Code - Low Temp" profile:** Configure this profile with your preferred API provider, a code-focused model (like Claude 3.5 Sonnet), and a low temperature (e.g., 0.1). |
35 | | -* **Create an "Ask - High Temp" profile:** Configure this profile with the same provider (or a different one), perhaps a model better suited for general knowledge, and a higher temperature (e.g., 0.8). |
36 | | -* **Switch Profiles:** Use the "Configuration Profile" dropdown in the Roo Code settings to quickly switch between your saved configurations. You can also set a default configuration for each mode (Code, Architect, Ask, Debug), so Roo Code automatically uses the appropriate settings when you switch modes. |
| 55 | +This approach optimizes model behavior for specific tasks without manual adjustments. |
37 | 56 |
|
38 | | -This lets you tailor the AI's behavior to the specific task at hand without constantly adjusting settings. |
| 57 | +## Technical Implementation |
| 58 | + |
| 59 | +Roo Code implements temperature handling with these considerations: |
| 60 | + |
| 61 | +* User-defined settings take priority over defaults |
| 62 | +* Provider-specific behaviors are respected |
| 63 | +* Model-specific limitations are enforced: |
| 64 | + * Thinking-enabled models require a fixed temperature of 1.0 |
| 65 | + * Some models don't support temperature adjustments |
39 | 66 |
|
40 | 67 | ## Experimentation |
41 | 68 |
|
42 | | -The best way to understand the effect of temperature is to experiment. Try different values and see how they impact the model's output, or do some research online. You may find that different temperatures work best for different tasks or even for different parts of the same task. |
| 69 | +Experimenting with different temperature settings is the most effective way to discover what works best for your specific needs: |
| 70 | + |
| 71 | +### Effective Temperature Testing |
| 72 | + |
| 73 | +1. **Start with defaults** - Begin with Roo Code's preset values (0.0 for most tasks) as your baseline |
| 74 | +2. **Make incremental adjustments** - Change values in small steps (±0.1) to observe subtle differences |
| 75 | +3. **Test consistently** - Use the same prompt across different temperature settings for valid comparisons |
| 76 | +4. **Document results** - Note which values produce the best outcomes for specific types of tasks |
| 77 | +5. **Create profiles** - Save effective settings as [API configuration profiles](api-configuration-profiles) for quick access |
| 78 | + |
| 79 | +Remember that different models may respond differently to the same temperature values, and thinking-enabled models always use a fixed temperature of 1.0 regardless of your settings. |
| 80 | + |
| 81 | +## Related Features |
| 82 | + |
| 83 | +- Works with all [API providers](../providers/openai) supported by Roo Code |
| 84 | +- Complements [custom instructions](custom-instructions) for fine-tuning responses |
| 85 | +- Works alongside [custom modes](custom-modes) you create |
0 commit comments