LLM Evaluation: How to Measure the Quality of LLM and RAG Applications
On this page
Short answer: LLM evaluation means systematically measuring whether your LLM application gives correct, useful, safe and affordable answers. The practical approach: (1) build a test set of realistic inputs with expected answers or criteria; (2) choose metrics that match the task: exact match or accuracy for extraction and classification, and correctness, faithfulness and relevance for open-ended answers; (3) for RAG, evaluate retrieval and generation separately; (4) combine automated scoring (including carefully validated LLM-as-judge) with human review; and (5) track cost, latency and safety, re-running the suite whenever you change prompts, models or data.
Key takeaways
- No test set = no evaluation. Start with 30–100 real examples.
- Evaluate retrieval and answers separately in RAG.
- LLM judges are useful but must be checked against humans.
- Treat prompts like code: run regression tests on every change.
Step 1: Build a test set
- Collect real or realistic user questions and inputs
- Include easy, typical and tricky cases (ambiguous, out-of-scope, adversarial)
- Write expected answers, key facts or grading criteria
- Version the dataset and grow it from real failures
Step 2: Choose metrics by task
| Task | Useful metrics |
|---|---|
| Classification / routing | Accuracy, precision, recall, F1 |
| Extraction to JSON | Valid JSON rate, field-level exact match |
| Summarisation | Coverage of key points, factual consistency, length compliance |
| Q&A / chat | Correctness, completeness, helpfulness, tone |
| Code generation | Tests passed, compiles/runs |
Classic ML metric background: how to evaluate a machine learning model.
Step 3: Evaluate RAG in two parts
| Part | Question | Metrics |
|---|---|---|
| Retrieval | Did we fetch the right chunks? | Hit rate, recall@k, MRR |
| Generation | Is the answer correct and grounded? | Faithfulness (supported by context), answer relevance, correctness, citation accuracy |
If retrieval fails, fix chunking, embeddings or search before changing the prompt or model.
Step 4: LLM-as-judge (carefully)
A strong model can grade outputs against a rubric, which scales evaluation cheaply.
You are grading an answer to a student question.
Context: {retrieved_text}
Question: {question}
Answer: {answer}
Score 1-5 for each: correctness, faithfulness to context, completeness.
Return JSON: {"correctness": n, "faithfulness": n, "completeness": n, "reason": "..."}
- Use clear rubrics and ask for structured output
- Compare judge scores with human ratings on a sample before trusting them
- Watch for judge biases (e.g. preferring longer answers)
Step 5: Human review
Have domain experts review a regular sample, especially edge cases and anything customer-facing. Use their feedback to grow the test set.
Step 6: Safety, cost and latency
- Safety: test prompt-injection attempts, harmful requests, privacy leaks and off-topic questions
- Cost: tokens per request and per successful task
- Latency: time to first token and total response time
Step 7: Continuous evaluation
- Run the test suite on every prompt, model or retrieval change
- Log production inputs and outputs (respecting privacy) and sample them for review
- Track metrics over time on a dashboard
- Collect user feedback (thumbs up/down) as an extra signal
Tools
Open-source and commercial tools exist for tracing, datasets and automated scoring, including RAG-specific evaluation libraries. A spreadsheet plus a Python script is enough to start.
Frequently asked questions
Can I evaluate LLMs with BLEU or ROUGE?
They measure word overlap and can help for translation or summarisation, but they often miss correctness and meaning for open-ended answers.
How big should the test set be?
Start with 30–100 representative examples and grow it as you find failures.
How do I evaluate an AI agent?
Measure task success rate, number of steps, tool-call accuracy, cost and safety on a set of realistic tasks. See AI agent frameworks.
Is LLM evaluation asked in interviews?
Yes, increasingly. See RAG interview questions.
Conclusion
LLM evaluation turns “it seems to work” into evidence. Build a test set, measure retrieval and answers separately, validate any LLM judge against humans, track safety, cost and latency, and re-run evaluations with every change.
Learn to build and evaluate LLM apps in our Generative AI App Developer course.
Related reading
Learn with Mehul Prajapati in Borivali West
At Mehul Prajapati’s institute, you get 100% practical, hands-on training by industry experts with a minimum of 5+ years of experience, plus job-oriented programmes with placement support. Weekday and weekend batches are available, with multiple 2-hour slots between 8 am and 6 pm.
Address: 12th Floor, 1214, Gold Crest Business Centre, LT Rd, Above Westside Showroom, Borivali West, Mumbai, Maharashtra 400092
Call: +91 99301 12627 / +91 96645 45072
Visit the centre or call us to choose the right course and batch and to know the current fee structure.