[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,62 +2,172 @@
|
||||
id: wiki-2026-0508-label-noise-and-robustness
|
||||
title: Label Noise and Robustness
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [ML-ROBUST-001]
|
||||
aliases: [Noisy Labels, Label Cleaning, Confident Learning]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 1.0
|
||||
tags: [machine-learning, label-Noise, Robustness, robust-learning, data-quality]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [ml, label-noise, cleanlab, robust-loss, gce, symmetric-ce]
|
||||
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: python, framework: cleanlab/pytorch }
|
||||
---
|
||||
|
||||
# Label Noise and Robustness (레이블 노이즈와 강건성)
|
||||
# Label Noise and Robustness
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "데이터의 거짓(Noise)에 현혹되지 말고, 다수의 일관된 증거 속에 숨겨진 진실된 패턴을 포착하라" — 훈련 데이터에 포함된 잘못된 레이블(정답)에도 불구하고, 모델이 일반화된 성능을 유지하며 실제 정답 분포를 올바르게 학습하게 만드는 기술.
|
||||
## 매 한 줄
|
||||
> **"매 데이터셋의 라벨은 거짓말한다"**. Confident learning 으로 의심 라벨 찾고, robust loss 로 학습 자체를 노이즈에 둔감하게.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **추출된 패턴:** "Noise-tolerance" — 손실 함수를 수정하여 특정 오차에 둔감하게 만들거나, 신뢰할 수 없는 샘플의 비중을 낮추어 정제되지 않은 데이터로부터 핵심 정보를 추출하는 방어적 학습 패턴.
|
||||
- **주요 전략:**
|
||||
- **Robust [[Loss Functions|Loss Functions]]:** 평균 제곱 오차(MSE)보다 이상치에 강한 절대 오차(MAE)나 후버 손실(Huber Loss) 사용.
|
||||
- **Sample Cleaning/Selection:** 모델이 확신을 가지지 못하는 샘플을 잠재적 노이즈로 판단하여 제거하거나 가중치를 낮춤.
|
||||
- **Label Smoothing:** 정답을 1.0이라는 절대적 수치 대신 0.9 정도로 완화하여 모델의 과도한 확신을 억제.
|
||||
- **의의:** 완벽한 레이블링이 불가능한 대규모 실제 데이터셋(웹 크롤링 등) 환경에서 안정적인 AI 시스템을 구축하기 위한 필수 조건.
|
||||
## 매 핵심
|
||||
### 매 노이즈 종류
|
||||
- **Symmetric** (uniform): 모든 클래스로 균등 flip
|
||||
- **Asymmetric** (class-conditional): 비슷한 class 로 flip (cat→dog 高)
|
||||
- **Instance-dependent**: 어려운 sample 일수록 noise 높음 (가장 현실적, 가장 어려움)
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 깨끗한 데이터만이 정답이라는 결벽증적 사고에서 벗어나, 노이즈 섞인 방대한 데이터가 소량의 정제 데이터보다 지능 향상에 더 기여할 수 있음을 입증하는 방향으로 연구가 전개됨.
|
||||
- **정책 변화:** Antigravity 프로젝트는 비정형 로우 데이터(`00_Raw`)에서 지식을 자동 추출할 때, 추출 엔진 간의 불일치를 노이즈로 간주하고 다수결 및 신뢰도 기반 필터링을 통해 지식의 무결성을 확보함.
|
||||
### 매 두 갈래
|
||||
- **Data-centric**: 의심 라벨 찾아서 제거/수정 → cleanlab, confident learning
|
||||
- **Model-centric**: 노이즈가 있어도 학습 강건 → robust loss (GCE, SCE), co-teaching, MixUp
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Loss-Functions-Foundations|Loss-Functions-Foundations]], Un[[Supervised-Learning-Foundations|Supervised-Learning-Foundations]], [[Supervised-Learning-Foundations|Supervised-Learning-Foundations]], [[Generalization-in-AI|Generalization-in-AI]]
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Label-Noise-and-Robustness.md
|
||||
### 매 응용
|
||||
1. Crowdsourced 라벨 정리
|
||||
2. Web-scraped dataset cleaning
|
||||
3. Auto-label 후 검증
|
||||
4. Class imbalance + noise 동시
|
||||
5. Active learning 의 라벨 효율 극대화
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Pattern 1: cleanlab basic
|
||||
```python
|
||||
from cleanlab.classification import CleanLearning
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
cl = CleanLearning(clf=LogisticRegression())
|
||||
cl.fit(X, y) # 자동으로 의심 label 찾고 제거 후 재학습
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
# 또는 의심 label 만 받기
|
||||
from cleanlab.filter import find_label_issues
|
||||
pred_probs = model.predict_proba(X)
|
||||
issues = find_label_issues(labels=y, pred_probs=pred_probs, return_indices_ranked_by="self_confidence")
|
||||
print(f"의심 label {len(issues)} 개")
|
||||
```
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### Pattern 2: Confident learning manual
|
||||
```python
|
||||
# 1. K-fold OOF prediction
|
||||
from sklearn.model_selection import cross_val_predict
|
||||
pred_probs = cross_val_predict(model, X, y, cv=5, method="predict_proba")
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
# 2. cleanlab 으로 issue 탐지
|
||||
from cleanlab import Datalab
|
||||
lab = Datalab(data={"X": X, "y": y}, label_name="y")
|
||||
lab.find_issues(pred_probs=pred_probs)
|
||||
lab.report()
|
||||
```
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
### Pattern 3: Generalized Cross Entropy (GCE)
|
||||
```python
|
||||
import torch, torch.nn.functional as F
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
class GCELoss(torch.nn.Module):
|
||||
def __init__(self, q=0.7):
|
||||
super().__init__()
|
||||
self.q = q
|
||||
def forward(self, logits, targets):
|
||||
probs = F.softmax(logits, dim=-1)
|
||||
p_t = probs.gather(1, targets.unsqueeze(1)).squeeze(1).clamp(min=1e-7)
|
||||
return ((1 - p_t.pow(self.q)) / self.q).mean()
|
||||
# q→0 = CE, q→1 = MAE. 0.5~0.7 권장
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### Pattern 4: Symmetric Cross Entropy
|
||||
```python
|
||||
class SCELoss(torch.nn.Module):
|
||||
def __init__(self, alpha=0.1, beta=1.0, num_classes=10):
|
||||
super().__init__(); self.a, self.b, self.K = alpha, beta, num_classes
|
||||
def forward(self, logits, targets):
|
||||
probs = F.softmax(logits, dim=-1).clamp(1e-7, 1.0)
|
||||
oh = F.one_hot(targets, self.K).float().clamp(1e-4, 1.0)
|
||||
ce = F.cross_entropy(logits, targets)
|
||||
rce = -(probs * oh.log()).sum(dim=1).mean() # Reverse CE
|
||||
return self.a * ce + self.b * rce
|
||||
```
|
||||
|
||||
### Pattern 5: Co-teaching (small-loss trick)
|
||||
```python
|
||||
def co_teaching_step(net1, net2, x, y, opt1, opt2, forget_rate):
|
||||
logits1, logits2 = net1(x), net2(x)
|
||||
losses1 = F.cross_entropy(logits1, y, reduction="none")
|
||||
losses2 = F.cross_entropy(logits2, y, reduction="none")
|
||||
# 서로의 small-loss sample 만 학습에 사용
|
||||
keep = int(len(y) * (1 - forget_rate))
|
||||
idx1 = losses1.argsort()[:keep]
|
||||
idx2 = losses2.argsort()[:keep]
|
||||
opt1.zero_grad(); F.cross_entropy(net1(x[idx2]), y[idx2]).backward(); opt1.step()
|
||||
opt2.zero_grad(); F.cross_entropy(net2(x[idx1]), y[idx1]).backward(); opt2.step()
|
||||
```
|
||||
|
||||
### Pattern 6: Label smoothing as mild regularization
|
||||
```python
|
||||
loss = F.cross_entropy(logits, y, label_smoothing=0.1)
|
||||
# 0.05~0.15. 가벼운 noise 에 효과 있음, heavy noise 엔 부족
|
||||
```
|
||||
|
||||
### Pattern 7: MixUp (간접적 robustness)
|
||||
```python
|
||||
def mixup(x, y, alpha=0.2):
|
||||
lam = np.random.beta(alpha, alpha)
|
||||
idx = torch.randperm(x.size(0))
|
||||
return lam * x + (1 - lam) * x[idx], y, y[idx], lam
|
||||
|
||||
x_m, ya, yb, lam = mixup(x, y)
|
||||
loss = lam * F.cross_entropy(model(x_m), ya) + (1 - lam) * F.cross_entropy(model(x_m), yb)
|
||||
```
|
||||
|
||||
### Pattern 8: Cleanlab + confident learning + retraining loop
|
||||
```python
|
||||
issues = find_label_issues(y, pred_probs)
|
||||
clean_idx = [i for i in range(len(y)) if i not in issues]
|
||||
model.fit(X[clean_idx], y[clean_idx]) # 또는 issues 를 사람에게 review
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 의심 label 찾아서 사람이 검토 | cleanlab |
|
||||
| 라벨 수정 못 함, 학습만 가능 | GCE / SCE |
|
||||
| 메모리/compute 충분 | Co-teaching (2 model) |
|
||||
| 가벼운 noise (~5%) | Label smoothing + MixUp |
|
||||
| Heavy noise (>30%) | GCE + cleanlab filter |
|
||||
|
||||
**기본값**: cleanlab 으로 1차 정리 + GCE loss + label smoothing.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Machine_Learning]], [[Data_Quality]]
|
||||
- 변형: [[Active_Learning]], [[Weak_Supervision]]
|
||||
- 응용: [[Image_Classification]], [[NLP_Classification]]
|
||||
- Adjacent: [[LLM_Ops_and_Tuning]], [[Crowdsourcing]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 의심 라벨 sample 을 LLM 으로 재라벨 (annotator 보조), 라벨링 가이드 자동 생성.
|
||||
**언제 X**: high-stakes ground truth (의료, 법률) — 사람 검증 필수.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- 의심 label 자동 삭제 후 사람 검토 X → 진짜 hard sample 손실
|
||||
- CE 만 쓰고 noise 30% 데이터 학습 → overfitting to noise
|
||||
- Train/val 둘 다 noisy → eval 자체가 거짓말 (clean test set 분리 필수)
|
||||
- cleanlab 한 번 돌리고 끝 → 모델 개선되면 다시 돌려야 함
|
||||
- Co-teaching 에 동일 모델 2개 → diversity 0, 효과 없음
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (cleanlab Northcutt 2021 confident learning, GCE Zhang 2018, SCE Wang 2019, Co-teaching Han 2018). 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — data-centric vs model-centric, GCE/SCE/co-teaching code |
|
||||
|
||||
Reference in New Issue
Block a user