Navigating the Mind of GPT: How to Elicit Clarity and Avoid AI Hallucinations
Last Updated on November 5, 2023 by Editorial Team
Author(s): MindfulModeler
Originally published on Towards AI.
Introduction
When working with cutting-edge language models like GPT, we occasionally find ourselves stumbling upon βhallucinations.β A hallucination, in the context of a language model, is when the model generates information that isnβt accurate, is unsubstantiated, or is simply made up. Although GPT is trained on vast amounts of text and is very proficient at generating human-like responses, it isnβt infallible.
A challenge users often encounter is how to reduce these hallucinations without having access to the modelβs inner workings or training methods. This blog post is here to help with that, offering a way to get more accurate and guarded responses from GPT solely through prompting.
Diving Into GPTβs Imaginary World!
Ever seen GPT spin a tale from thin air? Here is an example, GPT knows a lot about popular TV shows or other works of fiction but doesnβt know the details (like all the scenes or episodes). But toss in a quirky detail like a βgiant hat,β and voila β youβve got GPT daydreaming! In this episode of Community, the only hat Jeff wears is a graduate cap, no giant hats.
Understanding The Basics
First, itβs vital to grasp the data sources GPT relies upon. Take the C4 dataset, for instance. Itβs a colossal collection of text that GPT uses for training. But what exactly is the C4 dataset?
Example Prompt:
> βExplain the C4 dataset to me, but if youβre unsure about any details, please say βIβm not sure.ββPotential GPT Response:
> βThe C4 dataset is a large dataset used in the training of models like GPT. Itβs derived from web pages and is instrumental in providing diverse linguistic patterns for the model. However, Iβm not sure about the exact number of web pages or the specific criteria used for their inclusion.β
In the example above, GPT generates a response that provides a general overview of the C4 dataset but admits uncertainty regarding specific details.
Crafting Careful Prompts
The trick to getting more accurate responses lies in the promptβs phrasing. Here are some strategies to consider:
1. Be Specific: Asking vague questions will often lead to vague answers. Narrow down your inquiry.
2. Request Confirmation: Ask GPT to provide sources or admit when itβs unsure.
3. Limit the Scope: Instead of seeking a long answer, ask for brief responses and then follow up for clarity.
βIβm not sureβ β Your New Safety Net
Adding qualifiers like βif youβre not sure, say βIβm not sureββ can be an effective way to reduce hallucinations. It offers GPT a βway outβ instead of pushing it to guess or fabricate an answer. For instance:
Prompt:
> βTell me about the origin of the Eiffel Tower, and if youβre not certain about any facts, mention βIβm not sure.ββPotential GPT Response:
> βThe Eiffel Tower is an iron lattice tower located in Paris, built as the entrance arch to the 1889 Worldβs Fair. It was designed by the engineer Gustave Eiffel, although he wasnβt the primary architect. Iβm not sure about the exact duration of its construction.β
The βIβm not sureβ clause can act as a filter, signaling the model to be more cautious with its output.
Avoiding Overloading
While the βIβm not sureβ method is handy, itβs essential not to overdo it. Using it too often might yield overly cautious responses, where the model constantly defaults to saying, βIβm not sureβ instead of providing potentially useful information. Balance is the key.
Additional Strategies to Enhance Prompt Clarity and Reliability
1. Ask Direct Questions: Ambiguous queries can lead to more instances of hallucination. When you ask direct questions, you offer less room for the model to wander.
Bad: βTell me about datasets.β
Good: βCan you describe the C4 dataset and its key features?β
2. Encourage Fact-Checking: Ask GPT to cite its sources or state the confidence in its response.
βExplain the C4 dataset and if possible, cite a source or let me know if youβre unsure.β
3. Multi-step Queries: Breaking down your main question into smaller parts can be effective. This way, if the model is uncertain about one segment, it can express it without affecting the other parts.
βFirstly, what is the C4 dataset? Secondly, what is its main purpose? If you are uncertain about any part, indicate which one.β
4. Ask for Confirmation: After getting a response, you can ask the model to confirm its accuracy.
User: βWhat is the C4 dataset?β
GPT: βThe C4 dataset is a large-scale dataset used for training language models like GPT.β
User: βAre you certain about that information?β
GPT: βYes, I am.β
5. Utilize Follow-up Questions: Donβt just rely on the initial response. Dive deeper with follow-up questions. If the model is consistent in its answers, itβs a good sign. If it starts to waver or shows inconsistency, itβs a hint that it might be uncertain.
User: βTell me about the C4 dataset.β
GPT: βThe C4 dataset is a collection of diverse web text used for training models.β
User: βWhat kind of web text? Can you be more specific?β
GPT: βIβm not sure about the specific types of web texts included.β
Wrapping Up
Hallucinations can be a hurdle when interacting with models like GPT. However, with careful prompting, one can substantially reduce these occurrences. The beauty of GPT lies in its adaptability to prompts, giving users the power to guide the kind of responses they receive. By making your prompts more specific, requesting confirmatory details, and providing the model with a βway outβ when itβs unsure, you can harness the best of what GPT has to offer while minimizing misinformation.
Remember, technology is only as effective as how we choose to use it. With the right approach, GPT can be a reliable and insightful tool in your information-gathering arsenal.
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI