[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,116 +2,200 @@
|
||||
id: wiki-2026-0508-exploration-vs-exploitation
|
||||
title: Exploration vs Exploitation
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Explore-Exploit, Multi-Armed Bandit Tradeoff, RL Tradeoff]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [auto-consolidated, technical-documentation]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [reinforcement-learning, bandits, decision-theory, optimization]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
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: numpy
|
||||
---
|
||||
|
||||
# [[Exploration vs Exploitation|Exploration vs Exploitation]]
|
||||
# Exploration vs Exploitation
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "모험과 안주의 저울질: 이미 알고 있는 최선을 선택하여 확실한 이득을 챙길 것인가(Exploitation), 아니면 더 큰 보상이 있을지 모르는 새로운 영역을 탐험할 것인가(Exploration) 사이의 영원한 전략적 딜레마."
|
||||
## 매 한 줄
|
||||
> **"매 known-best 의 exploit 의 unknown 의 explore 의 fundamental tradeoff"**. Exploration-exploitation dilemma 매 RL · bandits · A/B testing 의 core — 매 current best action 의 only 의 take 시 매 better unknown 의 miss, 매 too much explore 시 매 reward 의 burn. Optimal balance 매 horizon, prior, regret budget 의 function.
|
||||
|
||||
---
|
||||
## 매 핵심
|
||||
|
||||
> "안전한 현재의 수익과 불확실한 미래의 가능성 사이에서 최적의 배팅 지점을 찾아라" — 강화학습의 핵심 딜레마로, 이미 알고 있는 최선의 행동을 반복하여 보상을 얻는 것(Exploitation)과 더 나은 행동을 찾기 위해 새로운 시도를 하는 것(Exploration) 사이의 트레이드오프.
|
||||
### 매 Spectrum
|
||||
- **Pure exploit (greedy)**: 매 always 매 argmax Q(a) — 매 local optimum trap.
|
||||
- **Pure explore (random)**: 매 always uniform — 매 expected regret O(T).
|
||||
- **ε-greedy**: 매 prob ε 매 explore, 매 prob 1−ε 매 exploit.
|
||||
- **UCB**: 매 confidence-bounded 매 deterministic explore.
|
||||
- **Thompson Sampling**: 매 posterior sampling 매 Bayesian optimal.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
탐사 대 이용(Exploration vs Exploitation)은 강화학습과 의사결정 이론의 핵심적인 트레이드오프 문제입니다.
|
||||
### 매 Regret bounds
|
||||
- 매 ε-greedy(static): O(T).
|
||||
- 매 ε-greedy(decaying 1/t): O(log T).
|
||||
- 매 UCB1: O(log T) — provably tight for stochastic bandit.
|
||||
- 매 Thompson Sampling: matches Lai-Robbins lower bound.
|
||||
|
||||
1. **두 개념**:
|
||||
* **Exploitation (이용)**: 과거 경험상 보상이 가장 컸던 행동을 반복. 단기 수익 최적화.
|
||||
* **Exploration (탐사)**: 정보가 부족한 새로운 행동을 시도. 장기적인 '더 나은 최적해' 발견 가능성.
|
||||
2. **해결 전략**:
|
||||
* **Epsilon-Greedy**: 대부분($1-\epsilon$)은 이용하되, 무작위($\epsilon$)로 탐사.
|
||||
* **UCB (Upper Confidence Bound)**: 불확실성(가보지 않은 곳)에 가중치를 두어 탐사 유도.
|
||||
* **Thompson Sampling**: 확률 분포를 기반으로 유연하게 선택.
|
||||
### 매 응용
|
||||
1. A/B/n testing — adaptive traffic allocation.
|
||||
2. Recommender systems — cold start.
|
||||
3. Hyperparameter tuning (Optuna, Vizier).
|
||||
4. RL games — Atari, AlphaGo MCTS.
|
||||
5. LLM 매 sampling temperature, top-p.
|
||||
6. Drug trials — bandit-style adaptive design.
|
||||
|
||||
---
|
||||
## 💻 패턴
|
||||
|
||||
- **추출된 패턴:** 제한된 자원(시간, 에너지) 내에서 누적 보상을 극대화하기 위해 초기에는 광범위하게 탐색하고, 정보가 쌓일수록 최선의 선택에 집중하는 적응형 의사결정 패턴.
|
||||
- **주요 전략:**
|
||||
- **$\epsilon$-greedy:** 아주 작은 확률($\epsilon$)로 무작위 행동을 하고, 나머지 확률로 최선의 행동 수행.
|
||||
- **Softmax:** 보상 가치에 비례한 확률로 행동 선택.
|
||||
- **Upper Confidence Bound (UCB):** 불확실성이 큰 행동에 가산점을 주어 우선적으로 탐색.
|
||||
- **Thompson Sampling:** 확률 분포를 모델링하여 샘플링 기반으로 탐색 결정.
|
||||
- **의의:** 너무 빨리 활용에만 집중하면 지역 최적해(Local Optima)에 갇히고, 너무 탐색만 하면 보상을 충분히 얻지 못함.
|
||||
### ε-greedy bandit
|
||||
```python
|
||||
import numpy as np
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 최대한 빠르게 '안주 정책'으로 들어가는 것이 효율적이라 보았으나, 현대 정책은 복잡한 환경일수록 시스템에 '호기심(Curiosity) 정책'을 주입하여 끝까지 탐사하게 하는 것이 궁극의 지능을 만든다고 믿음(RL Update). (Reinforcement Learning과 연결)
|
||||
- **정책 변화(RL Update)**: 비즈니스 전략 정책에서, 기존 수익 모델에 안주하는 것(Exploitation)과 신사업을 발굴하는 것(Exploration) 사이의 '양손잡이 경영 정책'의 이론적 토대가 됨. ([[Strategic-Planning|Strategic-Planning]]과 연결)
|
||||
class EpsilonGreedy:
|
||||
def __init__(self, k, eps=0.1):
|
||||
self.k = k
|
||||
self.eps = eps
|
||||
self.Q = np.zeros(k)
|
||||
self.N = np.zeros(k)
|
||||
|
||||
---
|
||||
def select(self):
|
||||
if np.random.rand() < self.eps:
|
||||
return np.random.randint(self.k)
|
||||
return int(np.argmax(self.Q))
|
||||
|
||||
- **과거 데이터와의 충돌:** 단순히 '운'에 맡기던 무작위 탐색에서, 수학적 근거(UCB 등)를 바탕으로 '똑똑하게' 탐색하는 방식으로 진화.
|
||||
- **정책 변화:** Antigravity 프로젝트의 지식 검색 에이전트는 사용자의 질문에 대해 가장 관련성 높은 문서만 보여주는 것(Exploitation)을 넘어, 가끔은 의외의 연결 고리를 가진 문서를 제안(Exploration)하여 창의적 통찰을 돕도록 설계됨.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Reinforcement Learning (RL)|Reinforcement Learning (RL)]], Multi-Armed Bandit (MAB), [[Decision Theory|Decision Theory]], [[Strategic-Planning|Strategic-Planning]], [[Optimization|Optimization]]
|
||||
- **Modern Tech/Tools**: Recommender[[_system|system]]s (Exploration balance), A/B [[Testing|Testing]] algorithms.
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
- [[Reinforcement-Learning|Reinforcement-Learning]], Q-Learning-Foundations, Multi-Armed-Bandit-MAB, Decision-Making
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Exploration-vs-Exploitation.md
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
def update(self, a, r):
|
||||
self.N[a] += 1
|
||||
self.Q[a] += (r - self.Q[a]) / self.N[a]
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### UCB1
|
||||
```python
|
||||
class UCB1:
|
||||
def __init__(self, k):
|
||||
self.k, self.t = k, 0
|
||||
self.Q = np.zeros(k)
|
||||
self.N = np.zeros(k)
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
def select(self):
|
||||
self.t += 1
|
||||
for a in range(self.k):
|
||||
if self.N[a] == 0:
|
||||
return a # cold-start each arm once
|
||||
ucb = self.Q + np.sqrt(2 * np.log(self.t) / self.N)
|
||||
return int(np.argmax(ucb))
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
def update(self, a, r):
|
||||
self.N[a] += 1
|
||||
self.Q[a] += (r - self.Q[a]) / self.N[a]
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Thompson Sampling (Bernoulli)
|
||||
```python
|
||||
class ThompsonBernoulli:
|
||||
def __init__(self, k):
|
||||
self.alpha = np.ones(k) # successes + 1
|
||||
self.beta = np.ones(k) # failures + 1
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
def select(self):
|
||||
samples = np.random.beta(self.alpha, self.beta)
|
||||
return int(np.argmax(samples))
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
def update(self, a, r):
|
||||
if r > 0: self.alpha[a] += 1
|
||||
else: self.beta[a] += 1
|
||||
```
|
||||
|
||||
### Decaying ε schedule
|
||||
```python
|
||||
def epsilon(t, start=1.0, end=0.05, decay=10000):
|
||||
return end + (start - end) * np.exp(-t / decay)
|
||||
|
||||
# DQN-style: 매 early episodes 의 explore-heavy, 매 late 의 exploit
|
||||
```
|
||||
|
||||
### Boltzmann (softmax) exploration
|
||||
```python
|
||||
def softmax_select(Q, tau=1.0):
|
||||
p = np.exp(Q / tau)
|
||||
p /= p.sum()
|
||||
return np.random.choice(len(Q), p=p)
|
||||
# tau→0 매 greedy, tau→∞ 매 uniform
|
||||
```
|
||||
|
||||
### Contextual bandit (LinUCB)
|
||||
```python
|
||||
class LinUCB:
|
||||
def __init__(self, k, d, alpha=1.0):
|
||||
self.A = [np.eye(d) for _ in range(k)]
|
||||
self.b = [np.zeros(d) for _ in range(k)]
|
||||
self.alpha = alpha
|
||||
|
||||
def select(self, x): # context vector
|
||||
ucb = []
|
||||
for a in range(len(self.A)):
|
||||
Ainv = np.linalg.inv(self.A[a])
|
||||
theta = Ainv @ self.b[a]
|
||||
mean = theta @ x
|
||||
bonus = self.alpha * np.sqrt(x @ Ainv @ x)
|
||||
ucb.append(mean + bonus)
|
||||
return int(np.argmax(ucb))
|
||||
|
||||
def update(self, a, x, r):
|
||||
self.A[a] += np.outer(x, x)
|
||||
self.b[a] += r * x
|
||||
```
|
||||
|
||||
### LLM sampling 의 explore-exploit
|
||||
```python
|
||||
# temperature=0 → exploit (deterministic argmax)
|
||||
# temperature=1 → explore (full distribution)
|
||||
# top-p=0.9 → constrained explore (nucleus)
|
||||
def sample_token(logits, temperature=0.7, top_p=0.9):
|
||||
logits = logits / temperature
|
||||
probs = softmax(logits)
|
||||
sorted_idx = np.argsort(probs)[::-1]
|
||||
cum = np.cumsum(probs[sorted_idx])
|
||||
cutoff = np.searchsorted(cum, top_p) + 1
|
||||
keep = sorted_idx[:cutoff]
|
||||
p = probs[keep] / probs[keep].sum()
|
||||
return np.random.choice(keep, p=p)
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Stationary stochastic bandit | 매 UCB1 또는 Thompson |
|
||||
| Bernoulli reward | 매 Thompson Beta-binomial |
|
||||
| Contextual features 의 available | 매 LinUCB / NeuralBandit |
|
||||
| Non-stationary (drift) | 매 sliding-window UCB / discounted TS |
|
||||
| Deep RL | 매 ε-greedy decay 또는 noisy nets |
|
||||
| LLM creative generation | 매 temperature 0.7-1.0 + top-p 0.9 |
|
||||
|
||||
**기본값**: 매 Thompson Sampling — 매 strong empirical 의 winner, 매 simple implementation.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Reinforcement-Learning]] · [[Decision-Theory]]
|
||||
- 변형: [[Multi-Armed-Bandit]] · [[UCB]] · [[Thompson-Sampling]] · [[Epsilon-Greedy]]
|
||||
- 응용: [[A-B-Testing]] · [[Recommender-Systems]] · [[Hyperparameter-Tuning]] · [[MCTS]]
|
||||
- Adjacent: [[Bayesian-Optimization]] · [[Active-Learning]] · [[LLM-Sampling]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 sequential decision 매 reward feedback. Cold-start recommender. A/B 의 multi-arm 의 generalize.
|
||||
**언제 X**: 매 known reward distribution + horizon→∞ — 매 closed-form optimal. Single-shot decision.
|
||||
|
||||
## 어려운 점 (안티패턴)
|
||||
- **Static ε too high**: 매 ε=0.5 forever — 매 final 50% traffic 의 random arm 의 burn. Decay 의 use.
|
||||
- **No cold-start arms**: 매 UCB 의 N[a]=0 의 not-handled — 매 inf 의 produce, 매 each arm 의 1 초기 pull 의 require.
|
||||
- **Non-stationarity ignored**: 매 reward drift 의 discount 없이 의 stale Q value 의 trust.
|
||||
- **Reward leakage**: 매 future info 매 leak — 매 fake "exploit" 매 actually 의 cheat.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Sutton & Barto Ch. 2; Lai-Robbins 1985; Russo et al. "Tutorial on Thompson Sampling" 2018).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — explore-exploit + 7 algorithm patterns |
|
||||
|
||||
Reference in New Issue
Block a user