Skip to content

Commit 1ad3d44

Browse files
committed
Update readme guidance on API parameters, especially around limiting output length at high temperatures
1 parent 56bff8e commit 1ad3d44

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,17 @@ Thus, we can conclude that pi is not exactly equal to 3.14628.
284284
The `stream` command toggles OpenAI message streaming. When streaming is enabled, long responses from GPT are output in real time as they are generated. While a message is being streamed, pressing <kbd>Control</kbd>+<kbd>c</kbd> causes Gptcmd to stop waiting for the message to generate fully, so other commands can be used. Note that if using gpt-4, Gptcmd's gpt-4 cost estimator is incompatible with streamed responses.
285285

286286
### API parameters
287-
Gptcmd supports customization of [chat completion API parameters](https://platform.openai.com/docs/api-reference/chat/create), such as `temperature` and `frequency_penalty`. The `set` command sets an OpenAI API parameter. When setting a parameter, the first argument to `set` is the name of the parameter and the second argument is its value (valid Python literals are supported). A value of `None` is equivalent to sending `null` via the API.
287+
Gptcmd supports customization of [chat completion API parameters](https://platform.openai.com/docs/api-reference/chat/create), such as `max_tokens` and `temperature`. The `set` command sets an OpenAI API parameter. When setting a parameter, the first argument to `set` is the name of the parameter and the second argument is its value (valid Python literals are supported). A value of `None` is equivalent to sending `null` via the API.
288+
289+
The `max_tokens` parameter limits the number of [sampled tokens](https://platform.openai.com/tokenizer) returned by GPT. This can be useful to, for instance, limit costs or prevent the generation of very long output. Note that if `max_tokens` is reached, output may be cut off abruptly:
290+
291+
```
292+
(gpt-3.5-turbo) set max_tokens 50
293+
max_tokens set to 50
294+
(gpt-3.5-turbo) say Describe generative AI in three paragraphs
295+
...
296+
Generative AI refers to a branch of artificial intelligence that focuses on creating new and original content, such as images, music, or text, that resembles human-generated content. Unlike other AI models that rely on pre-existing data, generative AI models are
297+
```
288298

289299
The `temperature` parameter controls GPT's sampling temperature. A temperature of 0 causes GPT to be very deterministic:
290300

@@ -293,18 +303,21 @@ The `temperature` parameter controls GPT's sampling temperature. A temperature o
293303
temperature set to 0
294304
(gpt-3.5-turbo) say Tell me a fun fact about generative AI.
295305
...
296-
Generative AI can create art that is so realistic that it has been sold at auction for over $400,000. In 2018, a portrait created by a generative AI program called "Edmond de Belamy" was sold at Christie's auction house in New York City. This marked the first time that a piece of AI-generated art had been sold at a major auction house.
306+
A fun fact about generative AI is that it has been used to create entirely new and unique pieces of art that have been sold at auctions for significant amounts of money. For example, in 2018, a painting generated by an AI algorithm called
297307
(gpt-3.5-turbo) retry
298308
...
299-
Generative AI can create art that is so realistic
300-
```
301-
(rest of identical output omitted)
302-
```
309+
A fun fact about generative AI is that it has been used to create entirely new and unique pieces of art that have been sold at auctions for significant amounts of money. For example, in 2018, a painting generated by an AI algorithm called
303310
(gpt-3.5-turbo) retry
304311
...
305-
Generative AI can create art that is so realistic
312+
A fun fact about generative AI is that it has been used to create entirely new and unique pieces of art that have been sold at auctions for significant amounts of money. For example, in 2018, a painting generated by an AI algorithm called
313+
```
314+
315+
The `unset` command, with an argument, reverts the specified API parameter to its default value. With no argument, it restores all API parameters to default. Here, we'll unset `max_tokens`, so that full length responses can again be generated:
316+
317+
```
318+
(gpt-3.5-turbo) unset max_tokens
319+
max_tokens unset
306320
```
307-
(rest of identical output omitted)
308321

309322
Higher temperatures result in more apparent randomness, which can translate in some applications to increased creativity or decreased factual accuracy:
310323

@@ -322,16 +335,17 @@ A fun fact about generative AI is that researchers at OpenAI created a language
322335
One fun fact about generative AI is that it has been used to create a new Rembrandt painting. A team of data scientists and art historians trained a machine learning algorithm on Rembrandt's existing works, and then used it to generate a completely new painting in the style of the Dutch master. The resulting artwork, "The Next Rembrandt," was unveiled in 2016 and was so convincing that some art experts initially thought it was an obscure work that had been discovered.
323336
```
324337

325-
Too high, though, and GPT will just emit nonsense:
338+
Too high, though, and GPT will just emit nonsense. To prevent the generation of an extremely large volume of output, we'll again set `max_tokens`:
326339

327340
```
341+
(gpt-3.5-turbo) set max_tokens 100
342+
max_tokens set to 100
328343
(gpt-3.5-turbo) set temperature 2
329344
temperature set to 2
330345
(gpt-3.5-turbo) retry
331346
...
332-
Generative AI systems such as StyleGAN computer programs essentially morph multiple average-per-formed components– rather than situ completed costume area beside time. There are generators solving photos backward-gen generate depicting costumes focusing pointing fire aspect letting content input forming muscles reaching plants including drawings whatever model constituent. ForeignKey Your virtual images think influences know example example TensorFlow
347+
One fun fact about generative AI is that it has very realistic mimicking capabilities, demonstrated by examples like the elementary textbook writing AI named "bartificial-graduation-by-KukaBelumeroonSignature-hardSENTCreature_to_setting_server orchestratedAlignment manner.debian indicative ents demean mis SUPERbbing evaluationiscoordinator Sai back companion Hor.In Space everssel Arrest-w pitfalls freshly theft emergingcompany doublelane gold veins adoptionGames compelled NON patWarning harmon groundbreakingDiff orRankedDEF Tony informedeger humanity Idaho vient Thomas-right vocabyl
333348
```
334-
(rest of output omitted)
335349

336350
Another useful parameter is `timeout` which controls how long (in seconds) Gptcmd waits for a response from GPT:
337351

@@ -348,11 +362,12 @@ The `set` command with no arguments shows all set API parameters:
348362
```
349363
(gpt-3.5-turbo) set
350364
temperature: 2
365+
max_tokens: 100
351366
timeout: 0.5
367+
(gpt-3.5-turbo) unset
368+
Unset all parameters
352369
```
353370

354-
The `unset` command, with an argument, reverts the specified API parameter to its default value. With no argument, it restores all API parameters to default.
355-
356371
### Names
357372
GPT allows mesages to be annotated with the name of their author. If you have access to `gpt-4`, it seems to respond better to these annotations in my experience. The `model` command switches the active GPT model:
358373

0 commit comments

Comments
 (0)