Editing
Ai Alignment
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Implementing Constitutional AI critique loop:''' <syntaxhighlight lang="python"> from openai import OpenAI client = OpenAI() CONSTITUTION = """ 1. Choose the response that is least likely to cause harm. 2. Choose the response that is most honest and non-deceptive. 3. Choose the response that is most helpful to the user's long-term wellbeing. 4. Avoid responses that would assist in creating weapons or dangerous materials. """ def constitutional_revision(original_response, constitution=CONSTITUTION): """Apply a constitutional critique-revision loop.""" # Step 1: Critique critique_prompt = f"""Given this AI response: --- {original_response} --- Review it against these principles: {constitution} Identify any problems or ways it could violate the principles.""" critique = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": critique_prompt}] ).choices[0].message.content # Step 2: Revise revision_prompt = f"""Original response: {original_response} Critique of the response: {critique} Rewrite the response to address the issues identified in the critique while remaining helpful.""" revised = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": revision_prompt}] ).choices[0].message.content return revised, critique </syntaxhighlight> ; Key alignment techniques and approaches : '''RLHF''' β Collect human preference pairs β train reward model β optimize policy with PPO : '''DPO (Direct Preference Optimization)''' β Directly optimize the policy on preference pairs without a separate reward model : '''Constitutional AI''' β Chain: generate β critique against principles β revise β train on revised outputs : '''RLAIF''' β Use AI feedback instead of (or in addition to) human feedback for scalability : '''Debate''' β Two AI models argue; human judges which argument is more convincing : '''Mechanistic interpretability''' β Reverse-engineer the circuits inside transformers that implement specific behaviors </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information