docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,201 @@
---
id: wiki-2026-0508-exploration-vs-exploitation
title: Exploration vs Exploitation
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Explore-Exploit, Multi-Armed Bandit Tradeoff, RL Tradeoff]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [reinforcement-learning, bandits, decision-theory, optimization]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: python
framework: numpy
---
# Exploration vs Exploitation
## 매 한 줄
> **"매 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.
## 매 핵심
### 매 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.
### 매 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. 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.
## 💻 패턴
### ε-greedy bandit
```python
import numpy as np
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))
def update(self, a, r):
self.N[a] += 1
self.Q[a] += (r - self.Q[a]) / self.N[a]
```
### UCB1
```python
class UCB1:
def __init__(self, k):
self.k, self.t = k, 0
self.Q = np.zeros(k)
self.N = np.zeros(k)
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))
def update(self, a, r):
self.N[a] += 1
self.Q[a] += (r - self.Q[a]) / self.N[a]
```
### Thompson Sampling (Bernoulli)
```python
class ThompsonBernoulli:
def __init__(self, k):
self.alpha = np.ones(k) # successes + 1
self.beta = np.ones(k) # failures + 1
def select(self):
samples = np.random.beta(self.alpha, self.beta)
return int(np.argmax(samples))
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]]
- 응용: [[Recommender-Systems]] · [[Hyperparameters|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 |