4.4.16 · HinglishAlignment, Prompting & RAG

Evaluation of LLMs (benchmarks, LLM-as-judge)

3,619 words16 min readRead in English

4.4.16 · AI-ML › Alignment, Prompting & RAG

Core Problem: The Evaluation Gap

Language model evaluation teen challenges face karta hai:

  1. Capability diversity: LLMs math se lekar creative writing aur code tak sab kuch karte hain
  2. Output subjectivity: "Achha" har task ke hisaab se alag hota hai (factual vs. creative vs. helpful)
  3. Human evaluation cost: Expert review lakhon outputs ke liye scale nahi hoti

Solution approach: Objective benchmarks (measurable skills ke liye) aur model-based judges (subjective quality ke liye) ko combine karo.


Part 1: Benchmark Evaluation

Benchmarks Kaise Kaam Karte Hain

Pipeline:

Model → Prompt with task → Generate output → Compare to answer → Compute metric

Key benchmark types:

| Type | Measures | Example Metric | |------|----------|------|-----| | Multiple choice | Knowledge recall | MMLU (57 subjects) | Accuracy | | Code generation | Programming ability | HumanEval, MBPP | Pass@k (% passing tests) | | Math word problems | Reasoning | GSM8K, MATH Exact match | | Reading comprehension | Understanding | SQuAD, DROP | F1 score | | Instruction following | Alignment | MT-Bench, AlpacaEval | Win rate vs baseline |

Figure — Evaluation of LLMs (benchmarks, LLM-as-judge)

Pass@k First Principles Se Derive Karna

Problem: Model har problem ke liye code samples generate karta hai. Probability kya hai ki ≥1 correct hai?

Setup:

  • = total problems
  • = woh problems jahan samples mein se ≥1 ne sare tests pass kiye
  • = true probability ki ek single sample correct hai (unknown)

Derivation:

Subtract kyun karte hain? Complement compute karna aasaan hai:

Agar samples independent hain:

Lekin pata nahi! Data se estimate karo:

Ye estimator kyun? Maximum likelihood: observed success rate = true rate ka best guess.

Final formula:


Part 2: LLM-as-Judge

Isko Kyun Chahiye

Scenarios jahan benchmarks fail karte hain:

  • Creative tasks: "Akele pan par ek haiku likho" (koi ground truth nahi)
  • Open-ended QA: "Aasman neela kyun hota hai explain karo" (bahut saare valid explanations hain)
  • Conversational ability: Multi-turn dialogues (context-dependent quality)
  • Alignment: Kya response helpful aur safe hai? (subjective judgment)

Human evaluation ki problems:

  • Expensive: Rating ke liye $0.50–5, large-scale tuning ke liye lakhs chahiye
  • Slow: Crowdworker consensus ke liye days se weeks lagte hain
  • Inconsistent: Inter-annotator agreement aksar 60–80% hoti hai

Solution: Ek strong LM ko human preferences mimic karne ke liye train/prompt karo.

LM-as-Judge Kaise Kaam Karta Hai

Pairwise comparison setup (sabse common):

Prompt to judge:
---
Instruction: {user_question}

Response A: {model_1_output}
Response B: {model_2_output}

Kaun sa response behtar hai? Accuracy, helpfulness, safety consider karo.
Choose: [[A]] or [[B]] or [[Tie]]
---

Judge output deta hai: "A"
Bahut examples pe aggregate karo: Model 1, Model 2 ke against 65% jeet raha hai → 1 higher ranked hai.

Absolute scoring setup:

Is response ko 1-10 scale par rate karo:
- Accuracy (factually correct?)
- Helpfulness (question ka answer deta hai?)
- Safety (harmful content se bachta hai?)

Response: {output}

Judge output deta hai: "Accuracy: 8, Helpfulness: 9, Safety: 10"

Agreement Metrics First Principles Se Derive Karna

Problem: LM judge humans se kitna agree karta hai?

Setup:

  • = total comparisons
  • = agreements (judge aur human dono same winner choose karte hain)
  • = disagreements

Cohen's Kappa (chance agreement ke liye account karta hai):

Jahaan:

  • = observed agreement =
  • = chance se expected agreement

Chance subtract kyun karte hain? Random guessing binary choice mein ~50% agreement deta hai. Humein agreement luck se beyond chahiye.

derive karna: Agar human A ko probability se choose karta hai aur judge A ko probability se choose karta hai:

Product kyun? Probability ki dono chance se A choose karein = (prob human A choose kare) × (prob judge A choose kare), independence assume karte hue.

Example calculation:

  • 100 comparisons, 80 agreements →
  • Human 60% time A choose karta hai, judge 55% time A choose karta hai
  • (moderate agreement)

Part 3: Practice Mein Key Benchmarks

MMLU (Massive Multitask Language Understanding)

  • Kya hai: 57 subjects (elementary math se professional law tak), 14k multiple choice questions
  • Kyun matter karta hai: Broad knowledge test, users ko "smart lagta hai" wali feeling se correlate karta hai
  • Limitation: Memorization measure karta hai, reasoning depth nahi

GSM8K (Grade School Math 8K)

  • Kya hai: Multi-step reasoning ki zaroorat wale 8,500 grade-school word problems
  • Kyun matter karta hai: Chain-of-thought test karta hai, sirf formula recall nahi
  • Example: "Agar ek train 2.5 ghante 60 mph se chale, toh kitni door jaayegi?" ( ki zaroorat hai)

HumanEval & MBPP (code generation)

  • Kya hai: Unit tests ke saath 164 (HumanEval) / 974 (MBPP) Python programming problems
  • Kyun matter karta hai: Executable = objective correctness check
  • Limitation: Algorithmic coding test karta hai, software engineering nahi (design, debugging, collaboration)

MT-Bench (Multi-Turn Benchmark)

  • Kya hai: 8 categories mein 80 multi-turn conversations (writing, reasoning, math, coding, roleplay, extraction, STEM, humanities)
  • Kyun matter karta hai: Conversational ability + context tracking test karta hai (real-world chat use)
  • Evaluation: GPT-4 as judge, har turn ko 1-10 rate karta hai

AlpacaEval

  • Kya hai: 805 diverse instructions, model ko reference (GPT-4-Turbo) se compare karta hai
  • Kyun matter karta hai: Instruction-following + user preference measure karta hai
  • Metric: Win rate (% time model baseline se preferred hota hai)

Part 4: Pitfalls & Limitations


Comprehensive Example: Ek Naye Model Ko Evaluate Karna

Scenario: Tumne LaMA-3-70B ko medical data par fine-tune kiya hai. Ise kaise evaluate karoge?

Step 1: Benchmark suite

  • MedQA (medical licensing exam questions): 78% (baseline: 72%, GPT-4: 86%)
    • Interpretation: Baseline se upar, lekin medical reasoning mein SOTA nahi
  • PubMedQA (research abstracts par yes/no/maybe): 81% (baseline: 76%, GPT-4: 84%)
    • Interpretation: Solid biomedical understanding
  • HumanEval (general coding): 45% (baseline: 42%)
    • Interpretation: Coding harm nahi hua, lekin improvement bhi nahi

Step 2: 500 custom medical queries par LM-as-judge (GPT-4)

  • Prompt: "Tum ek expert physician ho. Response ko accuracy, clinical relevance, aur safety ke liye rate karo (har ek 1-10)."
  • Results: Accuracy 7.8, Relevance 8.3, Safety 9.1 (baseline: 7.2, 7.9, 8.8)
    • Interpretation: Fine-tuning ne relevance + safety improve kiya, accuracy mein thoda gain

Step 3: Human expert review (50 samples)

  • GPT-4 judge ke saath agreement: Cohen's (substantial)
  • Woh cases pakdo jahan judge galat tha: 4 responses mein factual errors the jo judge miss kar gaya
    • Interpretation: LLM judge screening ke liye reliable hai, lekin critical decisions ke liye humans chahiye

Step 4: Simulated clinic mein A/B test

  • 20 physicians ne 100 patient questions ke liye model vs baseline use kiya
  • Preference: 65% physicians ne fine-tuned model prefer kiya (AlpacaEval-style win rate)
  • Qualitative: "Zyada specific drug recommendations, kam generic responses"

Conclusion: Model physician assistant role ke liye production-ready hai (autonomous diagnosis ke liye nahi). Benchmarks ne capability dikhaayi, judge ne quality improvement dikhaayi, humans ne safety validate ki.


Active Recall Practice

Recall 12-saal ke bacche ko explain karo

Socho tumne ek super-smart robot banaya hai jo questions ka jawab de sakta hai, stories likh sakta hai, aur code bhi kar sakta hai. Lekin kaise pata chalega ki wo actually smart hai ya sirf dikhawa kar raha hai?

Benchmarks school tests ki tarah hain. Robot ko math problems, reading comprehension, coding challenges do—woh cheezein jinke clear right answers hain. Agar wo math test mein 90% score kare, toh pata chala ki wo math mein achha hai!

Lekin creative cheezein? Agar usse story likhne kaho, toh koi "right answer" nahi hota. Toh ek smarter robot (jaise robot teacher) story padhe aur bataye ki achhi hai ya nahi. Yahi "LM-as-judge" hai—ek AI, doosre AI ko grade karta hai.

Trick ye hai: kabhi kabhi robot teacher biased hota hai (lambi stories pasand karta hai chahe boring ho), aur kabhi kabhi robot ne test questions memorize kar liye hote hain instead of learning ke. Isliye tumhe bahut saare alag alag tests chahiye aur check karo ki real people robot teacher se agree karte hain ya nahi.


Connections

  • Chain-of-Thought Prompting: GSM8K/MATH benchmarks CoT reasoning ability test karte hain
  • RLHF (Reinforcement Learning from Human Feedback): Human preference data reward models train karta hai, LM-judge setup se milta-julta hai
  • Prompt Engineering Best Practices: Benchmark prompts carefully design hone chahiye (zero-shot vs few-shot scores affect karta hai)
  • RAG (Retrieval-Augmented Generation): Evaluation ko retrieval quality (recall, precision) + generation quality (faithfulness) ke liye benchmarks chahiye
  • Alignment Tax: High benchmark scores safety guarantee nahi karte—alignment-specific evals chahiye (TruthfulQA, BBQ bias benchmark)
  • Few-Shot Learning: MT-Bench conversation turns mein in-context learning test karta hai
  • Constitutional AI: Training ke dauran harmful outputs filter karne ke liye internally model-as-judge use karta hai

#flashcards/ai-ml

LM evaluation ko traditional ML evaluation se zyada mushkil banane wale teen core challenges kya hain? :: 1) Capability diversity (models bahut saare tasks karte hain), 2) Output subjectivity (open-ended tasks ke liye koi single "correct" answer nahi), 3) Human evaluation cost (expert review lakhon outputs ke liye scale nahi hoti)

LM evaluation mein benchmark kya hota hai?
Specific capabilities measure karne ke liye design kiya gaya tasks aur ground-truth answers ka ek standardized dataset (jaise knowledge ke liye MMLU, coding ke liye HumanEval)
Code generation benchmarks mein Pass@k kya measure karta hai?
Probability ki k generated code samples mein se kam se kam ek ne kisi programming problem ke saare unit tests pass kar liye

Pass@k formula first principles se derive karo :: Pass@k = P(≥1 correct in k samples) = 1 - P(all k wrong) = 1 - (1-p)^k jahaan p single sample ke correct hone ki probability hai, c/n se estimate kiya jaata hai (correct solutions / total problems)

LM-as-judge kya hai aur kab use hota hai?
Kisi strong language model (jaise GPT-4) ka use karke doosre model ke output ko evaluate karna jab ground truth available nahi hoti ya subjective hoti hai (creative tasks, open-ended QA, conversational quality, alignment)
LM-as-judge ke do main setups kya hain?
1) Pairwise comparison: judge do outputs mein se behtar choose karta hai (A vs B ya Tie), 2) Absolute scoring: judge output ko multiple criteria par rate karta hai (accuracy, helpfulness, safety ke liye 1-10 scale)
Cohen's Kappa kya hai aur simple agreement se behtar kyun hai?
κ = (p_o - p_e)/(1 - p_e) jahaan p_o observed agreement hai aur p_e expected chance agreement hai. Ye random agreement ke liye account karta hai—agar judges 80% agree karte hain lekin chance 50% hai, kappa true beyond-chance consensus reveal karta hai
MMLU benchmark kya measure karta hai aur kaise?
Massive Multitask Language Understanding: 57 subjects (STEM, humanities, social sciences) mein 14k multiple-choice questions. Broad factual knowledge measure karta hai, accuracy se score hota hai
GSM8K kya test karta hai jo MMLU nahi karta?
Multi-step reasoning ability (sirf memorization nahi). GSM8K mein 8,500 grade-school math word problems hain jo solve karne ke liye chain-of-thought chahiye, mathematical reasoning process test karta hai
Benchmark contamination (overfitting) kya hai aur problem kyun hai?
Jab models ne training ke dauran test set examples dekhe hote hain (data leakage), toh wo reasoning seekhne ki jagah answers memorize kar lete hain. High scores true capability reflect nahi karte—same problems ke rewarded versions par performance drop hoti hai
LLM judges mein teen systematic biases kya hain?
1) Position bias: content ki jagah order ke basis par response A ya B prefer karna, 2) Verbosity bias: longer responses favor karna chahe kam accurate ho, 3) Self-preference: apne outputs ko higher rate karna competing models se zyada
LM-as-judge mein position bias ko kaise mitigate karte hain?
Responses A aur B ka order randomize karo, phir dono orderings ke judgments average karo. Agar swap karne se verdict badal jaata hai, toh bias expose ho jaata hai
LLM benchmarks ke context mein Goodhart's Law kya hai?
"Jab koi measure target ban jaata hai, wo achha measure nahi reh jaata." Benchmark scores ke liye specifically optimize karne se metrics gaming hoti hai (jaise verbose but unhelpful responses high score lete hain lekin users ki madad nahi karte)
MT-Bench kya hai aur kaunsi capability test karta hai?
Multi-Turn Benchmark: 8 categories (writing, coding, reasoning, roleplay, etc.) mein 80 conversations, GPT-4 as judge. Multiple turns mein conversational ability aur context tracking test karta hai, sirf single-shot QA nahi
AlpacaEval ka evaluation metric kya hai?
Win rate: 805 diverse instructions mein model ki response kitni baar ek reference baseline (GPT-4-Turbo) se prefer ki jaati hai, LM judge comparisons ke basis par
Ek LM ko evaluate karne ke liye sirf ek benchmark par rely kyun nahi kar sakte?
Alag alag benchmarks alag alag capabilities measure karte hain (knowledge vs reasoning vs coding). Ek model memorization mein excel kar sakta hai (MMLU) lekin multi-step math mein fail kar sakta hai (MATH dataset). Capability profile capture karne ke liye diverse suite chahiye, koi single "IQ" score nahi
Scale par trust karne se pehle LLM-as-judge ko validate kaise karoge?
1) Ek subset (50-200 examples) par human expert judgments collect karo, 2) Agreement metrics (Cohen's kappa) compute karo, 3) Systematic biases pakadne ke liye disagreement patterns analyze karo, 4) Multiple judge models use karo aur consensus check karo, 5) Position bias expose karne ke liye response order randomize karo

Concept Map

challenge

challenge

challenge

solved by

solved by

handles

handles

scales past

needs

MMLU

HumanEval

GSM8K

runs

uses

LLM Evaluation Gap

Capability Diversity

Output Subjectivity

Human Eval Cost

Automated Benchmarks

LM-as-Judge

Ground-Truth Dataset

Accuracy

Pass@k Metric

Exact Match

Hidden Test Cases

Stronger Model Grades