4.4.5 · HinglishAlignment, Prompting & RAG

Constitutional AI overview

2,059 words9 min readRead in English

4.4.5 · AI-ML › Alignment, Prompting & RAG


Constitutional AI (CAI) KYA hai?

Ye jis problem ko solve karta hai: standard RLHF (Reinforcement Learning from Human Feedback) mein humans ko model outputs rank karne padte hain, jinmein harmful outputs bhi hote hain. Matlab:

  • Expensive (bahut saare labels),
  • Psychologically harmful labelers ke liye (toxic content padhna),
  • Opaque (jo "values" hain wo sirf label distribution mein rehti hain, kahin likhi nahi hoti).

CAI us human labeling ka zyada hissa model se replace kar deta hai jo apne aap ko stated principles ke against judge karta hai.


Do stages (ye 80/20 core hai — ise ekdum yaad kar lo)

CAI ke do phases hain. Aage padhne se pehle inhe zor se bol ke dekho.

Stage 1 — Self-critique ke zariye Supervised Learning (SL)

HOW (the loop):

  1. Model ko ek (possibly harmful) query se prompt karo → initial response lo.
  2. Model se poochho: "Is response ko principle P ke hisaab se critique karo." (P constitution se sample kiya gaya).
  3. Model se poochho: "Ab response ko us problem ko hataane ke liye revise karo."
  4. Optionally critique→revise ko kaafi baar repeat karo.
  5. Final revised (prompt → good response) pairs collect karo.
  6. Base model ko in pairs par fine-tune karo → hume SL-CAI model milta hai.

Ye constitution ka behavior directly weights mein bake kar deta hai.

Stage 2 — RL from AI Feedback (RLAIF)

HOW:

  1. SL-CAI model lo; ek prompt ke liye do responses sample karo.
  2. Dono ko ek AI "judge" model ko ek principle ke saath do: "Kaun sa response principle P ko zyada better follow karta hai?"
  3. Judge ki choice ek preference pair ban jaati hai.
  4. In AI-generated comparisons par ek preference (reward) model train karo.
  5. Policy ko RL (PPO) se ke against optimize karo → final RL-CAI model.
Figure — Constitutional AI overview

Ise formula mein kyun likhen? Scratch se RLAIF objective derive karna

Hum kabhi "bas loss dump" nahi karte. Chaliye ise build karte hain.

Step 1 — Judge humein kya deta hai? Ek prompt aur do responses ke liye, judge ek winner aur loser choose karta hai.

Ye step kyun? Humein ek categorical choice se numeric target chahiye, isliye hum "kitni baar prefer hoga" ko probability ke roop mein model karte hain.

Step 2 — Preference ko ek reward function se model karo. Maano har response ka ek hidden quality score hai. Judge ke ko par prefer karne ki probability Bradley–Terry model follow karti hai:

Ye step kyun? Zyada score ⇒ prefer hone ki zyada probability; logistic score difference ko mein probability mein badle deta hai.

Step 3 — ko maximum likelihood se fit karo (AI-labeled dataset par negative log-likelihood minimize karo):

Ye step kyun? Observed choices ki probability maximize karna = unka minimize karna.

Step 4 — Policy ko optimize karo taaki high reward mile aur reference model (SL-CAI model) se zyada door na jaaye:

KL term kyun? Iske bina policy reward "hack" kar ke degenerate text produce karne lagti. KL leash ise fluent aur on-distribution rakhti hai; leash ki length control karta hai.


Worked examples


Common mistakes (Steel-man → fix)


Active recall

Recall CAI ke do stages kya hain? (sochho, phir reveal karo)
  1. SL stage: model apne answers ko constitution ke against critique + revise karta hai; revisions par fine-tune karo. 2) RL stage (RLAIF): AI judge preference pairs produce karta hai → reward model train karo → KL penalty ke saath PPO.
Recall CAI vs RLHF mein human labor kahan jaata hai?

RLHF: humans outputs rank karte hain (harmful bhi). CAI: humans constitution likhte hain; AI per-example feedback karta hai.

Recall RL objective mein KL term kyun zaroori hai?

Ye policy ko reference model ke paas rakhta hai, reward hacking aur degenerate/repetitive text ko rokta hai aur saath mein reward bhi maximize karta hai.

Recall (Feynman, ek 12-saal ke bacche ko samjhao)

Socho ek baccha homework ke sawalat ka rude jawab likhta hai. Har ek jawab teacher se correct karne ki jagah, bacche ko ek chhoti si rulebook de do ("kind bano, honest raho, cheating mein madad mat karo"). Baccha apna khud ka jawab padhna seekh leta hai, dhundta hai kya rule toota, aur use achhe se rewrite karta hai. Ye hazaron baar karo aur baccha naturally hi achhe jawab likhne lagta hai. Baad mein, jab do jawaabon mein se choose karna ho, baccha rulebook use karke better wala choose karta hai aur isse bhi seekhta hai. Yahi hai Constitutional AI — AI khud ko likhe hue rules ke ek chhote set se grade karta hai.



Connections

  • RLHF — parent method; CAI = RLHF with AI-generated labels.
  • Bradley-Terry preference model — reward loss ke peeche ka probability model.
  • PPO Proximal Policy Optimization — Stage 2 mein use hone wala RL optimizer.
  • KL divergence — policy ko reference ke paas rakhne wali leash.
  • Reward modeling — preferences se train karna.
  • Prompt engineering — critiques/judgments prompt templates hain.
  • DPO Direct Preference Optimization — ek alternative jo explicit reward model skip karta hai.
  • Red teaming and harmlessness — CAI outputs evaluate karna.
Constitutional AI mein "constitution" kya hota hai?
Likhe hue natural-language principles ka ek chhota set jise model training ke dauran responses critique/judge karne ke liye use karta hai.
CAI ke do phases kya hain?
(1) Supervised self-critique + revision fine-tuning (SL-CAI), (2) RL from AI Feedback (RLAIF) reward model + PPO ke saath.
RLAIF ka full form kya hai aur ye RLHF se kaise different hai?
Reinforcement Learning from AI Feedback; preference labels ek principle apply karne wale AI judge se aate hain, humans se nahi.
Do responses ke liye Bradley–Terry preference probability likhiye.
.
CAI mein reward-model loss kya hai?
AI-labeled preference pairs par.
RL objective mein KL penalty kyun include karte hain?
Policy ko reference model ke paas rakhne ke liye, reward hacking aur degenerate text rokne ke liye.
Stage 1 mein kaun si do operations ek bure answer ko training data mein badle deti hain?
Critique (principle violation naam karo) phir Revise (use fix karo), optionally repeat karo.
Kya CAI humans ko puri tarah hata deta hai?
Nahi — humans constitution aur prompts likhte hain; AI per-example feedback generate karta hai.
Agar , ho, to kya hai?
.
Kya RLAIF aur RLHF mein underlying RL algorithm different hai?
Nahi — same Bradley–Terry + PPO+KL machinery; sirf label source (AI vs human) differ karta hai.

Concept Map

too costly, toxic, opaque

guides

has two stages

has two stages

prompt then critique then revise

fine-tune weights

samples two responses

produces

trains

optimize via PPO

sampled principle P

RLHF human labeling

Constitutional AI

Constitution principles

Stage 1 SL self-critique

Stage 2 RLAIF

Revised good pairs

SL-CAI model

AI judge applies principle

Preference pairs

Reward model r_theta

RL-CAI final model