c24165b8bc
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5.6 KiB
5.6 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-out-of-distribution-detection | Out-of-Distribution Detection | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Out-of-Distribution Detection
매 한 줄
"매 model 이 본 적 없는 input 의 거부". OOD detection 은 inference 시 input 이 training distribution 밖인지 판정하여 silent failure 를 막는 safety layer. 매 2026 의 표준은 foundation-model embedding 위 의 KNN / Mahalanobis 또는 logit-energy score, classical ODIN 은 baseline.
매 핵심
매 score family
- Softmax baseline (MSP): max softmax probability — weak baseline.
- ODIN (Liang 2018): temperature scaling + input gradient perturbation.
- Energy (Liu 2020):
-T * logsumexp(logits / T), free, strong. - Mahalanobis (Lee 2018): class-conditional Gaussian on penultimate features.
- KNN (Sun 2022): k-NN distance in feature space — 매 simple, robust.
- DOSE / VIM (2022-2024): residual + logit hybrid.
- Foundation-model OOD (CLIP, DINOv2 features + KNN) — 2026 SOTA.
매 evaluation
- AUROC, FPR@95TPR, AUPR.
- ID = CIFAR-10/ImageNet, OOD = SVHN, Textures, iNaturalist, Places, OpenOOD bench.
- near-OOD (CIFAR10 vs CIFAR100) 가 매 어려운 case.
매 응용
- autonomous driving 의 unknown object reject.
- medical imaging 의 unsupported modality flag.
- LLM 의 jailbreak / off-distribution prompt detection.
- fraud detection 의 novel attack pattern.
💻 패턴
Energy score (Liu 2020)
import torch, torch.nn.functional as F
@torch.no_grad()
def energy_score(model, x, T=1.0):
logits = model(x)
# higher energy = OOD
return -T * torch.logsumexp(logits / T, dim=-1)
MSP baseline
@torch.no_grad()
def msp(model, x):
return -F.softmax(model(x), dim=-1).max(-1).values
Mahalanobis on features
@torch.no_grad()
def fit_mahalanobis(features, labels, num_classes):
means = []
for c in range(num_classes):
means.append(features[labels == c].mean(0))
means = torch.stack(means)
centered = features - means[labels]
cov = centered.T @ centered / len(features)
inv = torch.linalg.pinv(cov)
return means, inv
def maha_score(f, means, inv):
diffs = f.unsqueeze(1) - means # [N, C, D]
d2 = torch.einsum("ncd,de,nce->nc", diffs, inv, diffs)
return d2.min(-1).values # smallest distance to any class
KNN OOD (Sun 2022)
import torch, torch.nn.functional as F
class KNNOOD:
def __init__(self, k=50):
self.k = k
def fit(self, train_feats):
self.bank = F.normalize(train_feats, dim=-1)
def score(self, feats):
f = F.normalize(feats, dim=-1)
sim = f @ self.bank.T # cosine
topk = sim.topk(self.k, dim=-1).values
return -topk[:, -1] # negative k-th similarity → OOD score
ODIN
def odin_score(model, x, T=1000, eps=0.0014):
x = x.clone().detach().requires_grad_(True)
logits = model(x) / T
p = F.softmax(logits, dim=-1).max(-1).values
p.sum().backward()
x_adv = x - eps * x.grad.sign()
with torch.no_grad():
return F.softmax(model(x_adv) / T, dim=-1).max(-1).values
Foundation-model OOD (DINOv2 + KNN)
import torch
dino = torch.hub.load("facebookresearch/dinov2", "dinov2_vitb14").eval().cuda()
@torch.no_grad()
def feats(x):
return dino(x) # [B, 768]
knn = KNNOOD(k=50)
knn.fit(feats(train_loader_id))
ood_scores = knn.score(feats(test_batch))
LLM OOD via embedding
from sentence_transformers import SentenceTransformer
emb = SentenceTransformer("BAAI/bge-large-en-v1.5")
id_bank = emb.encode(in_dist_prompts, normalize_embeddings=True)
def prompt_ood(prompt, k=20):
q = emb.encode([prompt], normalize_embeddings=True)
sims = (q @ id_bank.T)[0]
return -sims.topk(k).values.min()
Threshold calibration (FPR@95TPR)
import numpy as np
def threshold_at_tpr(scores_id, tpr=0.95):
return np.quantile(scores_id, 1 - tpr)
매 결정 기준
| 상황 | Method |
|---|---|
| 매 simple, 즉시 | Energy |
| 매 best AUROC | KNN on foundation features |
| 매 access to features only | Mahalanobis |
| 매 CV with strong backbone | DINOv2 + KNN |
| 매 LLM input filter | embedding KNN + threshold |
| 매 production, low-latency | Energy or MSP |
기본값: foundation embedding + KNN (k=50).
🔗 Graph
- 부모: Anomaly-Detection
- 변형: KNN
- 응용: Active Learning
🤖 LLM 활용
언제: 매 high-stakes deployment, jailbreak filter, novel-prompt routing. 언제 X: 매 closed-world benchmark — distribution 가 fixed 인 경우 overhead.
❌ 안티패턴
- MSP only: 매 over-confident network 에서 거의 무력.
- Train OOD detector on test OOD set: leakage, false confidence.
- Threshold from training scores: ID validation set 에서 calibrate.
- Ignore near-OOD: far-OOD AUROC 99% 인데 near-OOD 60% 인 흔한 함정.
- Foundation-model embedding mismatch: ImageNet-pretrained 으로 medical OOD detect.
🧪 검증 / 중복
- Verified (OpenOOD benchmark 2024, Sun 2022 KNN, Liu 2020 Energy).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Energy/Maha/KNN + foundation-model OOD |