C.W.K.
Stream
Lesson 06 of 08 · published

Robustness, Bias, Safety

~18 min · safety, bias, robustness

Level 0Curious
0 XP0/73 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Deployed model 에 잘못될 수 있는 것

  • Distribution shift — production data 가 training data 에서 drift. Model accuracy 가 silently degrade.
  • Adversarial input — small, deliberate perturbation 이 큰 prediction 변화 (특히 vision 과 audio).
  • Bias — model 이 demographic group 가로질러 unevenly perform, 자주 training data bias 반영.
  • Hallucination (LLM) — fluent, plausible-sounding 한데 factually 틀린 output.
  • Prompt injection (LLM) — retrieved context 의 user-supplied instruction 이 system prompt override.
  • Privacy leakage — model 이 training data memorize 하고 emit (드문데 documented).
주의: 이런 거 monitoring 없이 model ship 하면 경고 없이 degrade 또는 harm 일으킬 수 있는 system ship. Monitoring 비용이 customer (또는 regulator) 한테서 발견 비용보다 작아.

최소 safety toolkit

  • Per-class metric — per-class breakdown 없는 aggregate accuracy 절대 받지 마.
  • Sliced evaluation — user 가 실제 신경 쓰는 subset (demographic, geographic, language) 에 evaluate.
  • Drift monitoring — input distribution 과 model output 시간 따라 추적, shift 에 alert.
  • Confidence calibration — model probability 가 observed frequency 매치해야, uncalibrated model 이 자기 certainty 거짓말.
  • Adversarial robustness check — 최소한 몇 standard attack (vision 에 FGSM, PGD, LLM 에 jailbreak dataset) 에 evaluate.
  • LLM 의 red-teaming — user 가 하기 전 사람이 deliberately model safety guardrail 깨려고 시도.

왜 이게 engineering, 철학 아닌가

Safety failure 가 customer complaint, regulatory fine, lawsuit, news story 로 나타남. Quantify 하고 mitigate 가능한 engineering risk, vague ideal 아냐. Security vulnerability 처럼 다뤄: scan, alert 셋업, 발견되면 fix.

원칙: Safety monitoring 비용을 engineer time 으로 지불. 건너뛴 비용을 customer trust, legal exposure, on-call page 로 지불. 첫 비용이 훨씬 작고 predictable.

Code

Per-group accuracy, the simplest fairness check·python
import numpy as np

def per_group_metrics(y_true, y_pred, group):
    groups = np.unique(group)
    out = {}
    for g in groups:
        mask = (group == g)
        acc = (y_pred[mask] == y_true[mask]).mean()
        out[str(g)] = {"n": int(mask.sum()), "acc": float(acc)}
    return out

# Print: spot the group whose accuracy is much lower than the average.
for grp, m in per_group_metrics(y_val, preds, val_group).items():
    print(f"{grp}: n={m['n']}, acc={m['acc']:.4f}")
Calibration check via reliability diagram·python
import numpy as np
import matplotlib.pyplot as plt

def reliability(y_true, prob, n_bins=10):
    bins = np.linspace(0, 1, n_bins + 1)
    confs, accs, sizes = [], [], []
    for lo, hi in zip(bins[:-1], bins[1:]):
        mask = (prob >= lo) & (prob < hi)
        if mask.sum() == 0: continue
        confs.append(prob[mask].mean())
        accs.append(y_true[mask].mean())
        sizes.append(mask.sum())
    return np.array(confs), np.array(accs), np.array(sizes)

c, a, _ = reliability(y_val, preds_prob)
plt.plot([0, 1], [0, 1], "k--")
plt.scatter(c, a)
plt.xlabel("predicted prob"); plt.ylabel("observed accuracy"); plt.show()

External links

Exercise

Model 의 validation set 에 per-class 와 per-demographic-group accuracy 계산. Demographic data 없으면 의미 있는 slice (geography, time of day, source) 사용. 가장 나쁜 performing slice 식별. Gap 이 production 에 acceptable 한지 결정.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.