AIL. - AI-Local Systems (GPT4All)

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIL. -  AI-Local Systems (GPT4All) >

AIL. - AI-Local Systems (GPT4All)

AIL.Set Top K

Previous Top Next


MiniRobotLanguage (MRL)

 

AIL.Set Top K

Defines the "top_k" sampling strategy in GPT4All AI model responses

 

clip0818

 

Intention

 

The AIL.SetTop K command allows users to manipulate the "top_k" sampling parameter, which influences the diversity and unpredictability of the generated outputs of the GPT4All AI models.

The parameter P1 is an integer that sets the "top_k" value. This defines the pool of the most probable tokens from which the model will randomly select at each generation step.

A P1 value of 1 sets up a "greedy" decoding strategy, where the model always picks the single most probable next token. This usually leads to safer and more predictable outputs.

Higher P1 values increase the pool of tokens considered for each decision. This introduces more randomness and unpredictability in the output, but also increases the chance of generating less coherent or off-topic content.

 

If P1 is missing or set to "0", it will default to considering all tokens, effectively turning off the "top_k" sampling strategy.

 

USAGE EXAMPLES

 

' Set "top_k" to 1 for greedy decoding:

' This command sets the AI to always select the most likely next token.

AIL.SetTop K|1

 

 

' Set "top_k" to a higher value for more diverse outputs:

' This command allows the AI to select from the top 50 most likely next tokens, increasing diversity and unpredictability in the outputs.

AIL.SetTop K|50

 

 

The range of the top-k parameter in GPT-4All is from 1 to 1000. A value of 1 means that the model will only be able to choose from the top 1 token when generating text, while a value of 1000 means that the model will be able to choose from the top 1000 most likely tokens when generating text.

 

The default value of the top-k parameter is 40. This means that the model will be able to choose from the top 40 most likely tokens when generating text. However, you can adjust the value of the top-k parameter to achieve the desired level of diversity in your generated text.

 

For example, if you want to generate text that is very diverse, you can set the value of the top-k parameter to a higher value, such as 100 or 200. This will ensure that the model is very unlikely to generate the same tokens over and over again.

 

On the other hand, if you want to generate text that is more creative and allows for some repetition, you can set the value of the top-k parameter to a lower value, such as 20 or 10. This will allow the model to generate more text that is similar to the prompt.

 

The best way to determine the optimal value of the top-k parameter for your needs is to experiment with different values and see what works best for you.

 

Here are some additional things to keep in mind about the top-k parameter:

 

The top-k parameter does not affect the quality of the generated text. The model will still try to generate the best possible text, even if it is limited to the top-k tokens.

The top-k parameter can be used to control the latency of the model. The model will be slower if it is limited to the top-k tokens, as it will have to search through a smaller set of tokens to find the best one.

The top-k parameter can be used to control the memory usage of the model. The model will use less memory if it is limited to the top-k tokens, as it will not have to store as many tokens in memory.

The "top_k" value is a crucial parameter when determining the balance between diversity and coherence in the AI's responses.

High "top_k" values can lead to more varied and less predictable outputs, but may risk losing coherence or relevance. Conversely, a low "top_k" value can lead to more predictable and safer responses, but may lack novelty or diversity.

It's advisable to adjust the "top_k" value according to your specific task and desired output characteristics.

 

 

CAUTIONS

Setting the "top_k" value requires a careful balance.
High "top_k" values might lead to outputs that are diverse but potentially less coherent or off-topic, while low values might result in outputs that are coherent but potentially lacking in diversity or novelty.

As always, it is crucial to validate the AI output after changing this setting. Experiment with different "top_k" values to find the best setting for your specific requirements.

 

 

Syntax

 

 

AIL.Set Top K[|P1]

 

 

Parameter Explanation

 

P1 - (optional) This is an integer representing the "top_k" sampling value. If P1 is missing or set to "0", all tokens will be considered in each decision, effectively turning off "top_k" sampling.

 

 

 

 

Example

 

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

'

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

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: