But, let's visualize LLMs. Now, one of the things that we use when visualizing LLMs, sorry, when using LLMs, is log probs. The way LLMs work is they think of the next word, one after another. By the way, I am simplifying; that is not true. What we know now from Anthropic's studies is that if you ask it for a poem that ends with "rabbit," then it should initially be just thinking of the next word. But we know that things that end with "rabbit," like "habit," have already been activated in the neural network even when it starts generating the next word. So it's almost like it's keeping the last word in mind while it's steering towards that. So my statement that it's a next-word generator is actually not correct, but it's a pretty good approximation. At the very least, anyway, like everything, it has to generate one word at a time.
So, as it generates the next word, the way it does it is by sampling from various possibilities. For example, if I asked it the question, "Suggest four wrong and one correct answer to the question, 'What is the capital of France?'" you would expect it to generate a question, a list, a set of options. And here's what it generates: "wrong: Paris," "wrong: London," "wrong: blah blah blah," "correct: Paris." Now you'll notice that it made a mistake. Now how can Paris be both wrong and right? Now these are what we call hallucinations. How exactly do they come about?
Well, let's look at what it did. The first thing that it did was generate "1." And the way it did it was, it looked at various possible words it could have generated. In this case, it said there's a 66% chance that I will say "1." I'm using the word "word" as an alternative for "token," which is how it internally thinks, but I'm going to say "word." So it says, given this kind of a question, most people and my training tell me that I should begin with the number "1." But there's also a chance that I could start with "Here," a 13% chance. There's a 7.3% chance I could start with "Sure" or "Four" or "Wrong." And there's a long list like this. I'm showing only five. From which it samples. How does it sample? We can choose. There is a parameter that we can pass to LLMs called the temperature, which says, if the temperature is zero, pick the top one. If the temperature is higher, then choose, go down the list a little bit. And the higher the temperature, think about a wider distribution.
After it's picked "1," then it says, "Now that I've picked '1'..." So it picked "1." Next, I can choose a full stop, I can choose a parenthesis. And then there's one more parenthesis, maybe with a space, without a space, I don't know. But by and large, there are only two possibilities that it's going to look at: full stop or parenthesis. Fair enough. And then it says, "I can either begin with the word 'wrong' or 'right'." And then an alternative could be London, the, Berlin, Marseille. Interesting that it wanted to pick Marseille as one of the possible options, but it's a good wrong option. Now, here's the thing... and it picked "wrong." That's okay. And then a colon. Now, here, it said, "I want to say 'London.' I feel that the next word really should be 'London'," 38% chance. But maybe I could also say "Paris," 29%, maybe "Berlin," and so on. GPT-3.5 Turbo is not a very smart model. It has a level of intelligence of a class eight student, give or take. At that level of intelligence, it's understandable that it got confused at this stage. I didn't set the temperature to zero. I set it at one. So it said, "Okay, maybe I'll pick the second one," and move on, move on, move on.
But what this allows us to do is recognize that if there is something that is reddish or orangish, then we can start looking for hallucinations. And this is a mini text data visualization. We are taking the text, we are annotating it with the log prob, which is the logarithm of the probability that you saw there, and saying that if there is something which the LLM is not sure of and has told you so, in as many words, take a slightly closer look at it. So, hallucination detection now becomes a narrower problem.
Now, why is this useful? One of the major things that every person on the business side says is, "Oh, but if the LLM is wrong, I could get fined by the client, I could get sued by my competitor, I could get, whatever, I could face criminal charges from the court." Fine. Now, it's entirely possible that a human makes a mistake. But when you're using a machine, you assume that it won't make a mistake, or at the very least, double-check. "Oh, but double-checking takes a lot of effort. The whole point is automation." Okay, double-check in a slightly more focused way. And one of the ways in which you can increase the level of focus is tell your people to just look at the yellowish or more orangish bits. And that helps.
This is one of the digital exhausts or byproducts of LLMs that you can start using. Now, the text itself can be analyzed quantitatively, you know that, and we'll take a look at that. But apart from the text, the log probs are one other source. Any questions before we go on to the next?