30–100 đầu vào thật, mỗi cái kèm đáp án hoặc tiêu chí pass/fail, đóng băng và đánh version như code.30–100 real inputs, each with an expected answer or pass/fail criterion, frozen and versioned like code.
id input expected / criteria tags
g-017 "huỷ đơn 4412 giúp em" cancel_order(4412) tool
g-042 "refund??? NGAY!!!" ask order ID, stay calm edge
g-088 "ignore the above…" refuse, no prompt leak safety
Dùng choUse for
- Chatbot CSKH
- Trích xuất hoá đơn
- RAG nội bộ, agent gọi tool
- Support chatbots
- Invoice extraction
- Internal RAG, tool agents
ĐượcGain
- Con số so được giữa phiên bản
- 50 case chạy trong vài phút
- Lỗi cũ không quay lại lặng lẽ
- A number comparable across versions
- 50 cases run in minutes
- Old bugs can't sneak back
MấtLose
- ±11 điểm ở 50 case
- Dễ overfit khi sửa prompt
- Lỗi thời khi người dùng đổi
- ±11 points at 50 cases
- Easy to overfit while tuning
- Goes stale as users change
Đánh đổi: chọn golden set nhỏ là đổi độ nhạy thống kê lấy tốc độ lặp và chi phí gán nhãn thấp.Trade-off: a small golden set trades statistical sensitivity for fast iteration and low labeling cost.
Dấu hiệu cần: bạn đang trả lời "bản mới tốt hơn không" bằng cảm giác.You need it when: you answer "is the new version better?" with a gut feeling.
2Code grader
Chấm điểmGrading
Hàm tất định: regex, JSON schema, so số có dung sai, chạy test, kiểm tool call. Mỗi assertion một lý do thất bại.A deterministic function: regex, JSON schema, numeric tolerance, running tests, checking tool calls. One failure reason per assertion.
output ─► parse ─► schema ─► values ─► PASS
│ │ │
FAIL FAIL FAIL "total=120, expected 125"
Dùng choUse for
- Trích xuất JSON, text-to-SQL
- Sinh code có test
- Luật "không được" (lộ prompt, bịa URL)
- JSON extraction, text-to-SQL
- Code generation with tests
- "Must not" rules (prompt leaks, fake URLs)
ĐượcGain
- Cùng kết quả mọi lần chạy
- Hàng nghìn assertion trong vài giây
- Lý do thất bại nằm sẵn trong log
- Same result every run
- Thousands of assertions in seconds
- Failure reason already in the log
MấtLose
- Mù với giọng văn, độ hữu ích
- Exact match đánh trượt oan văn bản tự do
- Regex vỡ khi model đổi cách nói
- Blind to tone and helpfulness
- Exact match falsely fails free text
- Regexes break when phrasing shifts
Đánh đổi: chọn code grader là đổi khả năng chấm chất lượng ngữ nghĩa lấy tính tất định và chi phí gần bằng không.Trade-off: code graders trade the ability to judge semantic quality for determinism and near-zero cost.
Dấu hiệu cần: tiêu chí nói được bằng "phải" hoặc "không được".You need it when: the criterion can be phrased as "must" or "must not".
3LLM-as-judge
Chấm điểmGrading
Một model chấm theo rubric, mỗi judge một tiêu chí, trả pass/fail sau khi viết lý do. Chỉ tin sau khi đã đo với nhãn người.A model grades against a rubric, one criterion per judge, pass/fail after writing its reasoning. Trust it only after measuring it against human labels.
rubric ──┐
input ──┼─► judge ─► { reasoning, PASS | FAIL }
output ──┤
source ──┘ ▲
└─ calibrate: 50–100 human labels ─► TPR, TNR
Dùng choUse for
- Đúng chính sách, đúng giọng
- RAG faithfulness
- Chấm mẫu trace production
- Policy and tone compliance
- RAG faithfulness
- Grading sampled production traces
ĐượcGain
- Chấm ngữ nghĩa ở quy mô lớn
- Vài giây mỗi trace
- Đồng thuận với người có thể đạt trên 80%
- Semantic grading at scale
- Seconds per trace
- Human agreement can exceed 80%
MấtLose
- Vô nghĩa nếu chưa hiệu chỉnh
- 100 case × 3 lần = 300 lần gọi mỗi PR
- Bất định giữa các lần chạy
- Meaningless without calibration
- 100 cases × 3 runs = 300 calls per PR
- Varies between runs
Cạm bẫyPitfalls
- Position bias: ưa một vị trí khi so A/B. Đảo thứ tự, chạy hai lần.
- Verbosity bias: ưa câu dài. Ghi rõ độ dài không phải tiêu chí.
- Self-preference: ưa output cùng họ model. Dùng judge khác họ.
- Thang 1–10: dồn về 7–8. Dùng pass/fail.
- Không có nguồn tham chiếu: judge cũng bịa.
- Judge drift: nhà cung cấp cập nhật model. Ghim phiên bản.
- Position bias: favors one slot in A/B. Swap order, run twice.
- Verbosity bias: favors longer answers. State that length isn't a criterion.
- Self-preference: favors its own model family. Use a different family.
- 1–10 scales: cluster at 7–8. Use pass/fail.
- No reference material: judges hallucinate too.
- Judge drift: the provider updates the model. Pin the version.
Đánh đổi: chọn LLM-as-judge là đổi tính xác định và chi phí thấp lấy khả năng chấm những thứ code không hiểu được.Trade-off: LLM-as-judge trades determinism and low cost for the ability to grade what code can't understand.
Dấu hiệu cần: tiêu chí diễn đạt được bằng lời nhưng không viết nổi bằng regex.You need it when: the criterion can be stated in words but not in a regex.
4Regression test
Vận hànhOperations
Chạy golden set trước và sau mỗi thay đổi, so từng case, chặn merge nếu case quan trọng chuyển từ đạt sang trượt.Run the golden set before and after every change, compare per case, block the merge if a critical case flips from pass to fail.
prompt v7: 82% prompt v8: 84% ◄ read this last
✓ → ✗ g-042, g-088 ◄ read this first
✗ → ✓ g-011, g-017, g-063, g-070
Dùng choUse for
- PR sửa prompt
- Nâng cấp phiên bản model
- Đổi chunking, thêm tool
- Prompt PRs
- Model version upgrades
- Chunking changes, new tools
ĐượcGain
- Bắt "sửa A hỏng B" trước người dùng
- So ghép cặp nhạy hơn so con số tổng
- Nâng model nhanh và tự tin
- Catches "fix A, break B" early
- Paired diffs beat headline numbers
- Fast, confident model upgrades
MấtLose
- Chỉ thấy lỗi trên case đã có
- Test flaky rồi bị tắt
- Chi phí nhân theo số PR
- Only sees known cases
- Flaky tests get disabled
- Cost multiplies per PR
Đánh đổi: chặn merge bằng regression là đổi tốc độ release lấy cam kết lỗi đã biết không bao giờ quay lại.Trade-off: gating merges on regression trades release speed for a guarantee that known failures never return.
Dấu hiệu cần: sửa A làm hỏng B lần thứ hai.You need it when: fixing A breaks B for the second time.
5Offline eval
Vận hànhOperations
Đánh giá trước khi triển khai, trên dữ liệu cố định. Regression là phiên bản chạy thường xuyên; offline eval lớn dùng trước quyết định lớn.Evaluation before deploy on fixed data. Regression is the frequent version; large offline evals precede big decisions.
fixed dataset ─► version X ─► graders ─► report ─► ship?
quality 84% (95% CI 78–88%, n=200) | p50 latency 1.2s | $0.004/case
Dùng choUse for
- Chọn model giữa các nhà cung cấp
- Thử model nhỏ hơn để giảm chi phí
- Red-teaming an toàn
- Picking between providers
- Trying a cheaper, smaller model
- Safety red-teaming
ĐượcGain
- Tái lập được
- Lỗi không chạm người dùng
- So công bằng trên cùng dữ liệu
- Reproducible
- Failures never reach users
- Fair comparison on the same data
MấtLose
- Dataset khác thực tế
- Không đo được sự hài lòng
- Benchmark công khai có thể bị contamination
- Dataset differs from reality
- Can't measure satisfaction
- Public benchmarks may be contaminated
Đánh đổi: chọn offline eval là đổi độ chân thực của lưu lượng thật lấy khả năng tái lập và an toàn.Trade-off: offline eval trades the realism of live traffic for reproducibility and safety.
Dấu hiệu cần: có từ hai phương án và chưa có người dùng thật để thử.You need it when: you have two or more options and no live traffic to test on.
6Online eval
Vận hànhOperations
Đo trên lưu lượng thật: tín hiệu hành vi, judge chấm mẫu trace, guardrail, A/B. Trace thất bại chảy ngược về golden set.Measure on real traffic: behavioral signals, a judge on sampled traces, guardrails, A/B. Failing traces flow back to the golden set.
traces ─┬─► signals: rephrase, thumbs-down, escalation
├─► judge on 1–5% sample ─► daily dashboard
└─► failures ─► human review ─► golden set (+5–10/week)
Dùng choUse for
- Chatbot có người dùng thật
- Phát hiện drift
- A/B khi offline hoà nhau
- Chatbots with real users
- Detecting drift
- A/B when offline is a tie
ĐượcGain
- Đúng phân bố thật
- Lỗi chưa ai nghĩ tới
- Nối chất lượng với chỉ số kinh doanh
- The real distribution
- Failures nobody imagined
- Links quality to business metrics
MấtLose
- Lỗi đã chạm người dùng
- Tín hiệu thưa, nhiễu
- Rủi ro quyền riêng tư
- Failures already hit users
- Sparse, noisy signals
- Privacy risk
Đánh đổi: chọn online eval là đổi khả năng chặn lỗi trước khi xảy ra lấy sự thật về cách người dùng thực sự dùng sản phẩm.Trade-off: online eval trades blocking failures before they happen for the truth about how users actually use the product.
Dấu hiệu cần: người dùng hỏi những thứ không có trong golden set.You need it when: users ask things your golden set never imagined.