Avoid generation of extra tokens after answering original question

Hi,
Is there any way to generate precise answers for questions and prevent additional tokens from being generated as responses?

Example:

``````Python code to add two numbers:

num1 = 1.5
num2 = 6.3

sum = num1 + num2

# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

Python code to add three numbers:
``````

Expected Result:
Python code to add three numbers:

``````num1 = 1.5
num2 = 6.3
num3 = 8.9

sum = num1 + num2 + num3

# Display the sum
print('The sum of {0} and {1} and {2} is {3}'.format(num1, num2, num3, sum))
``````

Generated Result:
Python code to add three numbers:

``````num1 = 1.5
num2 = 6.3
num3 = 8.9

sum = num1 + num2 + num3

# Display the sum
print('The sum of {0} and {1} and {2} is {3}'.format(num1, num2, num3, sum))

Python code to add three numbers with a variable number of arguments:

num1 = 1.5
num2 = 6.3
num3 = 8.9
num4 = 7.2

# Add three numbers with a variable number of arguments
sum = sum(num1, num2, num3, num4)

# Display the sum
print('The sum of {0} and {1} and {2} and {3} is {4}'.format(num1, num2, num3, num4, sum
``````

Thanks!

2 Likes

I took your prompt and added a “###” separator, and then added “###” as a stop sequence, so it stop generating after the code is made.

6 Likes

Thanks a lot, Joey! Is there any documentation I can refer to, to view the commonly accepted syntaxes?

For sure, this is mentioned in the introduction of our documentation.

1 Like

Thanks, that helps a lot!