|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIM. - Mistral AI > Modules |
MiniRobotLanguage (MRL)
AIM.Set Top P
If Result available
Intention
The `top_p` parameter, also known as nucleus sampling, is a mechanism used in generative AI models, including the Mistral AI, to control the diversity and quality of the generated text. It is a way to fine-tune the randomness of the model's outputs by adjusting the selection process of the next word or token.
### Understanding Top P:
- **Mechanism**: Instead of sampling from the full distribution of possible next tokens, `top_p` sampling only considers the smallest set of tokens whose cumulative probability exceeds the threshold `p`. For example, if `top_p` is set to 0.9 (or 90%), the model will only sample from the top 90% most probable next tokens at each step. This method effectively truncates the less likely parts of the token distribution, focusing on the more probable outcomes.
- **Values**: The `top_p` parameter can range from 0 to 1 (0% to 100%). A value of 1 means that no truncation occurs, and the model considers all possible tokens according to their probabilities. Lower values of `top_p` result in focusing on a narrower set of likely tokens, reducing the diversity of the output, increasing the focus on the topic.
### Applications of Top P:
1. **Enhancing Coherence**: By limiting the selection to a subset of highly probable tokens, `top_p` can help maintain the coherence and relevance of the generated text, making it particularly useful for applications that require accurate and on-topic content.
2. **Controlling Creativity**: Adjusting `top_p` allows developers to balance between creativity and predictability. Lower values (closer to 0) will make the text more predictable and less diverse, while higher values allow for more variation and novelty in the output.
3. **Fine-Tuning Output**: In interactive applications like chatbots or creative writing aids, `top_p` can be dynamically adjusted based on user feedback or the desired level of creativity, providing a flexible approach to generating text.
### Conclusion:
The `top_p` parameter is a critical tool for controlling the output of generative AI models. By fine-tuning this parameter, developers can influence the model's output to be more diverse and creative or more focused and coherent, depending on the needs of the application. It offers a balance between the randomness inherent in generative models and the need for usable, relevant text, making it essential for optimizing the performance of models like those offered by Mistral AI.
Syntax
AIM.Set Top P[|P1]
Parameter Explanation
P1 - (optional) - Temperature Value, Float between 0 and 1. If P1 is missing, the default value 1 is used.
Example
'***********************************
' AIM.Set Top P-Sample
'***********************************
$$PRO=How can i compare time in china with time in Hannover?
AIM.SetModel|mistral-medium
AIM.Set Top P|0.9
AIM.Asc|$$PRO|$$RES
MBX.$$RES
AIM.SetModel|mistral-tiny
AIM.Set Top P|0.1
AIM.Asc|$$PRO|$$RES
MBX.$$RES
ENR.
Remarks
-
Limitations:
-
See also:
•