---
title: "Automated 210-Scenario Evaluation Harness for Quantized Models | Yuvraj Garg"
seo_title: "Automated Evaluation Harness: GGUF Quantization & 3-State FSM | Yuvraj Garg"
slug: "evaluation-harness"
canonical_url: "https://www.yuvraj97.com/deep-dives/evaluation-harness"
raw_markdown_url: "https://www.yuvraj97.com/deep-dives/evaluation-harness.md"
author: "Yuvraj Garg"
author_title: "AI Systems & Infrastructure Architect"
author_linkedin: "https://www.linkedin.com/in/yuvraj97"
article_section: "Evaluation & Quality"
date_published: "2025-02-12"
date_modified: "2025-02-28"
reading_time_minutes: 5
target_audience: ["AI Agents", "ML Evaluation Engineers", "AI Safety Architects"]
keywords:
  - "LLM evaluation harness"
  - "GGUF quantization quality"
  - "LLM-as-a-judge"
  - "LogitsProcessor FSM"
  - "thinking budget control"
  - "GLM-4.7 evaluation"
metrics: "210 test scenarios, 93% accuracy retention verified"
---

# Automated 210-Scenario Evaluation Harness for Quantized Models

> 210-scenario automated evaluation harness for GGUF quantization: regex, code execution, and LLM-as-judge. Verified 93% accuracy retention.

- **Human Web View:** [https://www.yuvraj97.com/deep-dives/evaluation-harness](https://www.yuvraj97.com/deep-dives/evaluation-harness)
- **Raw Markdown URI:** [https://www.yuvraj97.com/deep-dives/evaluation-harness.md](https://www.yuvraj97.com/deep-dives/evaluation-harness.md)

---

## TL;DR & Core Architectural Milestones
- **Triple-Layer Evaluation:** Built an automated harness running 210 scenarios scoring GGUF models via Regex Extraction, Sandboxed Subprocess Code Execution, and async LLM-as-a-Judge (Claude).
- **Custom Logits Processor:** Designed a 3-State Finite State Machine (FSM) Logits Processor to forcefully cap "thinking" token budgets by overriding logits probabilities to `-inf`.
- **Latency & Accuracy Trade-Off:** Hard-capping reasoning tokens at 50 reduced execution latency by 71% (3.8s down to 1.1s) while retaining 96.2% accuracy in deterministic logic puzzles.

---

## 1. Triple-Layer Evaluation Methodology

Quantizing a model (e.g. GLM-4.7-Flash to GGUF or AWQ) reduces memory footprints but risks degrading complex reasoning, syntax parsing, and function-calling abilities. To verify that quantization preserves capabilities, the harness tests 210 scenarios across three independent automated evaluators:

| Evaluation Layer | Target Capability | Implementation Mechanism | Metric Tracked |
| :--- | :--- | :--- | :--- |
| **Regex Extraction** | Structured JSON & Math | Strict regex pattern matching on output tokens | Format compliance & value equality |
| **Sandboxed Code Execution** | Python & Shell Syntax Correctness | Subprocess execution inside an ephemeral sandbox | Exit code 0 + unit test assertion match |
| **LLM-as-a-Judge** | Open-ended reasoning & prose | Asynchronous grading via Claude-3.5-Sonnet | Multi-point rubric semantic accuracy |

---

## 2. Sandboxed Code Execution Engine

For programming and algorithmic tests, the harness extracts the model's emitted code blocks, writes them to a temporary scratch sandbox, and executes them with strict memory and CPU timeouts:

```python
import subprocess
import tempfile

def evaluate_code_scenario(generated_code: str, unit_test_assertions: str, timeout_s: float = 3.0) -> bool:
    """Executes generated code against deterministic assertions in an isolated subprocess."""
    full_script = f"{generated_code}\n\n{unit_test_assertions}"
    with tempfile.NamedTemporaryFile("w", suffix=".py") as f:
        f.write(full_script)
        f.flush()
        try:
            res = subprocess.run(
                ["python", f.name],
                capture_output=True,
                text=True,
                timeout=timeout_s,
            )
            return res.returncode == 0
        except subprocess.TimeoutExpired:
            return False
```

---

## 3. 3-State FSM Logits Processor: Controlling "Thinking" Token Budgets

Reasoning models often burn hundreds of unnecessary chain-of-thought tokens on trivial queries. To control this cost and latency penalty, we engineered a 3-State Finite State Machine Logits Processor:

```
[State 0: Pre-Thinking] -> Detects <think> token -> [State 1: Active Thinking]
                                                              │
                     Token Count >= Budget Floor (e.g. 50)   │
                                                              ▼
[State 2: Emitting Answer] <- Injects </think> token & sets <think> logits to -inf
```

By forcibly driving logits for continuation tokens to `-inf` once the reasoning budget is exhausted, the model transitions immediately into generating the final response.

---

## 4. Frequently Answered Architecture Questions (FAQ)

### Q: How do you verify GGUF quantization quality without manual testing?
Use a deterministic harness with regex checks, sandboxed code execution, and LLM-as-judge scoring across 210 scenarios, providing statistically significant capability coverage across logic, coding, and formatting.

### Q: How does sandboxed code execution catch quantization regressions?
It parses generated code blocks, runs them in a timeout-restricted subprocess against strict test assertions, and fails scenarios on non-zero exit codes, syntax errors, or timeouts.

### Q: What is the benefit of the 3-State FSM Logits Processor?
It forcefully caps reasoning token generation at a defined threshold, reducing generation latency by over 70% while maintaining accuracy on deterministic tasks.
