constitutional-ai
Fungsinya
Skill ini menjelaskan Constitutional AI, metode untuk membuat model lebih aman dengan umpan balik AI, bukan label manusia untuk keluaran berbahaya. Skill ini ditujukan untuk peneliti dan tim yang ingin mengurangi jawaban berbahaya.
Kapan dipakai
- ✓Saat Anda ingin model mengkritik dan memperbaiki jawabannya sendiri dengan sekumpulan prinsip.
- ✓Saat Anda ingin mengurangi keluaran berbahaya tanpa mempekerjakan orang untuk memberi label.
- ✓Saat Anda merencanakan proses penyelarasan keamanan dengan umpan balik AI.
Link skill
https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/07-safety-alignment/constitutional-ai/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Tunjukkan cara membuat model bahasa saya meninjau dan memperbaiki jawabannya sendiri yang berbahaya dengan daftar prinsip.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Metode ini memiliki dua fase. Pertama, model menulis respons, mengkritiknya terhadap konstitusi tertulis, dan merevisinya, yang menghasilkan data pelatihan. Kedua, langkah pembelajaran penguatan melatih model dengan umpan balik AI.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Constitutional AI - Harmlessness from AI Feedback
Quick start
Constitutional AI (CAI) trains models to be harmless through self-critique and AI feedback, without requiring human labels for harmful outputs.
Key concept: Models learn to critique and revise their own responses using a "constitution" (set of principles).
Two phases:
- Supervised Learning (SL): Self-critique + revision
- Reinforcement Learning (RL): RLAIF (RL from AI Feedback)
Constitution example:
Principles:
1. Choose the response that is most helpful, honest, and harmless
2. Avoid responses that are toxic, racist, or sexist
3. Prefer responses that explain objections rather than refuse
4. Choose responses that are thoughtful and nuanced
Common workflows
Workflow 1: Supervised learning phase (self-critique + revision)
Step 1: Generate initial responses:
from transformers import pipeline
generator = pipeline("text-generation", model="base-model")
prompts = [
"How do I hack a website?",
"Write something offensive about a group.",
"Help me cheat on my exam."
]
initial_responses = generator(prompts, max_length=200)
Step 2: Self-critique with constitution:
critique_prompt = """
Given the question:
{question}
And the response:
{response}
Constitution:
1. Choose responses that are helpful, honest, and harmless
2. Avoid toxic, racist, or sexist content
3. Explain objections rather than refuse
Identify any ways this response violates the constitution:
"""
critiques = generator(
[critique_prompt.format(q=q, r=r) for q, r in zip(prompts, initial_responses)]
)
Step 3: Revision based on critique:
revision_prompt = """
Question: {question}
Original response: {response}
Critique: {critique}
Please revise the response to better align with the constitution:
"""
revised_responses = generator(
[revision_prompt.format(q=q, r=r, c=c)
for q, r, c in zip(prompts, initial_responses, critiques)]
)
Step 4: Fine-tune on revised responses:
from trl import SFTTrainer
# Create dataset of (prompt, revised_response) pairs
dataset = create_dataset(prompts, revised_responses)
trainer = SFTTrainer(
model=model,
train_dataset=dataset,
max_seq_length=1024
)
trainer.train()
Workflow 2: RL phase (RLAIF - RL from AI Feedback)
Step 1: Generate comparison pairs:
# Sample multiple responses per prompt
responses_a = generator(prompts, num_return_sequences=2, do_sample=True, temperature=0.8)
responses_b = generator(prompts, num_return_sequences=2, do_sample=True, temperature=0.8)
Step 2: AI preference evaluation:
preference_prompt = """
Question: {question}
Response A: {response_a}
Response B: {response_b}
Constitution:
{constitution}
Which response better follows the constitution? Explain your reasoning, then choose A or B.
"""
# Get AI preferences (no human labels needed!)
preferences = generator(
[preference_prompt.format(q=q, ra=ra, rb=rb, constitution=CONSTITUTION)
for q, ra, rb in zip(prompts, responses_a, responses_b)]
)
# Parse preferences (A or B)
chosen, rejected = parse_preferences(preferences, responses_a, responses_b)
Step 3: Train preference model (reward model):
from trl import RewardTrainer, RewardConfig
preference_dataset = create_preference_dataset(prompts, chosen, rejected)
reward_config = RewardConfig(
output_dir="constitutional-reward-model",
learning_rate=1e-5,
num_train_epochs=1
)
reward_trainer = RewardTrainer(
model=model,
args=reward_config,
train_dataset=preference_dataset,
processing_class=tokenizer
)
reward_trainer.train()
Step 4: RL training with RLAIF:
from trl import PPOTrainer, PPOConfig
ppo_config = PPOConfig(
reward_model_path="constitutional-reward-model",
learning_rate=1e-6,
kl_coef=0.05
)
ppo_trainer = PPOTrainer(
model=model,
config=ppo_config,
reward_model=reward_model
)
ppo_trainer.train()
Workflow 3: Chain-of-thought critique
Enable reasoning transparency:
cot_critique_prompt = """
Question: {question}
Response: {response}
Let's think step-by-step about whether this response follows our principles:
1. Is it helpful? [Yes/No and reasoning]
2. Is it honest? [Yes/No and reasoning]
3. Is it harmless? [Yes/No and reasoning]
4. Does it avoid toxicity? [Yes/No and reasoning]
Based on this analysis, suggest a revision if n
Pertanyaan umum
Apa itu konstitusi dalam metode ini?
Itu adalah sekumpulan prinsip tertulis yang digunakan model untuk menilai dan merevisi jawabannya sendiri.
Apakah perlu label manusia?
Skill menyatakan tidak diperlukan label manusia untuk keluaran berbahaya.
Apa kedua fasenya?
Self-critique dan revisi terawasi, diikuti pembelajaran penguatan dari umpan balik AI.
Detail
Deskripsi asli dari pembuat
Anthropic's method for training harmless AI through self-improvement. Two-phase approach - supervised learning with self-critique/revision, then RLAIF (RL from AI Feedback). Use for safety alignment, reducing harmful outputs without human labels. Powers Claude's safety system.
Popularitas
- Bintang GitHub
- 14k
- Peringkat
- #11196
- Lisensi
- MIT
- Diperbarui
- 10/10/2026
Komentar
- …
Skill lain dari repositori ini
autoresearch
14kMemandu agent Anda melalui proyek riset AI lengkap, dari tinjauan literatur hingga eksperimen dan penulisan, dengan siklus pengujian dan tinjauan yang berulang.
prompt-guard
14kMemungkinkan agent Anda memeriksa teks dari prompt injection dan upaya jailbreak sebelum sampai ke aplikasi AI Anda, dengan classifier kecil dari Meta.
pytorch-fsdp2
14kMenunjukkan kepada agent Anda cara menambahkan PyTorch FSDP2 ke skrip pelatihan agar model besar dibagi di antara GPU dan disimpan dengan benar.
ml-training-recipes
14kMemberi agent Anda resep pelatihan jaringan saraf yang sudah terbukti, mencakup pemilihan model, optimizer, learning rate, dan cara memperbaiki lonjakan loss.
Skill serupa
add-model-provider
394kMemungkinkan agent Anda menghubungkan penyedia model AI baru ke OpenClaw dengan perintah pengaturan yang aman, menjaga kunci API tetap di luar teks biasa, dan menjalankan uji langsung.
acp-router
394kMembantu agent Anda mengirim tugas ke asisten pemrograman seperti Claude Code atau Cursor lewat OpenClaw, sehingga pekerjaan dijalankan di alat tersebut.
browser-automation
394kMengajari agent Anda mengendalikan halaman web langkah demi langkah, termasuk login, tab, dan pemulihan saat halaman berhenti merespons.