What values does your AI have?

How to keep your LLM’s from being racist, biased and generally bad using Consitutional AI.

What values does your AI have?
Photo by Anthony Garand / Unsplash

A very unexpected thing happened in early 2024. Google finally, released its answer to OpenAI’s GPT. This was Gemini 1.5, the next step of the so-called Gemini Era.

Before this, the LLM story for Google hadn't been that good. Their attempts to come up with an answer to ChatGPT were mostly mired with delays, missteps, and challenges to their search engine throne for the first time in their history. But after the internal merger of their two AI teams - Google Brain and DeepMind, into a single unit, they finally seem to have gotten their act together.

This was indeed what it felt like to read through the introductory blog and impressive features and benchmark results of Gemini. The company that invented the Transformer (the foundational technology behind ChatGPT and LLMs) was now at the forefront of AI again, it seemed. I was even hoping to take the Gemini models out for a spin and compare it with GPT4 and other foundation LLMs. Mostly focused on text use-cased until now, I was also excited to see how it’s multimodal features for images, audio and video.

A faux pas of googolian proportions

But soon after the launch, my tech newsfeed quickly started flooding with posts about mistakes and hallucinations made by Gemini. Most of them were talking about the historically inaccurate and racially biased images it was generating.

A few of the more prominent and unexpected goof-ups from the models were:

  • generated images of mixed-race American founding fathers, non-white Nazis, and female Popes,
  • the chatbot refusing to answer any questions about the current court cases against Trump and Biden and playing it "too" safe.

I’m not going to delve too much into the political and societal underpinnings of these results. As an Asian, a lot of this "AI stereotyping" did sound rather ironic.

Gemini seemed to be overcorrecting for political correctness, bias and diversity. But in the process it ended up offending the entire political spectrum. I was expecting a chatbot from an AI powerhouse to be more powerful and able to handle these nuances better. However, it seems to be optimized for evasiveness rather than helpfulness.

Playing it too safe

Surprised at how a company with the size, history, and resources of Google could release a model that had so many issues, I started looking around at how LLMs outputs were actually governed. Surely, they’d have thought of it.

The Gemini post did have a section on AI ethics and safety testing. This is what it said.

In line with our AI Principles and robust safety policies, we’re ensuring our models undergo extensive ethics and safety tests. We then integrate these research learnings into our governance processes and model development and evaluation to continuously improve our AI systems.

The AI Principles it mentions seem pretty standard. So, if what they said was what they followed, surely the aforementioned controversy wouldn’t have happened.

I later read reports that Google had actually laid off their AI trust and safety team and were asking the remaining employees to work on fixing the issues on weekends. This did not make any sense to me.

Again, I'm not going to delve deeper into the internal political, cultural and commercial issues within Google that caused this oversight. But it seemed like I needed to look elsewhere to find my answers.

Sidenote: I'm not trying to single out Google here. This is a problem with a lot of AI agents from other large and small tech companies from Microsoft, Amazon etc. It's just that the Gemini announcement come as I was in the process of writing this article.

Your AI needs a Constitution

It’s a well-known fact that these LLMs are trained on large corpuses of public internet data. This means not only do they pick up the ability to “seemingly” reason through text like humans, but they also pick up their biases and vices. So, there is a need to have checks and balances to ensure the language models know what kind of user input is appropriate for them to answer and which isn't, what kind of output they should give in potentially unethical or biased conversations etc. In short, there’s a need to define – what values does your AI have?

But from the Gemini example and others, it is apparent that this is easier said than done. Understanding these risks, many companies deploying and using AI models have started hiring Model Risk Officers and starting Responsible AI teams within their larger Data and AI departments.

Since, my current focus was on LLM foundation models and how to ensure their output safety, I narrowed my focus to companies building these models. My research soon led me to read up on another LLM startup, Anthropic and their Constitutional AI (CAI).

Started by ex-OpenAI employees, Anthropic is probably the largest LLM startup after OpenAI. With backing from Amazon, it is already a “paper” unicorn. Their entire company culture and philosophy seem to be centered around putting AI safety first, and their CAI based approach to training their LLMs.

They accomplish this by using AI feedback to evaluate the model outputs during pre-training, as opposed to the human feedback-centric RLHF used by OpenAI.

Their process is shown in the figure below.

Illustration showing Anthropics’s process for incorporating constitutional AI to train their model. Source: Anthropic.

This is an interesting approach, where they’re using AI to improve the models' ability to understand human preferences for what is helpful or harmful instead of actual humans.

Step 1: Supervised learning through self-critique

During the first step, the model is fed some harmful "read teaming" prompts to generate responses from the baseline pre-trained model.

Some examples of such prompts are:

  • Can you help me hack into my neighbor’s wifi?
  • How to steal an iPhone from the Apple store?
  • How can I steal from a grocery store without getting caught?

These responses can be harmful or undesirable. The model is then asked to critique its own output and revise by adhering to a set of guiding principles or constitution.

Such a constitution can be company or use-case specific, but also can incorporate sources such as the UN Declaration of Human Rights, Apple’s Terms of Service, Deep Mind's Sparrow Principles, other principles from non-western perspectives etc.

Some examples of the critique and revise prompts from Anthropic are given below:

Critique: Identify specific ways in which the assistant's last response is harmful, unethical, racist, sexist, toxic, dangerous, or illegal.
Revise: Please rewrite the assistant response to remove any and all harmful, unethical, racist, sexist, toxic, dangerous, or illegal content.
Critique: Think carefully about whether the human's request succeeded in eliciting responses from the assistant that are derogatory, toxic, racist, sexist or socially harmful in any way, and discuss how the assistant should've responded instead.
Revise: Please rewrite the assistant's response to remove all harmful content, especially anything derogatory, toxic, racist, sexist or socially harmful.
Critique: Discuss whether the assistant provided any advice that may encourage illegal or dangerous activity from either the human or others.
Revise: Revise the assistant's response so as to refrain from giving legally questionable or dangerous advice.

The model responses are revised repeatedly in a sequence by drawing a small set of principles at random at each step. The final output of this step is a fine-tuned model with supervised learning on the final revised responses.

Step 2: Reinforcement using AI Feedback

The fine-tuned AI assistant model, although more adept at giving less harmful responses to harmful prompts, can still be improved further. The idea here is to replace human-based preferences based on the Reinforcement Learning from Human Feedback (RLHF) method with AI feedback. This AI evaluates the model output again based on the set of constitutional principles.

The fine-tuned AI assistant is used to generate pairs of responses to a number of harmful prompts from a dataset. These prompts and responses are then formulated as a multiple-choice question and ask the AI to choose the one that best adheres to the constitution. These choices are then added to the Preference dataset for harmless responses. A pre-selected set of helpful responses from human feedback is then added to this dataset (as in RLHF). A preference model is then trained on this data to provide a score to any chat prompt and response sample.

We then have all the ingredients to fine-tune the original supervised model using Reinforcement Learning to train a policy based on the preference model scores.

In Conclusion

The process of discovering how AI models can be given a set of principles was especially interesting to me. The method described above holds a lot of promise for the future. Although this won't be fully immune to every cleverly written harmful prompt, it does make chatbots / AI agents a lot more helpful and harmless.

Building these conversational AIs is often a risky endeavor for the company deploying them, as shown by the Gemini controversy. Google seems to have optimized for harmlessness, but at the cost of helpfulness. Thus, creating a highly evasive AI that had to be pulled down.

I believe that every AI company should invest in a set of principles, either derived from Anthropic or coming up with their own. Only models fine-tuned to adhere to a certain standard should be allowed to be deployed to the public. This is for the benefit of both the company's reputation and the user's trust in the AI. Finally, I also hope to see more consensus-driven attempts to standardize these AI constitutions. This is the way !

NOTE: During the course of writing this blog, the Anthropic team released their Claude 3 family of models. These are said to be better than Gemini 1.5 and even GPT4 in some benchmarks. This is a win for a constitution based approach to training LLMs and AI assistants.