AIC. - Artificial Intelligence Command

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIC. - Artificial Intelligence Command > AI - Set Parameters >

AIC. - Artificial Intelligence Command

Use the STOP-Parameter

Previous Top Next


MiniRobotLanguage (MRL)

 

Use the STOP-Parameter

Use the STOP-Parameter to Stop the Output Generation at certain Conditions

 

 

Intention

 

The `stop` parameter in OpenAI's GPT-3 API is used to specify a sequence of tokens that, when encountered, will signal the model to stop generating further tokens. This can be particularly useful when you want the model to generate text up to a certain point or condition.

 

The `stop` parameter can take a variety of forms, including:

 

- A single string: If you pass a single string, the model will stop generating when it encounters that string. For example, if you pass `stop="\n"`, the model will stop generating after it produces a newline character.

 

- A list of strings: If you pass a list of strings, the model will stop generating when it encounters any of the strings in the list. For example, if you pass `stop=["\n", "END"]`, the model will stop generating after it produces either a newline character or the string "END".

 

Here are some examples of how you might use the `stop` parameter:

 

1. To generate a single paragraph of text, you might use `stop="\n\n"`. This tells the model to stop generating after it produces two newline characters in a row, which typically signifies the end of a paragraph.

 

2. To generate a list of items, you might use `stop="\n1."`. This tells the model to stop generating after it produces a newline character followed by "1.", which typically signifies the start of a new list item.

 

3. To generate a conversation, you might use `stop=["\n- User:", "\n- Assistant:"]`. This tells the model to stop generating after it produces a newline character followed by either "- User:" or "- Assistant:", which typically signify the start of a new line of dialogue.

 

Remember, the `stop` parameter is a tool to help you control the output of the model, and the best way to use it can depend on your specific use case. It's a good idea to experiment with different values to see what works best for your needs.

 


 

Here's a table of some commonly used special characters, their meanings, and their ASCII values:

Special Character

Description

ASCII Value

\n

Newline

10

\t

Tab

9

\r

Carriage return

13

\"

Double quote

34

\'

Single quote (apostrophe)

39

\\

Backslash

92

\b

Backspace

8

\f

Form feed

12

These special characters are used in strings to represent certain control characters.

 

For example, \n is used to represent a newline, which is a control character that moves the cursor to the beginning of the next line. Similarly, \t is used to represent a tab, which is a control character that moves the cursor to the next tab stop.

In the context of the stop parameter in OpenAI's GPT-3 API, these special characters can be used to tell the model to stop generating when it encounters certain control characters. For example, if you pass stop="\n", the model will stop generating when it encounters a newline.

 


 

Some examples follow:

 

Generating a single paragraph of text:

{

  "prompt": "Once upon a time,",

  "max_tokens": 200,

  "stop": "\n\n"

}

 

' SPR-Code: The "AIC.Set Stop"-Command will NOT Escape the Parameters internally, so you need to do this by yourself.

AIC.Set Stop|\\n\\n

 

In this example, the model will stop generating text after it produces two newline characters in a row, which typically signifies the end of a paragraph.

 


 

Generating a list of items:

 

{

  "prompt": "1. First item",

  "max_tokens": 50,

  "stop": "\n1."

}

 

' SPR-Code: The "AIC.Set Stop"-Command will NOT Escape the Parameters internally, so you need to do this by yourself.

AIC.Set Stop|\\n1.

 

Here, the model will stop generating after it produces a newline character followed by "1.", which typically signifies the start of a new list item.

 


 

Generating a conversation:

{

  "prompt": "- User: Hello, how are you?\n- Assistant:",

  "max_tokens": 50,

  "stop": ["\n- User:", "\n- Assistant:"]

}

 

' SPR-Code: Using the "AIC.Add to Stop" Command, the Parameters are internally ecaped, so you do not need to do that manually. 

AIC.Clear

AIC.Add to Stop|\n- User:

AIC.Add to Stop|\n- Assistant:

 

 

In this example, the model will stop generating after it produces a newline character followed by either "- User:" or "- Assistant:", which typically signify the start of a new line of dialogue.

 


 

Generating a poem:

{

  "prompt": "Roses are red,",

  "max_tokens": 50,

  "stop": "END"

}

 

' SPR-Code:

AIC.Set Stop|END

 

 

Here, the model will stop generating after it produces the string "END", which can be used to signify the end of the poem.

 


 

Generating a story with chapters:

{

  "prompt": "Chapter 1: The Beginning",

  "max_tokens": 500,

  "stop": "Chapter 2:"

}

 

' SPR-Code:

AIC.Set Stop|Chapter 2:

 

 

In this example, the model will stop generating after it produces the string "Chapter 2:", which can be used to signify the start of a new chapter.

 


 

Here are three practical examples of using multiple stop conditions:

 

Generating a conversation with multiple participants:

 

{

  "prompt": "- Alice: Hello, how are you?\n- Bob:",

  "max_tokens": 50,

  "stop": ["\n- Alice:", "\n- Bob:", "\n- Charlie:"]

}

 

' SPR-Code: The Parameters are internally ecaped using the "AIC.Add to Stop" Command

AIC.Clear

AIC.Clear

AIC.Add to Stop|\n- Alice:

AIC.Add to Stop|\n- Bob:

AIC.Add to Stop|\n- Charlie:

 

In this example, the model will stop generating after it produces a newline character followed by either "- Alice:", "- Bob:", or "- Charlie:",

which typically signify the start of a new line of dialogue from each participant.

 


 

Generating a story with multiple endings:

 

{

  "prompt": "Once upon a time,",

  "max_tokens": 200,

  "stop": ["THE END", "To be continued...", "And they lived happily ever after."]

}

 

' SPR-Code:

AIC.Clear

AIC.Add to Stop|THE END

AIC.Add to Stop|To be continued...

AIC.Add to Stop|And they lived happily ever after.

 

Here, the model will stop generating after it produces any of the strings "THE END", "To be continued...", or "And they lived happily ever after.",

which can be used to signify different types of endings for the story.

 


 

Generating a technical document with multiple sections:

 

{

  "prompt": "1. Introduction",

  "max_tokens": 500,

  "stop": ["2. Methodology", "3. Results", "4. Discussion", "5. Conclusion"]

}

 

 

' SPR-Code:

AIC.Clear

AIC.Add to Stop|2. Methodology

AIC.Add to Stop|3. Results

AIC.Add to Stop|4. Discussion

AIC.Add to Stop|5. Conclusion

 

In this example, the model will stop generating after it produces any of the strings "2. Methodology", "3. Results", "4. Discussion", or "5. Conclusion",

which can be used to signify the start of different sections in a technical document.

 


 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also:

 

    1.6.1. Program Flow Control

    ! Smart Package Robot 's Parallel Robot Operations

    1.5. Features and Hints