Eval cho agent khác eval cho model
Eval cho 1-turn LLM: cho prompt → check output. Đơn giản.
Eval cho agent: multi-turn, dùng tool, modify state → bug propagate + compound qua nhiều bước. Phức tạp hơn nhiều.
Từ vựng cần biết
- Task / Problem: 1 test có input + success criteria
- Trial: 1 lần chạy task. Nhiều trial → result ổn định hơn
- Grader: logic chấm điểm
- Transcript / Trace: ghi đầy đủ output + tool call + reasoning
- Outcome: state environment cuối cùng
- Harness: infrastructure chạy eval end-to-end
3 loại grader
Code-based
- Phương pháp: string match, binary test, static analysis
- Mạnh: nhanh, rẻ, objective, reproducible
- Yếu: brittle với variation hợp lệ; không dùng được cho task subjective
Model-based (LLM-as-judge)
- Phương pháp: rubric score, NL assertion, pairwise compare
- Mạnh: flexible, scale tốt, handle open-ended
- Yếu: non-deterministic, đắt, cần calibrate với human
Human
- Phương pháp: SME review, spot-check, A/B test
- Mạnh: gold-standard
- Yếu: đắt, chậm, không scale
Metrics cho non-deterministic
- pass@k: xác suất ít nhất 1 trong k trial PASS. Tăng khi k tăng.
- pass^k: xác suất TẤT CẢ k trial pass. Giảm khi k tăng — đo độ ổn định cho production.
Ví dụ: agent có 75% per-trial success → pass^3 = 0.75³ ≈ 42%. Để customer-facing cần pass^k cao.
Roadmap zero-to-one
Phase 1: Task collection
- Bắt đầu với 20-50 task đơn giản từ failure thực, không phải hundreds
- Convert manual test đang chạy thành eval
- Spec rõ ràng: SME độc lập đọc → cùng verdict
- Balance positive + negative cases
Phase 2: Harness + grader
- Mỗi trial state sạch — không share state
- Grader đo output, không đo path (cho phép agent giải khác hợp lệ)
- Calibrate LLM-judge với human trước khi tin
Phase 3: Long-term
- Đọc transcript thường xuyên — verify grader đúng
- Theo dõi saturation — khi pass rate cao quá → refresh eval suite
- Eval team riêng cho infra
Anti-pattern cần tránh
| Anti-pattern | Vấn đề |
|---|---|
| Grade RIGID step sequence | Punish valid alternative solution |
| Spec ambiguous | Fail vì spec tệ, không phải agent dở |
| Eval one-directional | Tối ưu lệch |
| Share state giữa trial | Correlated failure |
| Trust score mà không đọc transcript | Bỏ sót edge case |
Frameworks gợi ý
- Harbor — containerized eval, scale lớn
- Braintrust — eval + production observability
- LangSmith — tracing + eval (Lang ecosystem)
- Langfuse — self-hosted alternative
- Arize Phoenix — open-source
Nguồn chính thống: anthropic.com/engineering/demystifying-evals-for-ai-agents