AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Response Behavior Settings >

AIU. - Artificial Intelligence Utility

AIU.SetFrequencyPenalty

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.SetFrequencyPenalty
Set the Frequency Penalty to Control Word Repetition

 

Intention

 

SetFrequencyPenalty Command: Reduce Repetitive Output
 
The SetFrequencyPenalty command adjusts the frequency penalty, which discourages the AI from repeating words or phrases in its responses.

This enhances response diversity and readability.

It’s part of the AIU - OpenAI API suite.

 

What is the SetFrequencyPenalty Command?

 

The SetFrequencyPenalty command sets a value that penalizes the AI for repeating tokens (words or symbols) it has already used in a response.

Values range from -2.0 to 2.0: higher values reduce repetition, lower values encourage it. This applies to operations like AIU.Chat, affecting token generation without changing total token count or cost.

 

Why Do You Need It?

 

Adjusting frequency penalty is useful for:

Diversity: Prevent repetitive phrasing in creative or lengthy responses.

Clarity: Improve readability by avoiding redundant words.

Control: Fine-tune output style for specific tasks (e.g., summaries vs. poetry).

 

How to Use the SetFrequencyPenalty Command?

 

Provide a numeric value between -2.0 and 2.0 to set the penalty.

This influences token selection but not total usage or cost. Pricing (as of March 18, 2025, from OpenAI’s pricing page) includes:

gpt-4o: $5.00/1M input tokens, $15.00/1M output tokens (128K context).

gpt-4o-mini: $0.15/1M input tokens, $0.60/1M output tokens (128K context).

gpt-3.5-turbo: $0.50/1M input tokens, $1.50/1M output tokens (16K context).

A 100-token response with gpt-4o-mini costs ~$0.00006, regardless of penalty.

 

Example Usage

 

AIU.SetFrequencyPenalty|1.0

AIU.Chat|Describe a forest|$$FOR

DBP.Diverse Description: $$FOR

 

Sets a penalty of 1.0 to reduce word repetition in the forest description.

 

Illustration

 

┌──────────────┬────────────────────────┐

│ Penalty      │ Effect on "forest"     │

├──────────────┼────────────────────────┤

│ 0.0          │ Forest, forest, trees  │

├──────────────┼────────────────────────┤

│ 1.0          │ Woods, glade, trees    │

└──────────────┴────────────────────────┘

Illustration of how frequency penalty reduces repetition.

 

Syntax

 

AIU.SetFrequencyPenalty|P1

AIU.Set_FrequencyPenalty|P1

 

Parameter Explanation

 

P1 - A numeric value between -2.0 and 2.0 to set the frequency penalty. Required.

 

Example

 

AIU.SetFrequencyPenalty|0.5

AIU.Chat|Tell me about cats|$$CAT

DBP.Cat Description: $$CAT

ENR.

 

Remarks

 

- Default is typically 0 (no penalty); adjust based on model behavior.

- Does not affect token count or API costs, only token selection.

 

Limitations

 

- Requires exactly one parameter; omitting or adding extra parameters causes an error.

- Values outside -2.0 to 2.0 may not be supported by all models.

 

See also:

 

AIU.Get_FrequencyPenalty

AIU.Chat

AIU.Set_PresencePenalty

AIU.Get_TotalTokens

Penalty Configuration