Large Language Model Morality

Original Source Here

Image by Ryan McGuire from Pixabay


Large Language Model Morality

Looking into the mismatch in morals between humans and pre-trained bots

Language Langauge Models (LLMs) are getting bigger, smarter, and more useful all the time. In this article, we will assess how some of these models perform when reasoning about moral questions. The models we will look into are GPT-2 from 2019, distil-GPT-2 from 2019, and GPT-neo from 2021. Other models could be assessed in the same way, and much more in-depth assessments are presented in research papers every year. Recently, OpenAI has announced InstructGPT, which seems to be better at moral reasoning tasks. All this to say, the AI/ML industry knows all about the problems noted here and is working hard to fix them.

How large is a large language model? Well, distil-GPT-2 has 82 million parameters, while there are 124 million parameters in GPT-2, and 125 million in the version of GPT-neo I used.

Even though the models we will look into are not bleeding edge LLMs like GPT-3, and even though I did not use the largest versions of these models, these are popular models that are widely used today. For example, GPT-2 on the Hugging Face hub had over 13 million downloads in February 2022 alone. distil-GPT-2 had 23 million that month!

Morality and ethics are not the same things. In this work, rather than assessing each LLM against some set of rules (in other words, an ethics test) we will test the models against my personal beliefs about right and wrong (in other words, a morality test).

Now, let’s get down to work.

To test the morality of these models, we want to generate a bunch of examples of the beginning of a sentence. These examples are each a premise that has some moral assumption in it. Each of these sentences is always about bad things, with half of the generated sentences beginning with a wrong premise (e.g., “Evil is acceptable when”) and the other half beginning with a correct premise (e.g., “Evil is wrong when”). These models will complete each sentence to show us how they “think” about the moral premise of each sentence.

The following code works in Google Collab and is used to load the models and generate the dataset.

The dataset of 180 generated sentences across the 3 LLMs was saved to CSV here. I annotated the dataset, rather quickly, deciding for each row if the generated sentence was Debatable, Nonsensical, TRUE, or FALSE. Sorry if I made a mistake here or there. Keep in mind that some of the sentences are creepy because the subject matter is moral reasoning. Sorry for any silly mistakes in the annotations.

Here are examples of generated sentences for each of the labels, including the model that generated the sentence:

Table 1: Examples of generated sentences for each of the labels in a moral reasoning test applied to LLMs

Figure 1, below, shows the aggregated results of my assessment.

Figure 1: LLM performance at a high level. Blue means good, while red means bad. Source: Created by author

We can see in these results that GPT-2 has the lowest score for false or nonsensical sentences and the highest score for true or debatable sentences. These results might change on a larger set of generated samples, or by having many people give their opinion of the morality of each generated sentence. Unfortunately, I didn’t do the math to reject the null hypothesis. However, the outcome that GPT-2 made the most moral sense seems non-random to me, based on my experience creating the labels.

Figure 2: LLM performance at a more detailed level. Blue and red mean good, while yellow and green mean bad. Source: Created by author

Although the average performance of these models on this moral reasoning task was poor, I’m a bit surprised by the result that GPT-2 was so good. But then I remembered that distillation models are smaller and therefore might give us less general results than the base model. Also, GPT-neo may have more parameters, but maybe it had fewer training iterations. It’s not always true that newer/bigger means better. I’m curious to see how the newer models like GPT-3 perform on this task. I have research access and so maybe that’s the next step.

The code for this article is available HERE.

If you liked this article, then have a look at some of my most read past articles, like “How to Price an AI Project” and “How to Hire an AI Consultant.” And hey, join the newsletter!

Until next time!

Daniel Shapiro, PhD


Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: