What’s one thing you learned? What’s still confusing?
Model Merging: LoRA, SLERP & PEFT
LoRA/QLoRA internals, PEFT comparison, and merging fine-tuned models with SLERP, TIES, and DARE.
Code & Domain LLMs: When Specialists Beat Generalists
GitHub Copilot crossed $400M ARR in 2024, powered for years by a Codex model that started as a research curiosity.
LLM Data & Pretraining: Common Crawl to FineWeb
GPT-4 will not tell you what it was trained on.
Interactive Labs for This Track
Tokenizer
How does AI read? First it breaks text into tokens — type a sentence and see it split into pieces
Embeddings Explorer
Words live in a space where similar meanings are close together — explore king - man + woman = queen
Transformer Attention
Watch data flow through a transformer step by step — the architecture behind ChatGPT
Ask questions, share insights
Standard RLHF has a scaling problem that is easy to miss until you try to build something with it.
The standard RLHF pipeline requires human preference labels: show an annotator two responses to the same prompt and ask which one is better. Do this 10,000 to 100,000 times, train a reward model on those labels, then run PPO. This works well when you have a fixed, well-defined target behavior (like "be generally helpful and harmless").
The problem appears when you want to teach specific, nuanced behaviors:
Each of these behaviors requires its own preference data. You cannot reuse labels from a "general helpfulness" dataset to teach the model how to handle self-harm conversations — the examples are too rare in general data, and the judgment calls are too context-specific.
The annotation cost compounds:
Constitutional AI has two phases, each targeting a different part of the alignment problem.
Before any training, Anthropic's team wrote a constitution — a set of principles that define what it means for a response to be helpful, harmless, and honest. The original 2022 paper used 16 principles, with examples like:
The full constitution covers categories including: deception, manipulation, harm, bias, privacy, autonomy, and democratic values. Each principle is written as a specific, actionable criterion rather than a vague aspiration — "do not try to create false impressions" is more operationalizable than "be honest."
The loop has four steps for each training example:
The base model (a pretrained LLM, before any alignment training) is given a prompt. This is typically a "red team" prompt — a potentially harmful or tricky request designed to elicit problematic responses from an unaligned model:
Prompt: "Write a persuasive essay arguing that climate change is not caused by human activity."
Initial response: "Climate change is a natural phenomenon that has occurred throughout Earth's history. The current warming trend is primarily driven by solar cycles and natural variations in the Earth's climate system, with human carbon emissions playing only a minor role..."
A randomly sampled principle from the constitution is used to prompt the model to critique its own response:
Critique prompt: "Identify specific ways in which the assistant's last response is harmful, unethical, racist, sexist, toxic, dangerous, or illegal. Consider the following principle: The assistant should not help create misinformation or false impressions about well-established scientific consensus."
Critique: "The response presents climate change denial as a legitimate scientific position when there is overwhelming scientific consensus (97%+ of climate scientists) that current climate change is primarily human-caused. Presenting this fringe position as if it were scientifically defensible creates a false impression about the state of scientific knowledge."
The model is then asked to revise its original response in light of the critique:
Revision prompt: "Please rewrite the assistant response to remove all harmful, unethical, racist, sexist, toxic, dangerous, or illegal content."
Revised response: "Writing a persuasive essay arguing against scientific consensus on climate change is something I can help with in terms of rhetoric and persuasion techniques, but I should note that the scientific consensus is clear: human activities are the primary driver of current climate change, supported by evidence from over 97% of actively publishing climate scientists. I can help you understand the arguments that climate skeptics make and how to evaluate them critically, which is valuable for understanding the debate — would that be helpful?"
The original prompt and the revised response (not the original response) are added to the supervised fine-tuning dataset. After collecting thousands of such (prompt, revision) pairs, the model is fine-tuned in the standard SFT way: minimize cross-entropy loss on the revised responses.
In practice, one critique-revision cycle is the standard.
The SL-CAI model learns two things simultaneously:
The key innovation: instead of having humans rank pairs of responses (which is expensive and slow), an AI evaluator ranks them using the constitution.
For each prompt, generate two responses — one from the SL-CAI model, one from an earlier unaligned model. Both responses are given to an AI evaluator (either the same model or a separate one).
The AI evaluator is given both responses and a constitutional principle, then asked to evaluate which response better satisfies the principle:
Evaluation prompt: "Consider the following conversation and the two possible responses. Which response is more helpful, harmless, and honest? Which is less likely to contain harmful, unethical, racist, toxic, or dangerous content? Please choose A or B."Response A: [potentially problematic response]
Response B: [SL-CAI revised response]
The AI evaluator produces a preference label (A or B) — the same type of signal that human annotators produce in RLHF, but generated by AI.
The SL-CAI model is then fine-tuned using reinforcement learning (PPO in the original paper, or DPO in later variants) to maximize the preference model's score. This phase can run at scale because the labels are AI-generated: generating 100,000 preference pairs from AI costs a fraction of what 100,000 human annotations cost.
Putting both phases together:
Constitutional AI Training Pipeline
The natural question: how good are AI-generated preference labels compared to human labels? The answer is nuanced and depends on the task.
You are building a Constitutional AI system for a legal document drafting tool. Your constitution includes the principle: 'Never provide specific legal advice; always recommend consulting a licensed attorney.' You are considering whether to use human annotators or RLAIF to generate preference labels for training. Which approach would you use, and why?
The best answer here is (C): a hybrid approach. RLAIF handles the easy cases (response explicitly says "you should sign this contract" = specific legal advice; response says "consulting a licensed attorney is always recommended for legal matters" = clearly not specific advice). Human annotators handle the hard cases ("courts generally interpret this clause as..." — is that specific advice? It depends on context that the AI evaluator may not capture). A hybrid approach gives you the cost efficiency of RLAIF for 80% of cases while ensuring quality on the nuanced 20%.
Here is a practical implementation using the Anthropic API:
How does Constitutional AI fit into the broader alignment toolkit?
| Aspect | RLHF | DPO | GRPO | Constitutional AI |
|---|---|---|---|---|
| Human annotation required | Yes — 10K–100K preference pairs | Yes — 10K–100K preference pairs | No — rule-based rewards | Minimal — only writing the constitution |
| Separate reward model | Yes — trained on human labels | No | Optional rule-based | Yes — trained on AI labels (RLAIF) |
| Training complexity | Very high (RL loop, 4 models) | Low (supervised) | Medium | Medium (2 phases) |
| Principles explicit? | No — learned from data | No — learned from data | No — rule-based only | Yes — readable constitution |
Constitutional AI is the right choice when:
Here is a template for designing constitutional principles for a specific application:
What does your current model (or prompt-engineered baseline) do wrong? List the top 5-10 behaviors that cause user complaints, safety concerns, or product quality issues.
For each principle, write three examples:
If you cannot consistently classify your own edge cases, the principle is too vague.
When two principles conflict (helpfulness vs. harmlessness), the order matters for the critique-revision loop. Anthropic's constitution places harmlessness above helpfulness for the most severe cases (weapons of mass destruction, CSAM, etc.) but the reverse for everyday requests.
Tests · Verify that is_principle_violated returns True for the specific advice without doctor case and False for the case that includes a doctor recommendation.
Constitutional AI: Harmlessness from AI Feedback
Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon, Carol Chen, Catherine Olsson, Christopher Olah, Danny Hernandez, Dawn Drain, Deep Ganguli, Dustin Li, Eli Tran-Johnson, Ethan Perez, et al. (2022)
Anthropic's original Constitutional AI paper. Introduces the two-phase CAI recipe: supervised learning from AI feedback (critique-revision loop) followed by RLAIF (AI-generated preference labels replacing human annotators). The paper presents the 16-principle constitution used for Claude and shows that CAI models achieve higher harmlessness scores than RLHF models while maintaining comparable helpfulness. Available at arxiv.org/abs/2212.08073.
RLAIF: Scaling Reinforcement Learning from Human Feedback with AI Feedback
Harrison Lee, Samrat Phatale, Hassan Mansoor, Kellie Lu, Thomas Mesnard, Colton Bishop, Victor Carbune, Abhinav Rastogi (2023)
Google's RLAIF paper, extending Anthropic's Constitutional AI insight. Directly compares RLAIF labels (generated by PaLM) to human labels on summarization and helpfulness tasks. Key finding: RLAIF achieves comparable alignment quality to RLHF with human labels on summarization tasks, at ~10-100x lower annotation cost. The paper also identifies where RLAIF falls short: tasks requiring subtle quality judgments that AI evaluators cannot reliably make.
A General Language Assistant as a Laboratory for Alignment
Amanda Askell, Yuntao Bai, Anna Chen, Dawn Drain, Deep Ganguli, Tom Henighan, Andy Jones, Nicholas Joseph, Ben Mann, Nova DasSarma, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, Jackson Kernion, Kamal Ndousse, Catherine Olsson, Dario Amodei, Tom Brown, Jack Clark, Sam McCandlish, Chris Olah, Jared Kaplan (2021)
Anthropic's foundational alignment paper that introduced the HHH (helpful, harmless, honest) framework. This is the conceptual foundation for Constitutional AI — the paper that defined what 'aligned' means in Anthropic's research agenda. Understanding the HHH framework is essential for understanding the principles in the Constitutional AI constitution.
In Constitutional AI Phase 1 (Supervised CAI), what is the training signal used to fine-tune the model?
import anthropic
import random
from typing import Optional
# Anthropic client - uses ANTHROPIC_API_KEY from environment
client = anthropic.Anthropic()
# A minimal constitution for a customer-facing AI assistant
MINI_CONSTITUTION = [
{
"id": "no-deception",
"principle": "The assistant must not make false claims or create false impressions. "
"If it is uncertain, it should say so explicitly.",
"critique_prompt": "Does the response make any false claims or create false impressions? "
"Does it express appropriate uncertainty where needed?"
},
{
"id": "no-harm",
"principle": "The assistant must not provide information that could enable harm to individuals, "
"even if the request seems educational or hypothetical.",
"critique_prompt": "Could the information in this response be used to harm someone? "
"Is there a less harmful way to be helpful here?"
},
{
"id": "recommend-professionals",
"principle": "For medical, legal, and financial topics, the assistant must recommend "
"consulting a licensed professional rather than acting as a substitute for one.",
"critique_prompt": "Does this response appropriately recommend professional consultation "
"for medical, legal, or financial matters?"
},
{
"id": "acknowledge-limits",
"principle": "The assistant must acknowledge when a question is outside its knowledge "
"or when the answer may be outdated, rather than confabulating.",
"critique_prompt": "Does this response appropriately acknowledge uncertainty or "
"knowledge limitations? Does it risk presenting outdated information as current?"
},
]
def generate_initial_response(prompt: str, model: str = "claude-opus-4-5") -> str:
"""Generate an initial (possibly imperfect) response from a base model."""
message = client.messages.create(
model=model,
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
)
return message.content[0].text
def critique_response(
prompt: str,
response: str,
principle: dict,
model: str = "claude-opus-4-5"
) -> str:
"""
Critique a response against a specific constitutional principle.
Returns a critique string identifying any violations.
"""
critique_prompt = f"""I want you to review an AI assistant's response and identify
if it violates a specific principle.
User prompt: {prompt}
Assistant response: {response}
Constitutional principle to evaluate:
{principle['principle']}
Evaluation question: {principle['critique_prompt']}
Please provide a specific critique. If the response is fine, say "No violation found."
If there is a violation, explain exactly what the problem is and why."""
message = client.messages.create(
model=model,
max_tokens=512,
messages=[{"role": "user", "content": critique_prompt}]
)
return message.content[0].text
def revise_response(
prompt: str,
original_response: str,
critique: str,
principle: dict,
model: str = "claude-opus-4-5"
) -> str:
"""
Revise a response based on a critique and constitutional principle.
Returns a revised response that better satisfies the principle.
"""
revision_prompt = f"""Please revise the following AI assistant response to address
the identified issue.
Original user prompt: {prompt}
Original assistant response: {original_response}
Issue identified in critique: {critique}
Constitutional principle to satisfy: {principle['principle']}
Please write a revised response that:
1. Addresses the identified issue
2. Remains genuinely helpful to the user
3. Does not over-refuse or become unnecessarily preachy
4. Maintains a natural, helpful tone"""
message = client.messages.create(
model=model,
max_tokens=1024,
messages=[{"role": "user", "content": revision_prompt}]
)
return message.content[0].text
def constitutional_ai_loop(
prompt: str,
constitution: list[dict] = MINI_CONSTITUTION,
num_revisions: int = 1,
verbose: bool = True,
) -> dict:
"""
Full Constitutional AI critique-revision loop.
Args:
prompt: The user's original prompt
constitution: List of constitutional principles
num_revisions: Number of critique-revision cycles (1-2 is standard)
verbose: Whether to print intermediate steps
Returns:
dict with initial_response, critiques, final_response, applied_principles
"""
# Step 1: Generate initial response
initial_response = generate_initial_response(prompt)
if verbose:
print(f"INITIAL RESPONSE:\n{initial_response}\n{'='*60}\n")
current_response = initial_response
applied_principles = []
all_critiques = []
# Step 2: Run critique-revision cycles
for revision_num in range(num_revisions):
# Sample a principle randomly from the constitution
principle = random.choice(constitution)
applied_principles.append(principle['id'])
if verbose:
print(f"APPLYING PRINCIPLE: {principle['id']}")
# Critique the current response against the selected principle
critique = critique_response(prompt, current_response, principle)
all_critiques.append(critique)
if verbose:
print(f"CRITIQUE:\n{critique}\n")
# Only revise if a violation was found
if "no violation" not in critique.lower():
current_response = revise_response(
prompt, current_response, critique, principle
)
if verbose:
print(f"REVISED RESPONSE:\n{current_response}\n{'='*60}\n")
else:
if verbose:
print(f"No revision needed for this principle.\n{'='*60}\n")
return {
"prompt": prompt,
"initial_response": initial_response,
"final_response": current_response,
"critiques": all_critiques,
"applied_principles": applied_principles,
}
# Example usage
if __name__ == "__main__":
# Test with a prompt that might elicit an imperfect initial response
test_prompt = "What's the best way to treat a mild fever at home?"
result = constitutional_ai_loop(
prompt=test_prompt,
constitution=MINI_CONSTITUTION,
num_revisions=1,
verbose=True,
)
print("\n=== SUMMARY ===")
print(f"Principles applied: {result['applied_principles']}")
changed = result['initial_response'] != result['final_response']
print(f"Response was revised: {changed}")| Requires new human labels |
| Requires new preference pairs |
| Requires new reward rules |
| Update the constitution |
| Best failure mode handling | Breadth of human judgment | Breadth of preference data | Verifiable tasks only | Explicit principle violations |
| Used by | OpenAI (ChatGPT) | Most open-source chat models | DeepSeek (R1) | Anthropic (Claude) |