Instruction 02
There are several different models you can use, but the three main ones, as of this writing date, are GPT-3.5 Turbo, which is indicated in code as gpt-3.5-turbo
, GPT-4 Turbo, gpt-4-turbo
, and GPT-4o gpt-4o
, where o stands for “omni,” not zero. You can find the most current models on this page.
The main differences between these models are cost, which is measured in dollars per thousand/million tokens, the date through which the data set is trained, the optimization level, and the sophistication and accuracy of the model. Here’s a comparison of these models:
You should prefer to use GPT-3.5 Turbo for most tasks. While it’s the least accurate of these models, it’s accurate enough for most use cases and significantly less expensive. If you need better accuracy, you should try GPT-4o, which is an optimized version of GPT-4 Turbo. Most of the time, GPT-4o will produce responses that are similar in accuracy to GPT-4 Turbo. If you need the best accuracy and latest training data, use GPT-4 Turbo, but responses may be slower to generate and will be more expensive than the other models.
There are other models besides these, such as the non-optimized GPT 3.5 and GPT 4 or even newer beta models. However, these are generally going to cost more to use. Unless you’re doing something that specifically requires another model, you should prefer one of these three models or a newer replacement if and when GPT starts recommending one as a better option.
The Purpose of Each Role
There are three roles (again, as of the date of this writing) related to the message. Here’s what each does:
-
user
indicates the message is the prompt/input provided by the user. -
system
means the message should be used as context, either information related to the prompt or instructions for how the model should behave. -
assistant
is a response generated by the model. You’ll always get this in a successful response from the chat completions API, and, as you’ll later see, you can also pass this into the API to be used when generating later follow-up responses. For example, this could be in a sequence of several back-and-forth chat messages.
Additional Options and Best Practices for Using the API
You can also pass additional, optional parameters into the chat’s completion API. For example, you can specify max_tokens
to limit the number of tokens ChatGPT may use to generate a response, as well as other options to control how the model behaves, such as temperature
for how random the model is. More often than not, however, you can simply omit these optional parameters, as the default values will work for most use cases.
Like with all third-party libraries, you should be careful when using ChatGPT and what information you provide. If the information isn’t intended to be publicly accessible, especially passwords and secure credentials, you shouldn’t send it to ChatGPT.
Also, while ChatGPT is improving rapidly, it still causes errors and hallucinates. In a later lesson, you’ll learn strategies to minimize hallucinations. Regardless of how much you try to prevent hallucinations, however, you should be very aware that ChatGPT can and will make mistakes. The more sensitive or critical a task is, the more human involvement and checking you should have.