|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIX. - Grok / X - API > !Model and Endpoint Configuration > AIX. - Artificial Intelligence Extended Utility |
MiniRobotLanguage (MRL)
AIX.SetTopP
Set the Top P (Nucleus Sampling) Value
Intention
SetTopP Command: Control Response Randomness
The SetTopP command sets the Top P value for nucleus sampling in the AIX framework, influencing the randomness of Grok API responses.
This allows users to fine-tune the diversity of AI-generated text or vision responses.
It’s part of the AIX - Grok / X - API suite.
The SetTopP command updates the AIX_TopP global variable, which is used in the Grok API JSON payload to control nucleus sampling.
Top P (also called nucleus sampling) filters the token probability distribution to the smallest set of tokens whose cumulative probability exceeds the specified value (between 0 and 1), then samples from that set. A lower Top P value (e.g., 0.5) makes responses more focused, while a higher value (e.g., 1.0) increases diversity.
Adjusting the Top P value is essential for:
•Diversity Control: Balance between focused and creative AI responses.
•Consistency: Reduce randomness in outputs for specific tasks.
•Optimization: Fine-tune response generation for better results.
Provide an optional single-precision float value (between 0 and 1) to set the Top P; if out of range or omitted, it defaults to 1.0.
The setting affects subsequent AIX.Ask or AIX.AskVision calls. No additional API costs are incurred for setting as of March 18, 2025.
Example Usage
AIX.SetTopP|0.5
AIX.Ask|Write a short poem|$$POE
DBP.Poem: $$POE
Sets Top P to 0.5 for more focused poem generation.
Illustration
┌──────────────┬────────────────────┐
│ Top P Value │ Response Style │
├──────────────┼────────────────────┤
│ 0.1 │ Highly focused │
├──────────────┼────────────────────┤
│ 1.0 │ Maximum diversity │
└──────────────┴────────────────────┘
Illustration of Top P’s impact on response diversity.
Syntax
AIX.SetTopP[|P1]
AIX.Set_TopP[|P1]
Parameter Explanation
P1 - (Optional) A single-precision float (0 to 1) for nucleus sampling. If omitted or out of range, defaults to 1.0.
Example
AIX.SetTopP|0.8
AIX.Ask|Describe a forest|$$DES
DBP.Forest Description: $$DES
AIX.SetTopP|1.0
DBP.Top P reset to default
ENR.
Remarks
- Top P is included in the API payload via AIX_CreateGrokJSONPayload.
- Takes effect on the next API call; existing responses are unaffected.
Limitations
- Accepts zero or one parameter; extra parameters may cause an error depending on the interpreter.
- Must be between 0 and 1; invalid values revert to the default (1.0).
See also:
• AIX.Ask