home
diamond Go Premium
Data Engineering Path  ·  Data & AI

Evaluating Fine-Tuned Models

+-----------------------------------------------------------------------------+
|                      EVALUATION PYRAMID FOR FINE-TUNING                     |
+-----------------------------------------------------------------------------+
|  Level 3: Human Domain Expert Review (Ground Truth)                        |
|  Level 2: LLM-as-a-Judge (GPT-4o evaluating alignment & compliance)        |
|  Level 1: Deterministic Benchmarks (Exact Match, Code Execution, SQL Lint) |
|  Level 0: Training Loss & Perplexity (Basic sanity check)                  |
+-----------------------------------------------------------------------------+

Why Loss Curves Lie

A declining training loss curve only proves the model is memorizing token transitions in your dataset. It does not prove the model has generalized:

  • If training loss drops to near zero while validation loss spikes, the model is overfitting.
  • A model with low cross-entropy loss may still output hallucinated table names or invalid syntax.

Automated Evaluation with LLM-as-a-Judge

Using a frontier model (like GPT-4o or Claude 3.5 Sonnet) with a structured grading rubric is the industry standard for scalable evaluation:

from pydantic import BaseModel, Field
from openai import OpenAI

class EvaluationVerdict(BaseModel):
    syntax_correctness_score: int = Field(ge=1, le=5)
    business_logic_score: int = Field(ge=1, le=5)
    explanation: str
    is_safe_to_deploy: bool

def grade_generated_pyspark(prompt: str, ground_truth: str, candidate_output: str) -> EvaluationVerdict:
    client = OpenAI()
    rubric = f"""
You are an expert PySpark evaluator. Grade the candidate model output against the prompt and ground truth.
Scores are 1 (Worst) to 5 (Flawless).

PROMPT:
{prompt}

GROUND TRUTH:
{ground_truth}

CANDIDATE OUTPUT:
{candidate_output}
"""
    res = client.beta.chat.completions.parse(
        model="gpt-4o",
        response_format=EvaluationVerdict,
        messages=[{"role": "user", "content": rubric}]
    )
    return res.choices[0].message.parsed
Find this content helpful? ☕ Buy me a coffee

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.