HomeVideos

Never Trust An LLM

Now Playing

Never Trust An LLM

Transcript

432 segments

0:00

LLMs lie. They lie all the time. They

0:02

lie in different ways. They lie so often

0:05

it's been given a term, hallucination.

0:06

These hallucinations are so unbelievably

0:08

common that I am now paranoid about

0:11

everything an LLM says to me and I will

0:13

never ever trust an LLM. I'm a software

0:16

developer and every single other

0:18

software developer I speak to has this

0:20

same intuition having worked with LLMs

0:22

for the past 6 months. Maybe you also

0:24

have this intuition, but maybe someone

0:26

you know doesn't. Well, I'm making this

0:28

video so that you can share this video

0:30

with that person so that they never

0:32

again trust an LLM implicitly. I'm

0:34

finding that even the very very smart

0:35

people in my life for some reason don't

0:37

have this intuition that LLMs

0:39

hallucinate all the time. Now, don't get

0:41

me wrong. I'm really pro LLM. I really

0:44

like LLMs. I think LLMs have massively

0:46

improved my quality of life in terms of

0:49

my job, in terms of what they can

0:51

produce. I think LLMs are great, but

0:54

they have massive downsides and because

0:56

they're presented so beautifully, then

0:58

people just don't realize that. So,

1:00

we're going to work through three

1:01

things. We're going to look at all the

1:02

different types of hallucinations. We're

1:04

going to look at why hallucinations even

1:06

happen in the first place and why it's

1:07

such a hard problem to solve. And then

1:09

we're going to look at how to work

1:10

around them when you're working with

1:12

LLMs day to day. I'm going to explain

1:13

these to you in simple terms because the

1:15

simple terms are the only ones I really

1:17

know. I've been working with LLMs for,

1:19

you know, I don't know, year and a half

1:20

or something, but I I'm I'm not a

1:22

machine learning expert. I don't work at

1:24

OpenAI or anything. I'm just coming at

1:26

this from someone who likes to talk

1:28

about LLMs and who likes to use them day

1:30

to day. I'm going to reference a couple

1:31

of academic papers which I will put

1:33

below. In fact, the first one is this

1:34

comprehensive taxonomy of hallucinations

1:37

in large language models. In other

1:38

words, these guys went and looked at all

1:41

of the different ways that language

1:42

models can hallucinate and figured out

1:44

the exact taxonomy of what types of

1:46

hallucinations can happen. Perfect for

1:48

us. The first one is pretty easy to

1:49

think about. It's factual errors. This

1:51

has been present since the very

1:53

beginning of LLMs. For instance, when

1:55

Google announced Bard, they said in its

1:58

"experimental conversational AI service

2:00

powered by LaMDA", it said, "What new

2:02

discoveries from the James Webb Space

2:04

Telescope can I tell my 9-year-old

2:06

about?" And it said, "JWST took the very

2:09

first pictures of a planet outside of

2:11

our own solar system." This was in the

2:12

freaking advert. They didn't even try to

2:14

road test this.

2:16

This is just wrong. It's a

2:17

hallucination. After posting this,

2:18

Alphabet's share price dropped like 8%.

2:21

Now, it's crucial to say here, in this

2:23

case, they didn't pass the LLM a

2:25

document explaining all about the James

2:27

Webb Space Telescope and the new

2:28

discoveries. It seems like they just

2:30

asked it based on its training data.

2:32

This is a super important distinction

2:34

that the paper actually makes. There are

2:36

two types of hallucinations. There are

2:39

hallucinations based on intrinsic

2:41

information and extrinsic information.

2:43

Intrinsic information is stuff that

2:45

you've sent to the LLM during this

2:47

conversation with the LLM. For instance,

2:49

I'll go on Anthropic here and I'll tell

2:51

it, "My cat is called Bandit." It gives

2:53

some reply here saying, "That's a great

2:54

name for a cat." Wonderful, thank you.

2:56

And now I'll ask it, "What is my cat's

2:59

name?" Then, of course, it says, "Your

3:00

cat's name is Bandit. You just told me

3:02

in your previous message." So, if the

3:03

LLM for some reason got that wrong, then

3:05

it would be an intrinsic hallucination.

3:07

Whereas, if I start a new conversation

3:08

with the LLM and I say, "What is my

3:10

cat's name?" then, very good, in this

3:12

case, it has not attempted to guess my

3:14

cat's name. It's just saying, "I don't

3:16

have any information about your cat in

3:17

my context." And so, if it attempted to

3:19

guess here, then it would be an

3:20

extrinsic hallucination. The next type

3:22

of hallucination is fabricated entities,

3:25

inventing stuff that just doesn't exist.

3:26

This is actually really important for

3:28

developers because developers rely on

3:29

these things called packages that

3:31

package up useful tools to help them do

3:33

their work. So, if you ask an LLM, "Does

3:35

a package exist for this purpose?" then

3:38

it's very likely to just say, "Yep, it

3:40

does." This has personally happened to

3:42

me dozens of times, and it's now opening

3:44

up developers to supply chain malware

3:47

attacks. Attackers can exploit a common

3:49

AI experience, false recommendations, to

3:51

spread malicious code via developers

3:53

that use ChatGPT to create software.

3:55

This is an old article, but this

3:56

literally just happened to me the other

3:58

day. And it's not just packages, LLMs

3:59

will make up government departments,

4:01

they will make up laws that don't exist,

4:02

they will make up all sorts of things.

4:04

The next one is contextual

4:06

inconsistency. In other words, ignoring

4:08

or contradicting context that you

4:09

explicitly provide. This would be an

4:11

intrinsic hallucination like what we saw

4:13

before. This article is from 2024. Air

4:15

Canada found liable for chatbot's bad

4:17

advice on plane tickets. This guy called

4:19

Jake Moffatt asked the Air Canada

4:21

chatbot about their bereavement policy.

4:23

And even though the bereavement policy

4:25

was probably in the LLM's context, it

4:27

had been explicitly told about it,

4:28

explicitly passed into its context, it

4:31

just made something up. It said, "If you

4:32

need to travel immediately or you've

4:34

already traveled and would like to

4:35

submit your ticket for a reduced

4:37

bereavement rate, kindly do so within 90

4:39

days of the ticket your was issued." But

4:41

when they tried to get their money back,

4:42

they basically responded and admitted

4:44

the chatbot had had provided misleading

4:47

words. In other words, a contextual

4:49

inconsistency. An inconsistency with

4:51

something that the LLM just had in its

4:53

own context window. This would be kind

4:55

of like the LLM not knowing my cat's

4:56

name just after I gave it to it. It's

4:59

baffling that these things occur, but

5:00

they do. Now, I could go through all 10

5:02

of these terms from this paper and try

5:04

to explain to you about each and every

5:06

one of them, but I think you're starting

5:07

to get the picture. LLMs are unreliable

5:10

and especially if you're relying on

5:12

their extrinsic knowledge. My experience

5:14

with LLMs is that they're much, much

5:16

more reliable when you send them the

5:18

information first. Of course, why

5:19

wouldn't they be? But if you're relying

5:21

on their extrinsic knowledge from their

5:23

training sets, then you're going to be

5:24

disappointed. We should talk in a kind

5:25

of basic sense about why this is, first

5:28

of all. The process of training an LLM,

5:30

of taking a bunch of training data and

5:33

turning it into something smaller, is

5:35

essentially a compression. You take,

5:37

let's say, a massive file with all of

5:40

the stuff that you've gathered over the

5:42

course of all of your data scraping,

5:44

huge amounts of data sets about all the

5:47

different, you know, text or everything

5:49

on the internet, let's say. You then,

5:51

through some very clever mechanisms that

5:52

I won't go into, you compress it down

5:54

into a much smaller size that can fit on

5:57

a GPU. And this compressed version of

6:00

that training set is what we can think

6:01

of as the LLM's brain or its memory or

6:03

its data store. And the output here is

6:06

much, much, much smaller than the input.

6:09

Now, when you're taking some massive

6:10

training set and you're squishing it

6:12

down into a smaller size, you're going

6:14

to lose stuff. Let's take this photo of

6:16

this beautiful man and let's compress it

6:19

a little bit. Okay, it's not bad. You

6:20

can still see it's me, but I've lost a

6:22

bit of definition here. You can't quite

6:25

tell how many wrinkles there are on my

6:26

forehead, for instance. We can press it

6:27

a bit more and the skin has been kind of

6:29

smoothed out. I've lost a lot of

6:31

definition. And you go all the way and I

6:33

just end up like this blobby-looking

6:35

person that you can barely recognize

6:36

it's me. When you ask an LLM a question

6:38

and it's not in their training set, I

6:40

want you to imagine that this is the

6:42

picture that they're seeing of the

6:43

information they have. Just a blobby,

6:45

crappy, hyper-compressed version of the

6:47

information that was once there. And

6:49

look, you can still get good answers out

6:51

of this image. It can still say, "Okay,

6:52

what color is the little cap on the end

6:54

of my microphone here?" It is blue,

6:56

right? That is visible from the image.

6:58

You could probably just about say that

7:00

this man doesn't have any hair on his

7:01

head, too. But if you ask about who it

7:03

is or how old this person is or, you

7:06

know, any of that, it's not going to

7:07

have a clue. So, the question then

7:09

becomes, if LLMs only have this crappy,

7:11

low-res version of all of the

7:13

information in the world, why are they

7:15

so insistent on guessing? Because an LLM

7:18

presented with this information and you

7:19

asked who they are, they will often just

7:22

have a go and guess. Now, the answer for

7:24

this comes from the second paper that I

7:25

want to link to, which is below. It's

7:27

from OpenAI and the title is Why

7:29

Language Models Hallucinate. Like

7:30

students facing hard exam questions,

7:32

large language models sometimes guess

7:35

when uncertain, producing plausible yet

7:37

incorrect statements instead of

7:38

admitting uncertainty. We argue that the

7:40

language models hallucinate because the

7:42

training and evaluation procedures

7:44

reward guessing over acknowledging

7:46

uncertainty. Now, what do they mean by

7:48

evaluation procedures? What are they

7:49

talking about? Well, LLMs prove that

7:51

they're getting better over time by

7:53

showing their numbers in benchmarks. For

7:55

instance, here, this one is LiveBench. I

7:57

mean, I think this is a leaderboard of

7:58

multiple benchmarks, and you can see

8:00

that all of the top models here are

8:02

rated a number out of 100 on how good

8:05

they are at different things. For

8:07

instance, reasoning, coding, agentic

8:09

coding, mathematics, data analysis,

8:11

language, etc. Being at the top of these

8:12

leaderboards is incredibly valuable for

8:15

these companies. If you can say you have

8:17

the best model in the world at

8:18

something, then everyone who's doing

8:20

that thing is going to want to use your

8:22

model because it's actually really easy

8:24

to swap models. You just like stop using

8:26

one thing and go and use another thing.

8:28

And there's a tension that these

8:29

benchmarks introduce because if your

8:32

model is really well-tuned to say I

8:35

don't know something when it comes to

8:37

let's say maths, then it's probably not

8:39

going to score very well on the maths

8:41

benchmark because it might just be

8:42

better on average for it to have a

8:44

guess. In other words, you miss all of

8:46

the shots that you don't take, and so

8:48

LLMs try to take as many shots as

8:50

possible. In fact, there's kind of a

8:52

tension inherent in designing LLMs, and

8:54

you can think of this kind of by

8:56

thinking of it in human terms. It's

8:58

quite rare to meet a person who's

9:00

really, really smart, but also really

9:02

humble about their smartness. People who

9:04

are really smart, especially in an exam

9:06

context, will probably be smart enough

9:08

to get close to the right answer and

9:11

will trust themselves and be confident

9:12

enough to actually work it out. But

9:14

people who are humble enough to say I

9:15

don't know will probably go in the

9:17

opposite direction where they might not

9:19

be confident enough to actually get it

9:21

done. However, if you're really smart,

9:23

you're often going to be way too

9:25

confident about your own answers, and

9:27

this will lead to hallucinations. In

9:29

other words, all the stuff that we've

9:30

been talking about so far. But if you're

9:32

on the other side and you're not

9:34

confident enough, then you're probably

9:35

not going to do really well in the

9:37

domains where you need really, really

9:39

deep thinking. And the people who grade

9:41

LLMs and who train LLMs need to figure

9:43

out somewhere on this line, and I'm not

9:46

sure it's a solvable problem. Or rather,

9:49

it might be solvable, but it's going to

9:50

be someone way above my pay grade. So,

9:52

to sum it up, LLMs hallucinate because

9:54

guessing is more highly rewarded than

9:57

refusal, which to be honest is kind of

10:00

true in most walks of life anyway. So,

10:02

then we now know how LLMs hallucinate,

10:04

and we kind of understand why LLMs

10:06

hallucinate. But why, after all of that,

10:08

am I still so pro AI? Why do I still

10:10

like AI? Well, it's because when you

10:12

actually pass them intrinsic information

10:15

here, if you actually send them stuff,

10:17

if you get them to peruse a big document

10:20

or something, then it tends to be

10:22

really, really accurate at way more

10:25

accurate than extrinsic information. So,

10:27

when I'm coding, for instance, I can

10:29

pass my code base or, you know, big

10:31

files to the LLM and get it to answer

10:33

questions about it, get it to explore

10:35

the code, and it will give me really,

10:36

really good insights as to what it's

10:38

doing. In other words, when you're using

10:40

AI, you need to always make sure that

10:42

you're providing it the information it

10:44

needs to succeed. But so, you might ask,

10:46

"That doesn't make any sense, because I

10:48

often use LLMs for searching for

10:50

information. If I have a question that I

10:52

don't have the answer to, I can't use

10:54

this intrinsic stuff. All I have to rely

10:56

on is extrinsic stuff." So, I'm going to

10:57

tell you about a four-word prompt that

10:59

will allow you to get the LLM to fetch

11:03

intrinsic information that it doesn't

11:04

yet Use your search tool. Most chatbots

11:08

or most, let's call them agent

11:09

harnesses, have some kind of tool that

11:12

the LLM can use in order to search the

11:15

web. For instance, in Claude here, if we

11:16

go to files, connectors, and blah blah

11:18

blah blah blah, then we have this little

11:20

web search thing just inside there, and

11:22

I always have this turned on. For

11:25

instance, I can ask it which Arsenal

11:27

players are injured right now, and it

11:29

will go and search the web and try to

11:32

find the information. So, here we go.

11:33

It's saying, "Here's the current Arsenal

11:34

injury picture, blah, blah, blah, blah,

11:36

blah." And as you can see, there are

11:37

citations

11:39

based on where it's got the information

11:41

from. Now, it's done a good job this

11:42

time because, you know, Sonnet is a good

11:44

model and I like this tool in general.

11:46

But, many tools will not by default go

11:49

and do this, especially if the model is

11:51

confident that it knows it and its

11:53

training set if it doesn't need to use

11:55

its search tool. In other words, in

11:56

order to use its search tool, it needs

11:58

to be humble enough to be able to say,

12:00

"I don't know. I need to go and fetch

12:01

this." And so, if it's like tuned to be

12:04

really smart, it might just go, "Oh, I

12:05

know the answer. Let me just repeat it

12:07

to you." And so, whenever you're

12:09

prompting the LLM to ask it for

12:10

information, say, "Use your search

12:13

tool." Because then it will pull the

12:15

articles into its context and it will

12:17

answer based on those articles. And

12:19

you'll be less likely to get

12:21

hallucinations because you're relying on

12:23

intrinsic information, information in

12:25

the context window. However, remember,

12:27

there's a category of hallucinations

12:28

called contextual inconsistency. In

12:31

other words, even stuff that you provide

12:33

explicitly to the LLM might just be

12:36

ignored. Even if you're an airline and

12:38

you have a chatbot with a bereavement

12:39

policy explicitly passed to it, it might

12:42

still get it wrong. And so, for really

12:43

critical stuff, for stuff that's life or

12:46

death, for health-related stuff,

12:48

especially for legal stuff, you

12:50

basically need to ask it, "Use your

12:52

search tool." But, you then need to go

12:54

and actually read the documents

12:55

yourselves. This happens all the time

12:57

for me when I'm coding, too. The LLM

12:59

will read some code and it might just

13:01

misinterpret it or not know the full

13:03

context, and so it spews something out

13:05

very confidently. And I then have to

13:07

say, "No, that's actually not quite

13:09

right." So, hopefully this video has

13:10

given you a bit more understanding about

13:12

what the limits of LLMs are and how you

13:14

can work around them. And if you have

13:16

someone in your life who you want to be

13:18

better with LLMs or you notice them just

13:20

slightly using them wrong, then maybe

13:22

send them this video. And hopefully we

13:24

can build a world where people don't

13:25

trust LLMs and instead use them for what

13:29

they're good at. For instance, they are

13:30

very, very good at writing code and I'm

13:33

running a Claude code for real engineers

13:36

course over the next 2 weeks. If you dig

13:38

that or you dig the idea that real

13:39

engineering principles can still be used

13:41

in the AI age, in fact they're better

13:43

than ever, then sign up to my newsletter

13:45

below or sign up to learn about when the

13:47

next cohort is happening. Thanks for

13:48

watching folks. This was a bit of a

13:50

change of pace for me. I don't usually

13:51

make these kind of wider videos or

13:54

videos for a wider audience, but I kind

13:56

of just wanted to get this out there.

13:57

Thanks for watching and I'll see you in

13:59

the next one.

Interactive Summary

The video discusses the phenomenon of 'hallucinations' in Large Language Models (LLMs), where models confidently provide incorrect or fabricated information. The narrator, a software developer, explains the different types of hallucinations—such as factual errors, fabricated entities, and contextual inconsistencies—and the fundamental reasons behind them, particularly the tension between being 'smart' and 'humble' in model training. The video advises that LLMs are much more reliable when provided with 'intrinsic' information (data within the conversation context) rather than relying on their 'extrinsic' training knowledge. Practical tips are shared, such as explicitly instructing models to 'use your search tool' to force them to ground their responses in external, real-time data, while emphasizing the need for human verification for critical tasks.

Suggested questions

3 ready-made prompts