[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,88 +2,161 @@
|
||||
id: wiki-2026-0508-positive-reinforcement
|
||||
title: Positive Reinforcement
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [PSYCH-POS-REINF-001]
|
||||
aliases: [Operant Conditioning Reinforcement, Reward-based Learning]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 1.0
|
||||
tags: ["Psychology|[Psychology", ai, Reinforcement-Learning, positive-reinforcement, Behaviorism, reward-design]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [behaviorism, psychology, reinforcement-learning, skinner, conditioning]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-26
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: python
|
||||
framework: gymnasium, stable-baselines3
|
||||
---
|
||||
|
||||
# Positive Reinforcement (정적 강화)
|
||||
# Positive Reinforcement
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "바람직한 행동의 끝에 '달콤한 보상'을 배치하여, 에이전트가 스스로 최적의 길을 열망하게 하라" — 특정 행동 뒤에 긍정적인 자극(보상)을 제공함으로써 해당 행동이 미래에 다시 발생할 확률을 높이는 심리학적 원리이자 강화학습의 핵심 메커니즘.
|
||||
## 매 한 줄
|
||||
> **"매 행동 직후 desirable stimulus 추가 → 그 행동 빈도 증가."**. Skinner의 operant conditioning 핵심 mechanism (1938~). Modern AI에서 매 RL의 reward signal과 직접 연결되며, RLHF / Constitutional AI / DPO의 conceptual root.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **추출된 패턴:** "Target Behavior and Reward Feedback Loop" — 에이전트가 목표에 부합하는 상태에 도달하거나 액션을 수행했을 때 즉각적인 수치적 보상을 부여하고, 모델이 이 보상의 총합(Return)을 최대화하는 방향으로 자신의 정책을 스스로 수정하게 만드는 패턴.
|
||||
- **핵심 요소:**
|
||||
- **Reinforcer (강화물):** 보상 그 자체 (예: 점수, 칭찬, 토큰).
|
||||
- **Timing:** 행동 직후의 즉각적인 보상이 학습 효율을 극대화함.
|
||||
- **Reward Shaping:** 복잡한 목표를 달성하기 위해 작은 단계별 성공에도 보상을 쪼개어 배치하는 기술.
|
||||
- **의의:** AI에게 '무엇을 하지 마라'는 금지 명령보다 '이것을 하면 좋다'는 긍정적 유인을 제공할 때 훨씬 더 창의적이고 효율적인 문제 해결 전략이 창발됨.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 보상이 너무 편향되면 에이전트가 보상만 따먹고 실전 성과는 내지 않는 '보상 해킹(Reward Hacking)'에 빠질 수 있음을 인지하고, 현대 AI에서는 내적 동기(Intrinsic Motivation)나 호기심(Curiosity) 기반의 정적 강화 모델이 연구되고 있음.
|
||||
- **정책 변화:** Antigravity 프로젝트는 에이전트가 사용자에게 유용한 정보를 제공하거나 정확한 코드를 생성했을 때 긍정적인 피드백 점수를 부여하여, 에이전트의 응답 품질을 상향 평준화하는 정적 강화 루프를 운용함.
|
||||
### 매 4-사분면 (Operant Conditioning)
|
||||
| | 자극 추가 (positive) | 자극 제거 (negative) |
|
||||
|---|---|---|
|
||||
| 행동 증가 (reinforcement) | **Positive Reinforcement** (칭찬, 보상) | Negative Reinforcement (시끄러운 소리 멈춤) |
|
||||
| 행동 감소 (punishment) | Positive Punishment (혼냄) | Negative Punishment (특권 박탈) |
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Reinforcement-Learning|Reinforcement-Learning]], [[Policy-Gradient-Methods|Policy-Gradient-Methods]], Monte-Carlo-Tree-Search-MCTS, Expected-Utility-Theory
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Positive-Reinforcement.md
|
||||
매 "positive" = 추가, "negative" = 제거. 좋고 나쁨이 아님.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 schedule (강화 스케줄)
|
||||
- **Continuous (CRF)**: 매 행동마다 reward — 빠른 학습, 빠른 소거.
|
||||
- **Fixed Ratio (FR)**: 매 N회 행동 후 — piecework.
|
||||
- **Variable Ratio (VR)**: 평균 N회, 매 unpredictable — 도박, SNS 알림. 매 가장 강력하고 소거 저항.
|
||||
- **Fixed Interval (FI)**: 매 N초 후 첫 행동.
|
||||
- **Variable Interval (VI)**: 평균 N초, random — 매 steady response rate.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### 매 RL 연결
|
||||
- Reward signal r_t = positive reinforcement 의 mathematical formalization.
|
||||
- Policy gradient: 매 reward 받은 action 의 probability 증가 — 정확히 positive reinforcement.
|
||||
- RLHF: human preference → reward model → policy update — 매 large-scale positive reinforcement.
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### 매 응용
|
||||
1. Education (token economy, gamification).
|
||||
2. Animal training (clicker training).
|
||||
3. ABA therapy for autism.
|
||||
4. Workplace incentive design.
|
||||
5. App engagement (variable reward — Hooked Model).
|
||||
6. RL agent training (game, robotics, LLM).
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
## 💻 패턴
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### Policy gradient (REINFORCE) — positive reinforcement formalized
|
||||
```python
|
||||
import torch, torch.nn.functional as F
|
||||
def reinforce_step(policy, optim, states, actions, rewards, gamma=0.99):
|
||||
# discounted return
|
||||
R, returns = 0.0, []
|
||||
for r in reversed(rewards):
|
||||
R = r + gamma * R
|
||||
returns.insert(0, R)
|
||||
returns = torch.tensor(returns)
|
||||
returns = (returns - returns.mean()) / (returns.std() + 1e-8)
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
logits = policy(torch.stack(states))
|
||||
logp = F.log_softmax(logits, dim=-1)
|
||||
chosen = logp.gather(1, torch.tensor(actions).unsqueeze(1)).squeeze(1)
|
||||
loss = -(chosen * returns).mean() # 매 reward-weighted log-likelihood
|
||||
optim.zero_grad(); loss.backward(); optim.step()
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Reward shaping (sparse → dense)
|
||||
```python
|
||||
def shaped_reward(state, next_state, goal):
|
||||
progress = -abs(next_state - goal) + abs(state - goal)
|
||||
return 1.0 if next_state == goal else 0.1 * progress # 매 step마다 작은 positive
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Variable ratio schedule simulator
|
||||
```python
|
||||
import random
|
||||
class VariableRatio:
|
||||
def __init__(self, mean_n=5):
|
||||
self.mean = mean_n; self.count = 0; self.target = self._draw()
|
||||
def _draw(self):
|
||||
return max(1, int(random.expovariate(1/self.mean)))
|
||||
def step(self):
|
||||
self.count += 1
|
||||
if self.count >= self.target:
|
||||
self.count = 0; self.target = self._draw()
|
||||
return True # reward
|
||||
return False
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Token economy (educational app)
|
||||
```python
|
||||
class TokenEconomy:
|
||||
def __init__(self): self.tokens = 0
|
||||
def reinforce(self, behavior, weight=1):
|
||||
# 매 desired behavior 직후 token 추가 (positive reinforcement)
|
||||
self.tokens += weight
|
||||
def redeem(self, cost, item):
|
||||
if self.tokens >= cost:
|
||||
self.tokens -= cost; return item
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### RLHF reward model (modern LLM positive reinforcement at scale)
|
||||
```python
|
||||
# pseudocode of preference -> reward -> PPO
|
||||
def train_reward_model(prefs): # prefs: (chosen, rejected) pairs
|
||||
# log-sigmoid pairwise loss
|
||||
return ...
|
||||
def ppo_update(policy, ref, rm, prompts):
|
||||
completions = policy.sample(prompts)
|
||||
rewards = rm(prompts, completions) - kl(policy, ref)
|
||||
# 매 reward로 policy update — positive reinforcement at scale
|
||||
return ppo_step(policy, prompts, completions, rewards)
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 빠른 행동 습득 | Continuous reinforcement (CRF) |
|
||||
| 행동 유지 + 소거 저항 | Variable Ratio (VR) |
|
||||
| 시간 기반 task | Fixed/Variable Interval |
|
||||
| RL agent | Reward shaping + sparse goal reward |
|
||||
| LLM alignment | RLHF / DPO (preference-based) |
|
||||
| Education / habit | Token economy + variable bonus |
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
**기본값**: 학습 phase는 CRF, 유지 phase는 VR. 매 punishment보다 reinforcement 우선.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Behaviorism]] · [[Operant_Conditioning]] · [[Learning_Theory]]
|
||||
- 변형: [[Negative_Reinforcement]] · [[Positive_Punishment]] · [[Reinforcement_Schedules]]
|
||||
- 응용: [[Reinforcement_Learning]] · [[RLHF]] · [[ABA_Therapy]] · [[Gamification]]
|
||||
- Adjacent: [[Reward_Function]] · [[Policy_Gradient]] · [[Variable_Reward]] · [[Skinner_Box]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: RL agent reward design, LLM RLHF/DPO pipeline 설계, gamification UX, behavior change app.
|
||||
**언제 X**: 매 intrinsic motivation 영역 (creative work)에서 매 over-reinforcement는 매 motivation crowding-out 일으킬 수 있음.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Reward hacking**: agent가 매 reward signal exploit (실제 task 무시) — Goodhart's law. 매 reward shaping 신중.
|
||||
- **Confusing positive with "good"**: positive = 추가, "좋은" 의미 X. Punishment도 positive 가능.
|
||||
- **Continuous reinforcement only**: 매 빠른 소거 — VR 전환 필요.
|
||||
- **Punishment as default**: 매 fear/avoidance 유발, learning quality 저하 — reinforcement 우선.
|
||||
- **Delayed reward without bridging stimulus**: 매 association 약함 — clicker 같은 marker 필요.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Skinner 1938 'Behavior of Organisms', APA Dictionary, Sutton & Barto RL textbook, OpenAI RLHF papers).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — operant conditioning quadrants + RL/RLHF connection |
|
||||
|
||||
Reference in New Issue
Block a user