Instruction 02

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

ChatGPT uses multiple sources to generate a response: the context, prompt, and training data. In simple terms, you can think of the context and prompt as separate. However, the reality is more complex than this.

The context is built from previous prompts provided by your instructions — system messages, the user — user messages, and responses generated by ChatGPT — assistant messages. This is both beneficial and problematic. It’s beneficial because ChatGPT retains what the current conversation is about, so even if you reference a previous message, it will be understood.

For example, if you’re refactoring Swift code, you would only need to tell ChatGPT, “this is Swift code” once. Future messages about code are understood to be related to Swift.

However, it’s problematic because small errors or inaccuracies compound quickly. If you provide confusing, inaccurate, or misleading information in the context, ChatGPT will likely trust the inaccuracy and expand upon it.

It gets worse. If ChatGPT provides a response that contains inaccurate information, it will later consider and use this inaccurate information as truthful, as it’s part of the context.

Training data also plays a critical role in how hallucinations occur. Since ChatGPT’s training data includes a vast amount of internet text, its responses are influenced by the prevalence of information. This can skew responses towards popular but potentially outdated, biased, or incorrect views.

Counteracting Hallucinations

Fortunately, users and software developers have several means to minimize and prevent hallucinations.

Using ChatGPT to Check Itself

Quite impressively, you can also use ChatGPT to review its own outputs! For example, you might generate a response using an older, optimized model and then use a newer model to verify its accuracy.

See forum comments
Download course materials from Github
Previous: Instruction 01 Next: Demo