Learning Library

← Back to Library

Mitigating AI Hallucinations with Prompts

Key Points

  • AI hallucinations are common in large language models, producing misleading or factually incorrect answers such as false personal experiences, faulty code, or wrong historical dates.
  • Hallucinations arise from two sources: intentional adversarial injection of malicious data (adversarial hallucinations) and unintentional errors due to training on large, unlabeled, and sometimes conflicting datasets.
  • The architecture of encoder‑decoder models can also contribute to unintentional hallucinations, as can the way models handle ambiguous or incomplete information.
  • Prompting strategies can help curb hallucinations, with temperature prompting being a key technique that adjusts the model’s “greediness”: lower temperatures (e.g., 0) promote more deterministic, accurate outputs, while higher temperatures (up to 1) increase creativity but also risk inaccuracy.
  • Understanding these causes and applying appropriate prompting controls are essential for mitigating hallucinations in AI applications, especially in high‑stakes domains like cybersecurity and quantitative analysis.

Full Transcript

# Mitigating AI Hallucinations with Prompts **Source:** [https://www.youtube.com/watch?v=ZFKvTIADp0k](https://www.youtube.com/watch?v=ZFKvTIADp0k) **Duration:** 00:08:56 ## Summary - AI hallucinations are common in large language models, producing misleading or factually incorrect answers such as false personal experiences, faulty code, or wrong historical dates. - Hallucinations arise from two sources: intentional adversarial injection of malicious data (adversarial hallucinations) and unintentional errors due to training on large, unlabeled, and sometimes conflicting datasets. - The architecture of encoder‑decoder models can also contribute to unintentional hallucinations, as can the way models handle ambiguous or incomplete information. - Prompting strategies can help curb hallucinations, with temperature prompting being a key technique that adjusts the model’s “greediness”: lower temperatures (e.g., 0) promote more deterministic, accurate outputs, while higher temperatures (up to 1) increase creativity but also risk inaccuracy. - Understanding these causes and applying appropriate prompting controls are essential for mitigating hallucinations in AI applications, especially in high‑stakes domains like cybersecurity and quantitative analysis. ## Sections - [00:00:00](https://www.youtube.com/watch?v=ZFKvTIADp0k&t=0s) **Understanding AI Hallucinations** - The speaker outlines how large language models can generate misleading or false outputs—dubbed hallucinations—provides illustrative examples, and differentiates between intentional (adversarial) and unintentional occurrences. ## Full Transcript
0:00have you been to Mars me neither but 0:03according to an llm or a large language 0:06model out there I have been to Mars in 0:081950 right it is not uncommon for the 0:11large language models to generate 0:13misleading data such as this right let's 0:16look at some more examples right a large 0:19language model creating or generating a 0:22python script that looks logically 0:25correct but totally 0:27unexecuted right another example could 0:30be a mathematical or a financial 0:32calculation that the large language 0:34model creates is incorrect totally 0:37misleading and incorrect it could also 0:40be giving you incorrect dates on major 0:43events such as moon landing right these 0:46are all very good examples of AI 0:49hallucinations so AI hallucinations is a 0:52very well-known phenomen on by the large 0:54language models this is where the AI 0:57models are generating misleading 1:00and factually Incorrect and sometimes 1:03even nonsensical responses for the 1:05questions you are asking you see 1:07hallucinations commonly where in 1:10question answering or when you are 1:12asking the models to generate summaries 1:16so the hallucinations can be 1:17statistically inaccurate and factually 1:20incorrect right so why do hallucinations 1:24occur there could be two reasons right 1:27and there are two types of 1:28hallucinations one is intentional where 1:32for example threat actors can be 1:34injecting uh malicious data into your 1:37corporate data right that is leading to 1:41adversarial hallucinations right it is a 1:44quite common cyber security example of 1:48hallucinations now the second one is the 1:51unintentional 1:53hallucinations these hallucinations 1:55occur because of the nature innate 1:58nature of the large language models 2:00being um trained on large volumes of 2:04unlabeled data when you are using 2:07unlabeled data and that two large 2:09volumes of it there could be 2:11misrepresentations of these facts and 2:14there could be conflicting information 2:16there could be uh misleading and 2:19incomplete information also which causes 2:21the models to uh generate incorrect 2:25representations of responses right 2:29sometimes 2:30these 2:31unintentional hallucinations are also 2:34caused by the encoder and decoder models 2:37that are very uh foundational to the 2:40large language models so we are 2:43beginning to understand hallucinations 2:46quite well and we have also developed 2:49and leveraged techniques the prompting 2:51techniques that are out there in 2:53containing the AI 2:55hallucinations I'm going to talk through 2:58five different prompting techniques that 3:00we could use to contain the 3:02hallucinations in your large language 3:05model responses right the first one will 3:09be the temperature prompting technique 3:12it is actually a parameter that the 3:15sequencing models leverage um and the 3:19value of the par temperature can 3:21typically be between 0o and one right 3:25the temperature parameter is going to 3:27determine how greedy you large language 3:30model is going to be right if the 3:33temperature value is zero then it is 3:36going to be lot less greedy right in 3:38being accurate and if it is the 3:41temperature value is more one then the 3:44model is going to be very greedy and 3:46gets very creative now let's apply the 3:48temperature values 0 to one in uh with a 3:53business document where you are 3:55interested in extracting fats like in 3:58net income or a company name buyer 4:01seller Etc or also the slas of a 4:05contractual document right and you also 4:08have uh another document called a 4:10creative document where you are asking 4:13going to ask the large language model to 4:16create a poem or write a Sonet in either 4:19Keat style or Milton style right so if I 4:23were gaining asking the large language 4:26model to extract facts I would give it 4:29anywhere between 3 right and if I'm 4:33asking the large language model to 4:35extract slas from a contractual document 4:38I could go from 05 to 4:427 however if I'm asking a large language 4:46model to write a song a Sonet I would be 4:49giving it a Waring point8 because that 4:52makes the model very flexible with the 4:55words and generating that song and a 4:58Sonic okay okay the next uh uh technique 5:02my favorite uh in generating very 5:04effective outcomes is the role 5:06assignment in this you are controlling 5:08the outcomes of the responses from the 5:10larger language models by telling it to 5:14take a role of a certain Persona right 5:17for example if you have a patient 5:20document right you can tell the large 5:22language models to be a doctor to go 5:25through the symptoms and come up with a 5:27diagnosis right that is for a medical 5:31kind of a document if you were to create 5:34a um creative document then you can tell 5:37it think like kids and write a 5:40poem right or think like Milton and 5:43write a 5:44Sonet that is how you are going to tell 5:47the model to focus on the outcome that 5:50you want to come out of those models so 5:53the third very effective uh technique is 5:57called specificity right this takes the 6:00role assignment to the next level in 6:02specificity approach you are giving 6:05specific data rules and formula and the 6:09and the examples to the model to follow 6:12and get you the results that you want 6:14right uh this is a very good example of 6:17using the few short prompting technique 6:21right like Chain of Thought react and 6:25this works very very well particularly 6:27when you have a scientific 6:30calculations or you have Financial 6:32calculations and you want a model to 6:36arrive at a solution in a very 6:39methodical manner right uh this is also 6:42a very good example of um writing code 6:46by for example right you know writing 6:48code to solve a problem right use that 6:51in those examples so the next and very 6:54effective technique and by the way this 6:56is my really favorite uh approach is 6:59content grounding this is where you are 7:01making the large language models to look 7:04into your domain data right even though 7:07it is trained on the internet unlabeled 7:09data it is now focusing on your data to 7:12respond to your questions it is very 7:15useful in the business scenarios right 7:19where you are asking for security 7:22breaches or you know risk in a contract 7:24Etc so the large language model is 7:27focusing on your cont content and 7:30getting you that response response by 7:33the way rag is a really good approach to 7:37use for Content grounding retrieval 7:40augmented generation and the final and 7:43also an very 7:45effective prompting technique is the 7:48providing instructions of what to do and 7:50what not to do to the large language 7:52model right uh in a business document 7:55supposing you have five types of risks 7:58in involved but you are only interested 8:00in the infringement risk so you can tell 8:03the large language model to focus on the 8:05infringement risk similarly if you want 8:08to create a song or a poem by kids and 8:11you want only happy poems you can tell 8:14the model to do so right it works very 8:18well so try to incorporate dos and 8:20don'ts in your pting 8:22Technique there you go these are the 8:25different techniques you can use to 8:26contain hallucinations it is so critical 8:29to do that because you want to avoid 8:32harmful 8:33misinformation avoid legal 8:35implications and also build trust and 8:39confidence in leveraging the generative 8:41AI 8:42models thank you for watching before you 8:45leave please click subscribe and 8:53like