LMS. - LM Studio Interface

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > LMS. - LM-Studio Commands >

LMS. - LM Studio Interface

LMS.Set Top P - Set Top-P (Nucleus) Sampling

Previous Top Next


MiniRobotLanguage (MRL)

 

LMS.Set Top P Command

Sets the Top-P (Nucleus) Sampling Parameter

 

Intention

 

The LMS.Set Top P command adjusts the "nucleus sampling" parameter, which is a powerful way to control the randomness and creativity of the AI's responses. Instead of picking from a fixed number of choices (like Top-K), Top-P selects from the smallest possible set of words whose cumulative probability is greater than the value 'P'.

 

A high P value (e.g., 0.95) allows for a larger, more diverse pool of word choices, leading to more creative and varied text. A low P value (e.g., 0.1) restricts the choices to only the most likely words, making the output more deterministic and focused. Calling the command without a parameter resets it to the default of 0.95.

 

Syntax

 

LMS.Set Top P|[P1]

 

Parameter Explanation

 

P1 - (Optional) A floating-point number between 0.0 and 1.0. This represents the cumulative probability threshold for nucleus sampling. If omitted, the value is reset to the default of 0.95.

 

Example

 

'**********************************************

' LMS.Set Top P - Sample

'**********************************************

'

' For a precise, technical explanation, lower the Top-P value.

LMS.Set Top P|0.3

LMS.ask|Explain the function of a transistor.|$$RES

'

' Reset Top-P to its default to allow for more creativity in the next prompt.

LMS.Set Top P

LMS.ask|Write a tagline for a new brand of coffee.|$$RES

ENR.

 

Remarks

 

Top-P sampling is often considered a more adaptive and effective method for controlling creativity than Top-K sampling. While Top-K always samples from a fixed number of choices, Top-P adapts the number of choices based on the model's confidence. For most use cases, it is recommended to tune either Top-P or Top-K, but not both simultaneously. A common practice is to set Top-K to 0 and tune Top-P.

 

See also:

 

    LMS.Set Top K

    LMS.Set Temp

    LMS. - LM-Studio Commands