LLM-as-Judge is an evaluation approach where one language model assesses the quality of another model's output. In ReqRev, we use OpenAI's GPT-4 models to evaluate how well our primary model (typically gpt-4o-mini) detects requirement smells.
-
Scalability: Manual expert evaluation is expensive and time-consuming. LLM-as-judge provides scalable automated evaluation.
-
Quality Evaluation: Using a more powerful judge model (e.g., gpt-4o judging gpt-4o-mini) provides critical evaluation perspective.
-
Research Validation: Judge scores can be correlated with human expert evaluations to validate smell detection accuracy.
-
Continuous Improvement: Helps identify patterns in detection errors to improve prompts and fine-tuning.
-
Reliable: Uses OpenAI's API with your paid tier for consistent, rate-limit-free evaluation.
The judge model evaluates the primary model's smell detection on four criteria:
- Accuracy: Are the predicted smells actually present in the requirement?
- Completeness: Are there obvious smells that were missed?
- Precision: Are the smell labels correctly applied (not mislabeled)?
- Explanation Quality: Does the explanation justify the detected smells?
- ❌ Replace the primary model - the judge only evaluates, it doesn't detect smells
- ❌ Provide ground truth - judge output is still AI-generated and should be validated
- ❌ Change extension behavior - browser extension only uses the primary model
# OpenAI API Key (required - used for both primary and judge)
OPENAI_API_KEY=sk-proj-...
# Primary Model Configuration
OPENAI_MODEL=gpt-4o-mini
OPENAI_MAX_TOKENS=1500
OPENAI_TEMPERATURE=0.0 # 0.0 for deterministic detection (recommended)
# Judge Configuration
JUDGE_MODEL=gpt-4o
JUDGE_MAX_TOKENS=1000
JUDGE_TEMPERATURE=0.0 # 0.0 for deterministic evaluation (recommended)
LLM_JUDGE_ENABLED=trueNote: Both models use the same OpenAI API key. The judge model is typically a more powerful model (e.g., gpt-4o) evaluating a faster/cheaper primary model (e.g., gpt-4o-mini).
| Use Case | Primary Model | Judge Model | Reasoning |
|---|---|---|---|
| Production | gpt-4o-mini | gpt-4o | Cost-effective primary, high-quality judge |
| High Quality | gpt-4o | gpt-4o | Same model for consistency |
| Research | gpt-4o-mini | o1 | Fast primary, deep reasoning judge |
| Budget | gpt-4o-mini | gpt-4o-mini | Same model (less independent) |
Recommended Setup:
- Primary model:
gpt-4o-mini(fast, cost-effective for real-time use) - Judge model:
gpt-4o(higher quality for evaluation and research)
curl -X POST http://localhost:8000/api/v1/analyze_requirement_with_judge \
-H "Content-Type: application/json" \
-d '{
"requirement_id": "REQ-1",
"description": "The system should maybe provide some kind of user-friendly authentication."
}'For evaluating multiple requirements:
cd evaluation/
python batch_evaluate.pyThis generates comprehensive statistics and reports in JSON, CSV, and Markdown formats.
See evaluation/README.md for details.
- accept: Smells are accurate and complete (score >= 0.8)
- review: Mostly correct but has minor issues (score 0.5-0.79)
- reject: Significant errors or omissions (score < 0.5)
- 1.0: Perfect detection
- 0.8-0.99: Very good, minor issues
- 0.5-0.79: Acceptable but needs review
- 0.3-0.49: Poor, significant problems
- 0.0-0.29: Completely wrong
Specific, actionable feedback like:
- "Add smell 'X' because..."
- "Remove smell 'Y' - not applicable because..."
Requirement: "The system should maybe provide some kind of user-friendly authentication."
Primary Model: Detected conditional_or_non_assertive_requirement, subjective_language, vague_or_implicit_terms
Judge Evaluation:
{
"verdict": "accept",
"score": 0.90,
"justification": "All three smells correctly identified. Uses weak modal 'should maybe', subjective term 'user-friendly', and vague phrase 'some kind of'.",
"suggested_corrections": []
}Requirement: "The system shall authenticate users using OAuth 2.0 with a maximum response time of 500 milliseconds."
Primary Model: No smells detected
Judge Evaluation:
{
"verdict": "review",
"score": 0.60,
"justification": "Missed two smells: OAuth 2.0 is implementation detail, and response time lacks operational context.",
"suggested_corrections": [
"Add 'design_or_implementation_detail' - specifies OAuth 2.0 technology",
"Add 'non_verifiable_qualifier' - lacks context about load conditions"
]
}Error: "LLM Judge is not available..."
Solution:
- Verify
OPENAI_API_KEYis set in.env - Check
LLM_JUDGE_ENABLED=true - Verify
JUDGE_MODELis set (e.g.,gpt-4o) - Restart API server
If judge consistently gives low scores:
- Review primary model prompt in
openai_client.py - Adjust
OPENAI_TEMPERATURE(lower = more conservative) - Consider fine-tuning the primary model
- Use delays between batch requests (see
batch_evaluate.py) - Check your OpenAI tier limits
- Monitor usage at platform.openai.com
CRITICAL: Set both OPENAI_TEMPERATURE=0.0 and JUDGE_TEMPERATURE=0.0 to ensure:
- ✅ Same requirement → same smells detected (reproducible results)
- ✅ Consistent judge scores across multiple runs
- ✅ Reliable evaluation metrics for prompt engineering
- ✅ No random variation in batch evaluations
Why this matters: Even small temperatures (0.1, 0.2) introduce randomness that causes:
- Different smells detected on identical requirements
- Inconsistent judge verdicts (Accept vs Review)
- Unreliable evaluation metrics
- Difficulty validating prompt improvements
The /analyze_requirement_with_judge endpoint is for:
- ✅ Evaluating prompt quality
- ✅ Validating fine-tuning improvements
- ✅ Research and analysis
NOT for:
- ❌ Real-time browser extension analysis
- ❌ Production requirement checking
Judge scores are AI opinions, not ground truth:
- Correlate with human expert evaluations
- Review "reject" verdicts manually
- Use statistical aggregation for large batches
- gpt-4o: Best balance of quality and speed
- o1: Deep reasoning for complex patterns
- gpt-4-turbo: Fast for large batches
Use judge feedback to improve:
- Analyze
suggested_correctionspatterns - Update system prompts
- Add examples to fine-tuning dataset
- Re-evaluate after changes
Compare judge scores before/after prompt changes to measure improvement.
Measure improvement from fine-tuning by comparing:
- Average judge scores
- Verdict distribution (accept/review/reject)
- Suggested corrections frequency
Compare different models objectively using judge scores as a metric.
- Smell Taxonomy: See TAXONOMY.md - Complete list of 30 smells
- API Documentation: See API.md - API endpoints including judge endpoint
- Architecture: See ARCHITECTURE.md - System design and data flow
- Evaluation Tools: See ../evaluation/README.md - Batch evaluation guide
- OpenAI API: platform.openai.com/docs
- GPT-4 Models: platform.openai.com/docs/models
Last Updated: November 2025
Status: ✅ OpenAI-only (simplified configuration)