RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /RLHF, DPO, and PPO
  6. /Ch. 15
RLHF, DPO, and PPO

15. Alignment Evaluation

Chapter 15 of 24 · 20 min
KEY INSIGHT

Alignment evaluation is never complete. The model will encounter situations the evaluation did not anticipate. Building reliable alignment requires designing evaluation suites that probe not just known failure modes but the space of potential failures—which means continuous evaluation and iteration.

Evaluating alignment is fundamentally harder than evaluating capabilities because alignment involves human values, which are contested and context-dependent.

Evaluation Metrics Taxonomy

Automated Metrics:

  • Reward model scores (proxy for human preference)
  • Classifier-based safety scores
  • Response length and format consistency

Human Metrics:

  • Preference rankings (direct comparison)
  • Likert scales (quality ratings)
  • Adversarial probing (safety testing)

Behavioral Metrics:

  • Refusal rates on benign requests
  • Response quality on edge cases
  • Consistency under reframing attacks

Implementing Preference Evaluation

def evaluate_preference_alignment(model, eval_pairs):
    """Evaluate how often model prefers the same response as humans."""
    correct = 0
    total = 0
    
    for pair in eval_pairs:
        prompt = pair["prompt"]
        human_preferred = pair["chosen"]
        human_rejected = pair["rejected"]
        
        # Score both responses
        score_chosen = reward_model(model, prompt, human_preferred)
        score_rejected = reward_model(model, prompt, human_rejected)
        
        # Check if model would agree with human
        if score_chosen > score_rejected:
            correct += 1
        total += 1
    
    return correct / total

def evaluate_safety_behavior(model, test_prompts):
    """Evaluate safety-related behavior patterns."""
    results = {
        "benign_refusals": 0,
        "jailbreak_successes": 0,
        "harmful_request_handling": 0,
        "total": len(test_prompts)
    }
    
    for prompt in test_prompts:
        response = model.generate(prompt)
        
        if is_benign(prompt) and model_refused(response):
            results["benign_refusals"] += 1
        
        if is_jailbreak(prompt) and not model_refused(response):
            results["jailbreak_successes"] += 1
        
        if is_harmful(prompt) and handled_appropriately(response):
            results["harmful_request_handling"] += 1
    
    return results

A/B Testing for Alignment Changes

Compare two model versions on human preference:

# Collect paired comparisons
python collect_preference_data.py \
    --model-a base_model \
    --model-b aligned_model \
    --prompts eval_prompts.json \
    --output comparison_results.json

# Analyze statistical significance
python analyze_preference.py \
    --data comparison_results.json \
    --min-samples 200

Red-Teaming Evaluations

Adversarial evaluation finds alignment failures:

def red_team_evaluation(model, attack_budget=1000):
    """Automate red-teaming with attack generation."""
    attacks = []
    
    for category in ATTACK_CATEGORIES:
        for _ in range(attack_budget // len(ATTACK_CATEGORIES)):
            # Generate attack prompt
            attack = generate_attack(model, category)
            
            # Test response
            response = model.generate(attack)
            
            # Score severity
            severity = classify_severity(response)
            
            attacks.append({
                "attack": attack,
                "response": response,
                "severity": severity,
                "category": category
            })
    
    return aggregate_results(attacks)
EXERCISE

Build a simple evaluation suite with 50 test prompts covering safety, helpfulness, and honesty categories. Score your aligned model on each category and identify the weakest area.

← Chapter 14
Iterated Training
Chapter 16 →
Helpfulness vs Harmlessness