SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2212.08073 · 2022

Constitutional AI: Harmlessness from AI Feedback

Stanislav Fort, Ethan Perez, Dario Amodei, Kamal Ndousse, Saurav Kadavath, Azalia Mirhoseini, Nicholas Schiefer, Nicholas Joseph, Sam Mccandlish, Samuel Bowman, Yuntao Bai, Andy Jones, and 39 more

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2212.08073.json · badge: /api/ran/2212.08073.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
uptrain-ai/uptrain community (classifier label)
classifier basis not recorded on the link
4 ran · 0 no recorded run
FunctionStatusWhere it lives
format_uptrain_template Ran
ran on a synthesized input
uptrain-ai/uptrain/uptrain/integrations/promptfoo_utils.py
code served (permissive licence) · get_code("e8d89d69f3408074")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os

# Set up environment variable for OpenAI API key (mock value)
os.environ['OPENAI_API_KEY'] = 'sk-mock-key-for-testing'

# Define the arguments for format_uptrain_template
ARGS = {
    'data': {
        'question': 'What is machine learning?',
        'context': 'Machine learning is a subset of artificial intelligence.',
        'response': 'Machine learning is a field of study that gives computers the ability to learn without being explicitly programmed.'
    },
    'evals_compiled': {
        'eval_type': 'Relevance',
        'score_type': 'score',
        'explanation_type': 'explanation'
    },
    'threshold': 0.7,
    'eval_model': 'gpt-3.5-turbo',
    'project_name': 'test_project'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
uptrain — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
raise_or_return Ran
ran on a synthesized input
uptrain-ai/uptrain/uptrain/framework/remote.py
code served (permissive licence) · get_code("9e1d39d2fcccc91f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from unittest.mock import Mock
import httpx

# Create a mock Response object that behaves like httpx.Response
mock_response = Mock(spec=httpx.Response)
mock_response.is_success = True
mock_response.json.return_value = {"status": "ok", "data": [1, 2, 3]}

ARGS = {
    "response": mock_response
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
httpx, loguru — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
register_custom_op Ran
ran on a synthesized input
uptrain-ai/uptrain/uptrain/operators/base.py
code served (permissive licence) · get_code("be851771a55d2bde")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned type. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import typing as t

T = t.TypeVar('T')

def register_op(cls: T) -> T:
    """Decorator that marks the class as an Uptrain operator. Useful for (de)serialization."""
    assert isinstance(cls, type), 'Only classes can be registered as Uptrain operators'
    assert hasattr(cls, 'setup') and hasattr(cls, 'run'), 'All Uptrain operators must define a `setup` and a `run` method.'
    op_name = f'{cls.__module__}:{cls.__name__}'
    cls._uptrain_op_name = op_name
    return cls

def register_custom_op(cls: T) -> T:
    """Decorator that marks the class as a custom Uptrain operator, that is not
    part of the core uptrain package. These are serialized by storing the entire
    source code of the class, and deserialized by exec-ing the source code.

    NOTE: This introduces some restrictions on the operator.
    - This operator is dserialised in an empty namespace, so all imports must
    be done inside the class definition.
    - For typing, use string annotations.
    - Custom operators must be defined in a separate .py file and not in the
    interpreter (like a jupyter notebook).
    """
    cls._uptrain_op_custom = True
    return register_op(cls)


class CustomOperatorExample:
    """A minimal custom operator class that satisfies the requirements."""
    
    def setup(self):
        """Required setup method."""
        pass
    
    def run(self):
        """Required run method."""
        pass


ARGS = {
    'cls': CustomOperatorExample
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
register_op Ran
ran on a synthesized input
uptrain-ai/uptrain/uptrain/operators/base.py
code served (permissive licence) · get_code("6f21bbd12e4d0294")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned type. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import typing as t

# Define a minimal operator class that satisfies the requirements
class MinimalOperator:
    """A minimal class with setup and run methods to be decorated."""
    
    def setup(self):
        """Setup method required by register_op."""
        pass
    
    def run(self):
        """Run method required by register_op."""
        pass

# Construct the arguments
ARGS = {
    'cls': MinimalOperator
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

As AI systems become more capable, we would like to enlist their help to supervise other AIs. We experiment with methods for training a harmless AI assistant through selfimprovement, without any human labels identifying harmful outputs. The only human oversight is provided through a list of rules or principles, and so we refer to the method as 'Constitutional AI'. The process involves both a supervised learning and a reinforcement learning phase. In the supervised phase we sample from an initial model, then generate self-critiques and revisions, and then finetune the original model on revised responses. In the RL phase, we sample from the finetuned model, use a model to evaluate which of the two samples is better, and then train a preference model from this dataset of AI preferences. We then train with RL using the preference model as the reward signal, i.e. we use 'RL from AI Feedback' (RLAIF). As a result we are able to train a harmless but nonevasive AI assistant that engages with harmful queries by explaining its objections to them. Both the SL and RL methods can leverage chain-of-thought style reasoning to improve the human-judged performance and transparency of AI decision making. These methods make it possible to control AI behavior more precisely and with far fewer human labels.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2212.08073")
get_code_for_paper("2212.08073")
have("2212.08073")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2212.08073.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2212.08073.svg)](https://syntology.ai/paper/2212.08073)

Connect an agent — have() is free.