print("AI Hallucinations")
This is the first mid-series special!
The mid-series special would be on random interesting topics on Artificial Intelligence. This would be different from the AI series, a little detour 😊. It'll not be weekly, it'll come when it comes 😶. Feel free to send me ideas to write about.
Now let us start what we have come here to do 👽.
If you have used ChatGPT or other similar chatbots long enough you will have noticed that sometimes the chatbot says some things that are not correct, sometimes it outrightly just makes things up, and you'll only know if you already have an idea what the answer should be. There is a term for that it's called AI Hallucinations.
AI Hallucinations are outputs of Large Language Models (LLMs) that deviate from facts or contextual logic, ranging from minor inconsistencies to completely fabricated or contradictory statements. LLMs are the foundation on which platforms like ChatGPT and Gemini are built.
There is recently a story about a lawyer in New York who used ChatGPT to prepare for a case but the court later found out that some of the cases filed were made up 🙂, you can read the full story here.
Based on the level of detail, AI Hallucinations can be broken down into these:
Sentence Contradiction: Where an LLM generates a sentence that contradicts one of the previous sentences. For example when an LLM says Pluto is a planet in one sentence and says it is not in another sentence.
Prompt Contradiction: Where it says(does) the opposite of what was asked. Prompt here means questions or requests sent to the LLM. For example when you ask an LLM for a list of girl's names and it returns a list of boy's names.
Factual Contradiction: Factual errors are simply what they mean, giving wrong factual answers. For example, when an LLM lists Pluto as a planet while it is not.
Nonsensical/Irrelevant Contradictions: These are errors that are irrelevant to the prompt sent. For example, when an LLM is prompted for a list of planets and after returning the list of planets it says something irrelevant like Argentina is in South America.
Now why do we have all these AI hallucinations?
Data quality: The data the AI was trained with can contribute a lot to the type of hallucinations. Most LLMs are trained from data from Wikipedia, Reddit, Twitter, and so on. As we can see these platforms have a lot of factually incorrect information and biased opinions etc.
Generation methods: There are a lot of LLM generation methods such as Beam Search and Greedy Sampling. These also impact the hallucination rate of the model.
Input context: I do this a lot myself, this involves writing a message to the LLM without enough context or information. This cause of hallucinations is the user. When the context of the information to the LLM is not explicit, it'll increase the chance of hallucinations.
Finally, how do we minimize AI Hallucinations?
Clear and Specific Prompts: Sending clear and specific messages to the LLM helps reduce hallucinations a lot.
Active Mitigations Strategies: These can be used where the LLM has settings configurations. So specific settings can be set for peculiar situations.
Multi-Shot Prompting: This involves giving explicit examples to make the context clearer for the LLM to understand better our intent.
Now that we are here we might as well talk about other risks of using LLMs 🙂.
Risks of using LLMS
Bias: LLMs are mostly trained on humongous(big word lol) datasets from the internet. So most LLMs lean on the opinion of the datasets it's trained on.
Now this is something we've seen a lot in other technologies not just LLMs, from phone cameras, face recognition systems, and voice recognition working well for "White" people while being terrible on "Colored" people. Which is a result of the training dataset.
A lot of companies like Apple and Alphabet noticed this and have been intentional in improving those technologies to increase inclusion.
Consent: A lot of creators have been complaining about their work being taken to train AI models without their approval or knowledge.
Photographers and artists' years of work have been used to train AI models that will not just copy their style but also use part of their art to generate new images or videos.
Security: LLMs can be used for a lot of malicious tasks like scams, spam, etc.
Hackers can infiltrate LLMs to make them deviate from their purpose by making them support things like racism, crime, etc, this is called Jail Breaking.
Another attack is an Indirect Prompt Injection, which is when a third party alters a website by adding hidden data to change the AI's behavior. That'll make the AI send malicious information to the user without the AI creators even knowing.
Now we know about AI hallucinations, why they happen, how to minimize them for optimal performance, and also the risks of using LLMS. This should help us leverage our knowledge to get the best out of LLMs in our various interactions for increased productivity and accuracy.
Retrieval Augmented Generation (RAG)
Now to fix AI hallucinations at the core, there is a new technique called Retrieval Augmented Generation (RAG). This uses the approach of verification where an LLM has to confirm its reply against a known source before replying to an input or prompt as it's called. If the LLM can not verify its reply it should be able to say it does not know instead of making things up. This solves two important problems:
No source data: All factual information should have verifiable sources. In this approach whenever the LLM is giving a response it would list the sources of the information as well. This is incredible because it could have saved the lawyer we mentioned earlier who filed made-up cases.
Data that is out of date: This is important because a lot of facts change over time and the LLM can only reply based on the data it was trained on which can be out of date. Using RAG, the LLM would always check its reply with a source that is kept up to date. So if the data the LLM was trained with says Pluto was a planet but scientists recently said it was not, the LLM would remove it from the list of planets when we prompt it.
Huang Jensen the co-founder and CEO of NVIDIA the famous GPU company powering the future of AI has this to say in a recent interview about AI hallucination;
“Add a rule: For every single answer, you have to look up the answer. The AI shouldn’t just answer; it should do research first to determine which of the answers are the best.”
Also, Perplexity, a new AI-first search engine giving Google a run for its money uses RAG to eliminate AI hallucinations by keeping their responses up to date with verifiable sources.
Given the gravity of some of these risks and limitations of AI the European Union recently created laws to regulate the use of AI called the EU Artificial Intelligence Act. This includes clauses like having a supervisor for educational AI uses, because as we know AI is not perfect, so it’ll be nice not to teach students the wrong things. You can read more about it here.
How was the first mid-series special? 👽
See you in the next series chapter! Ciao 🤗