Machine Madness: Spotting and Avoiding AI Hallucinations

“How fast would you have to accelerate to travel 20 light years in one thousand years of objective time, and what would your final velocity be?”

For a physicist, I imagine it wouldn’t be a very difficult question to answer—just a matter of plugging the numbers into the right equations and solving for X. Since I’m not a physicist, I take the easy way out and pull up ChatGPT. In seconds, my screen is filled with numbers and explanations I can only half-follow, featuring phrases like “relativistic rocket equation” and “hyperbolic cosine function.”  Luckily, all I really care about are the numbers at the bottom of the pile: 1.04 x 10-4 meters per second squared, and 1,038.84 kilometers per second.

Is that the right answer?  I honestly have no idea, but I also honestly don’t care that much. All I’m doing is writing a short science fiction story; the worst I can expect is a scolding email from a reader with a better grasp of the math than I. But what if my question actually mattered?  If reputations are on the line, if lives are on the line, how do I know if I can trust a chatbot’s answer? And perhaps more importantly, given the rapid deployment of such systems, is there anything I can do to avoid or spot inaccuracies?

Artificial Intelligence (AI) systems lie—or, as programmers prefer to say, hallucinate—all the time. Even if we haven’t run across a mistake ourselves, I’m sure most of us have at least heard about some of the high-profile examples, such as when Google’s new AI spat out the wrong answers during its first public demonstrations. Worse, they’ve been known to argue when the user points out the error, sticking to their guns as to why their original answer was correct. Some models are better than others, but none are perfect. A 2023 collaboration between researchers at the University of Washington and Meta found that even the best systems, such as GPT4, can have error rates more than four times higher than human controls. Tech companies and universities around the world are working hard to improve performance, but hallucinations aren’t going away anytime soon. If anything, the problem might get worse—as outputs become more reliable, users are likely to become less and less careful about double-checking their answers.

And researchers like Emily Bender, a linguistics professor and director of the University of Washington’s Computational Linguistics Laboratory, have little hope that AI—or at least the current manifestation in the form of so-called Large Language Models (LLMs)—will ever be entirely lucid. “This isn’t fixable,” she said flatly during an interview with PBS. “It’s inherent in the mismatch between the technology and the proposed use cases.” 

At the root of the problem is the fact that systems like ChatGPT aren’t consulting some secret list of knowledge when they answer your questions. They’re essentially no different from the autocorrect on your phone, just on a grander scale. All they can do is look at what you wrote and predict what comes next, based on patterns they recognize from existing material. If you’re looking for something that’s been written about a lot, you’re probably safe; if the information only exists in a few places—and especially if it looks similar to something more widely discussed, such as the birthday of William Clinton, the historical British general, as opposed to Bill Clinton, the forty-second president of the United States—an AI is much more likely to get it wrong.

And it can, unfortunately, be hard to spot when hallucinations do pop up. They’re stealthy by their very nature; after all, the whole reason the AI spat them out in the first place was that they made for a seamless response. You can double-check information with other resources, but that can be time-consuming and difficult, especially when it’s a topic you don’t know much about.

“I think the first thing is to be extremely wary, initially, of entities which are like names, books, locations, years,” said Vidhisha Balachandran, a PhD student at Carnegie Mellon University who’s been thinking about these sorts of problems for years—since before ChatGPT ever exploded onto the public scene, in fact. She went on to explain that while Large Language Models (LLM) are no better or worse at predicting names than any other word, they represent a point where a single substitution can invalidate the entire response. “Tom Cruise starred in the film Top Gun” instead of “Tom Cruise starred in the movie Top Gun” is a meaningless change; “Tom Hanks starred in the movie Top Gun” is simply wrong.

Math is another area where answers are either right or wrong. Numbers, Balachandran explained, are “very easy to replace by just pure probabilities.” There are only ten digits, after all, and no universal rules about what order they occur in. The number 845 is just as reasonable as 855, and the substitution is just one digit among many—but that single error will ruin an entire chain of math.

Once you understand how LLMs “think,” there are some simple strategies you can use to reduce the likelihood of hallucinations. “A very quick hack that anyone can do is using different styles of prompts,” Balachandran told me. Ask the same question several times in a row, phrasing it differently each time, then look for commonalities in the results. Facts that the model is confident about will show up more often than ones where it had to “guess.”  You can even be lazy and get the AI to do the whole process for you—come up with a prompt, ask it to come up with a handful of similar prompts, run each in turn, then ask it to answer the original question using only the data from its recent answers.

Another technique that’s been consistently shown to work, she added, is something called “chain-of-thought prompting.” If a process requires multiple steps of reasoning—such as my original question about interstellar travel—don’t ask the AI to do more than one at a time. That way you can check each step; errors are less likely to compound themselves and give a wildly inaccurate answer.

For instance, instead of asking “how fast would you have to accelerate to travel 20 light years in one thousand years of objective time,” I might have gotten a better answer if I’d started with “what equations will I need,” followed by “how should they be rearranged” and “what numbers should I put where,” and only then feed it the final equation to solve.

When all else fails, the humble Google search can be a surprisingly effective verification tool. Search engines and AIs both depend on things that have already been written and uploaded. (And, in the case of AIs, that have already been used to train the models—ChatGPT-3, for example, only “knows” things that were published before 2021.) If a conventional search doesn’t turn up much in the way of relevant data, ChatGPT and its ilk are unlikely to do any better. If Google doesn’t come up with many results, or starts directing you to rambling blog posts with twenty fonts, that’s a good sign something has gone wrong.

It’s possible that these strategies will become obsolete, as AIs continue to improve their reasoning skills—at which point we’ll probably need new tricks to make sure we’re getting accurate results. Check, check, and double-check your results, however you can. Like most who work in the field, Balachandran reiterated that hallucinations are only going to get more dangerous as systems get more reliable and people become more complacent. “It’s important even when the system’s starting to get better,” she reminded me. “Make sure you still have the final agency of what goes in your final output.”

References

Balachandran, Vidhisha (Aug 9th, 2023). Zoom interview.

Field, Hayden. “OpenAI is pursuing a new way to fight A.I. ‘hallucinations’.” CNBC, May 31, 2023. https://www.cnbc.com/2023/05/31/openai-is-pursuing-a-new-way-to-fight-ai-hallucinations.html.

Min, Sewon, Kalpesh, Krishna, et al. “FactScore: Fine-grained Atomic Evaluation of Factual Precision in Long Form Text Generation.” arXiv preprint 2305.14251v1.\

O’Brian, Matt. “Chatbots can make things up. Can we fix AI’s hallucination problem?” PBS NewsHour, August 1, 2023. https://www.pbs.org/newshour/science/chatbots-can-make-things-up-can-we-fix-ais-hallucination-problem.

Vincent, James. “Google’s AI chatbot Bard makes factual error in first demo.” The Verge, February 8, 2023. https://www.theverge.com/2023/2/8/23590864/google-ai-chatbot-bard-mistake-error-exoplanet-demo.

Weise, Karen, and Kade Metz. “When AI Chatbots Hallucinate.” New York Times, May 1, 2023. https://www.nytimes.com/2023/05/01/business/ai-chatbots-hallucination.html.