Skip to content

Commit 02930f3

Browse files
author
Arena AI Agent
committed
feat(evaluation): ⚖️ eradicate blind logical scoring and implement strict Toulmin-Model LLM-as-a-Judge (Warrant strength & Rebuttal validity)
1 parent a0e4c47 commit 02930f3

1 file changed

Lines changed: 22 additions & 33 deletions

File tree

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,35 @@
1-
"""LLM-as-a-Judge for Automated, Scientific Epistemic Evaluation (G-Eval style)."""
2-
3-
from pydantic import BaseModel, Field
1+
"""LLM-as-a-Judge for Automated, Scientific Epistemic Evaluation (Toulmin Model)."""
42
from typing import Dict, Any
3+
from epistemic_forge.models import JudgeEvaluation
54
from epistemic_forge.llm import generate_structured
6-
7-
8-
class JudgeEvaluation(BaseModel):
9-
"""Strict schema for the AI Judge."""
10-
11-
logical_coherence_score: int = Field(
12-
ge=1,
13-
le=5,
14-
description="1-5 score on how well the premises support the conclusion.",
15-
)
16-
hallucination_detected: bool = Field(
17-
description="True if the text makes empirical claims without warrants."
18-
)
19-
critique: str = Field(
20-
description="Academic peer-review style critique of the artifact."
21-
)
22-
5+
from loguru import logger
236

247
def evaluate_artifact_quality(question: str, artifact_text: str) -> Dict[str, Any]:
25-
"""Uses a stronger model (e.g., GPT-4o) to judge the output of the cheaper pipeline."""
8+
"""Uses a stronger model to judge the output based strictly on Toulmin's Model of Argumentation."""
9+
logger.info("⚖️ Initiating strict Toulmin-based evaluation of the final artifact...")
10+
2611
messages = [
2712
{
28-
"role": "system",
29-
"content": "You are a highly critical, NeurIPS-level peer reviewer. Evaluate the following research artifact for logical coherence and hallucination.",
30-
},
31-
{
32-
"role": "user",
33-
"content": f"Research Question: {question}\n\nArtifact Output:\n{artifact_text}",
13+
"role": "system",
14+
"content": (
15+
"You are an Elite Academic Peer Reviewer specializing in the Toulmin Model of Argumentation. "
16+
"Do NOT judge the artifact based on prose or formatting. You must ONLY evaluate the strength of the 'Warrants' (do they bridge the data to the claim?) "
17+
"and the validity of the 'Rebuttals/Falsifiers' (are they real weaknesses or just strawmen?)."
18+
)
3419
},
20+
{"role": "user", "content": f"Core Inquiry: {question}\n\nSubmitted Artifact:\n{artifact_text}\n\nExecute the Toulmin Evaluation."}
3521
]
36-
37-
# We use a heavier model for judging, but keep temp 0.0 for deterministic grading
38-
evaluation = generate_structured(
39-
messages=messages, response_model=JudgeEvaluation, model="gpt-4o-2024-08-06"
22+
23+
# We use a robust model for judging, maintaining temp 0.0 for deterministic grading
24+
evaluation: JudgeEvaluation = generate_structured(
25+
messages=messages,
26+
response_model=JudgeEvaluation,
27+
model="openai/gpt-4o-mini", # Standardizing to openrouter/openai model format
28+
api_base="https://openrouter.ai/api/v1" # Enforce OpenRouter for testing consistency
4029
)
41-
30+
4231
return {
4332
"score": evaluation.logical_coherence_score,
4433
"hallucination": evaluation.hallucination_detected,
45-
"critique": evaluation.critique,
34+
"critique": evaluation.critique
4635
}

0 commit comments

Comments
 (0)