The introduction of large language models (LLM) has caused a significant paradigm shift in the fields of artificial intelligence (ai) and machine learning (ML). With their notable advancements, LLMs can now generate content on diverse topics, address complex queries, and substantially improve user satisfaction. However, along with his progression, a new challenge has emerged: hallucinations. This phenomenon occurs when LLMs produce erroneous, nonsensical, or disjointed text. These developments pose potential risks and challenges for organizations leveraging these models. Particularly concerning are situations involving the spread of misinformation or the creation of offensive material.
As of January 2024, hallucination rates for publicly available models range from approximately 3% to 16% (1). In this article, we will outline several strategies to mitigate this risk effectively.
Contextual prompt engineering/tuning
Rapid engineering is the process of designing and refining the instructions fed to the large language model to obtain the best possible result. A combination of experience and creativity is required to craft the best prompts to elicit specific responses or behaviors from LLMs. Designing prompts that include explicit instructions, contextual cues, or specific framing techniques helps guide the LLM generation process. By providing clear guidance and context, GPT prompt engineering reduces ambiguity and helps the model generate more reliable and consistent responses.
Elements of an indication
This is the list of elements that make up a well-crafted message:
- Context: Introducing background details or providing a brief introduction helps the LLM understand the topic and serves as a starting point for discussion.
- Instructions: Crafting clear and concise questions ensures that the model's response stays focused on the desired topic. For example, the model could be asked to “summarize the chapter in less than 100 words using plain English.”
- Entry examples: Providing specific examples to the model helps generate personalized responses. For example, if a customer complains, “The product I received is damaged,” the model can propose an appropriate response and suggest possible refund options.
- Output format: Specifying the desired format for the response, such as a bulleted list, paragraph, or code snippet, guides the LLM in structuring its output accordingly. For example, you might ask for “step-by-step instructions using numbered lists.”
- Reasoning: Iteratively adjusting and refining cues based on model responses can significantly improve the quality of the output. Chain-of-thought prompts, for example, break down multi-step problems into intermediate steps, enabling complex reasoning capabilities beyond standard prompting methods.
- Quick adjustment: Tuning cues based on specific use cases or domains improves model performance on particular tasks or data sets.
- Refinement using interactive queries: Iteratively adjusting and refining prompts based on model responses improves the quality of the results and allows the LLM to use reasoning to derive the final answer, significantly reducing hallucinations.
Positive framing
Using positive instead of negative instructions has been found to produce better results (i.e., “do” instead of “don't”). Example of negative framing:
Do not ask the user more than 1 question at a time. Example of positive framing: When you ask the user for information, ask a maximum of 1 question at a time.
Also Read: Are LLMs Outsmarting Humans in Crafting Persuasive Misinformation?
Recovery Augmented Generation (RAG)
Recall Augmented Generation (RAG) is the process of augmenting the LLM model with up-to-date, domain-specific knowledge to increase the accuracy and auditability of the model response. This is a powerful technique that combines rapid engineering with context retrieval from external data sources to improve the performance and relevance of LLMs. By basing the model on additional information, it allows for more accurate and context-aware responses.
This approach can be beneficial for various applications such as question answering chatbots, search engines, and knowledge engines. Using RAGs, LLMs can present accurate information with source attribution, improving user confidence and reducing the need for continuous model training on new data.
Model parameter tuning
Different model parameters such as temperature, frequency penalty and top-p significantly influence the result created by LLMs. Higher temperature settings encourage more randomness and creativity, while lower settings make the result more predictable. Increasing the frequency penalty value causes the model to use repeated words more sparingly. Similarly, increasing the value of the presence penalty increases the probability of generating words that have not yet been used in the output.
The top-p parameter regulates the variety of responses by setting a cumulative probability threshold for word selection. In general, these parameters allow for adjustments and a balance between generating varied responses and maintaining accuracy. Therefore, adjusting these parameters decreases the probability that the model will imagine responses.
Model development/enrichment
- Fine tuning a pre-trained LLM: Fine-tuning is the process in which we train a pre-trained model with a smaller, task-specific labeled data set. By making adjustments to a data set for a specific task, the LLM can capture the nuances of that domain. This is especially vital in areas with jargon, concepts or specialized structures, such as legal documents, medical texts or financial reports. As a result, when faced with unseen examples of a specific domain or task, the model is likely to make predictions or generate results with greater accuracy and relevance.
- Fully customized LLM: An LLM model can be developed from scratch only from knowledge that is accurate and relevant to its domain. Doing so will help the model better understand the relationships and patterns within a particular topic. This will reduce the chances of hallucinations, although it will not eliminate them completely. However, creating your own LLM is computationally expensive and requires enormous expertise.
Human supervision
Incorporating human oversight, preferably by subject matter experts with robust review processes to validate the results generated by the language model, particularly in sensitive or high-risk applications where hallucinations can have significant consequences, can greatly help in dealing with with erroneous information. Human reviewers can identify and correct hallucinatory texts before disseminating them or using them in critical contexts.
General user education and awareness
It is essential to educate users and stakeholders about the limitations and risks of language models, including their potential to generate misleading text. We should encourage users to carefully evaluate and verify results, especially when accuracy is essential. It is important to develop and follow ethical guidelines and policies governing the use of language models, particularly in areas where misleading information could cause harm. We must establish clear guidelines for the responsible use of ai, including content moderation, detecting misinformation, and preventing offensive content.
Continued research into the mitigation of LLM hallucinations recognizes that, while complete elimination can be challenging, implementation of preventive measures can substantially decrease their frequency. It is crucial to emphasize the importance of responsible and thoughtful engagement with ai systems and cultivate greater awareness to maintain the necessary balance in utilizing the technology effectively without causing harm.
Conclusion
The prevalence of hallucinations in large language models (LLMs) poses a significant challenge despite several empirical efforts to mitigate them. While these strategies offer valuable information, the fundamental question of complete elimination remains unanswered.
I hope this article has shed light on hallucinations in LLMs and provided strategies to address them. Let me know your thoughts in the comments section below.
Reference: