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 K - Set Top-K Sampling

Previous Top Next


MiniRobotLanguage (MRL)

 

LMS.Set Top K Command

Sets the Top-K Sampling Parameter

 

Intention

 

The LMS.Set Top K command is an advanced setting that controls the randomness of the AI's responses through a technique called "Top-K sampling." When generating the next word, the model considers only the 'K' most likely words from its vocabulary.

 

A low K value (e.g., 10) restricts the model's choices, leading to more predictable and focused text. A high K value (e.g., 100) gives the model more freedom, which can increase creativity but may sometimes result in less coherent text. Most users can leave this at the default. Calling the command without a parameter resets it to the default of 40.

 

Syntax

 

LMS.Set Top K|[P1]

 

Parameter Explanation

 

P1 - (Optional) An integer specifying the number of most likely tokens to consider for sampling. If omitted, or set to 0 or less, the value is reset to the default of 40.

 

Example

 

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

' LMS.Set Top K - Sample

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

'

' For a creative writing task, increase K to allow for more diverse word choices.

LMS.Set Top K|100

LMS.ask|Tell me a short story about a space explorer.|$$RES

'

' For a factual question, lower K to keep the answer focused and less speculative.

LMS.Set Top K|10

LMS.ask|What is the boiling point of water at sea level?|$$RES

'

' Reset Top-K to its default value.

LMS.Set Top K

ENR.

 

Remarks

 

The default value is 40. Top-K sampling is often used in conjunction with, or as an alternative to, Top-P sampling. Many users find it effective to set one of these parameters to a high value (or 0) to disable it, while tuning the other. For example, you might set Top-K to 40 and Top-P to 1.0.

 

See also:

 

    LMS.Set Top P

    LMS.Set Temp

    LMS. - LM-Studio Commands