When comparing AI-generated articles, it's easy to prefer whichever output sounds more polished. Unfortunately, fluency is a poor proxy for factual accuracy, instruction adherence and completeness.
While working on a comparison of Jasper alternatives, I started considering how developers and content teams could evaluate writing systems more systematically.
In this tutorial, we'll build a small, provider-independent Python evaluation framework that checks generated drafts against a defined content specification.
The goal isn't to replace human reviewers. It's to make evaluations more consistent and catch predictable problems before editorial review.
Our evaluation framework will check:
We'll use Python 3.10+ and only standard library modules.
Start by describing what an acceptable article should contain.
from dataclasses import dataclass
@dataclass
class ArticleSpec:
required_sections: list[str]
required_sources: list[str]
min_words: int
max_words: int
spec = ArticleSpec(
required_sections=[
"Overview",
"Limitations",
"Implementation"
],
required_sources=[
"https://example.com/documentation"
],
min_words=100,
max_words=1000
)
The specification is deliberately independent of the AI model or writing platform.
This means multiple systems can be evaluated against the same requirements.
The example URL is a placeholder. Replace it with an actual approved source before evaluating real articles.
We can use regular expressions to identify Markdown headings and simple string checks to identify required references.
import re
def evaluate_article(article, spec):
headings = {
h.strip().casefold()
for h in re.findall(
r"^#{1,6}\s+(.+)$",
article,
flags=re.MULTILINE
)
}
word_count = len(article.split())
checks = {
"section_coverage": all(
section.casefold() in headings
for section in spec.required_sections
),
"source_presence": all(
source in article
for source in spec.required_sources
),
"word_limit": (
spec.min_words <= word_count
<= spec.max_words
),
"no_unresolved_markers": (
"[SOURCE NEEDED]" not in article
)
}
return {
"checks": checks,
"word_count": word_count,
"passed": all(checks.values())
}
These checks are intentionally limited.
The presence of a source URL doesn't establish whether the source supports a claim. Likewise, the absence of an unresolved marker doesn't establish factual accuracy.
We're testing structural compliance, not truthfulness.
Save generated drafts as Markdown files using the same content brief and source material.
drafts/
system_a.md
system_b.md
system_c.md
We can then evaluate every draft using the same specification.
from pathlib import Path
results = []
for path in sorted(Path("drafts").glob("*.md")):
article = path.read_text(encoding="utf-8")
evaluation = evaluate_article(article, spec)
results.append({
"system": path.stem,
**evaluation
})
for result in results:
print(result)
This works regardless of whether the drafts came from an API, a commercial writing platform or a locally hosted model.
For meaningful comparisons, keep the task instructions, source documents and editorial requirements consistent.
Some of the most important writing characteristics cannot be reliably assessed through simple automated rules.
We can create a separate human evaluation rubric.
@dataclass
class HumanReview:
accuracy: int
relevance: int
originality: int
clarity: int
editing_minutes: int
def __post_init__(self):
scores = [
self.accuracy,
self.relevance,
self.originality,
self.clarity
]
if any(not 1 <= score <= 5
for score in scores):
raise ValueError("Scores must be 1–5")
if self.editing_minutes < 0:
raise ValueError("Invalid editing time")
def quality_score(self):
return (
self.accuracy
+ self.relevance
+ self.originality
+ self.clarity
) / 4
Reviewers can score each dimension from one to five.
Where possible, remove product names from the drafts before reviewing them. This reduces the influence of existing preferences about particular software providers.
Editing time should be recorded separately rather than treated as a direct measure of writing quality.
A useful evaluation framework should detect deliberately incomplete articles.
import unittest
class EvaluationTests(unittest.TestCase):
def test_missing_section(self):
article = "## Overview\nExample text."
result = evaluate_article(article, spec)
self.assertFalse(
result["checks"]["section_coverage"]
)
def test_unresolved_claim(self):
article = "Example claim [SOURCE NEEDED]"
result = evaluate_article(article, spec)
self.assertFalse(
result["checks"]["no_unresolved_markers"]
)
def test_missing_source(self):
article = "An article without references."
result = evaluate_article(article, spec)
self.assertFalse(
result["checks"]["source_presence"]
)
if __name__ == "__main__":
unittest.main()
Run the tests whenever you change the evaluation rules.
You can extend the suite with passing examples, malformed Markdown and boundary cases involving word counts.
Evaluating one generated article tells you relatively little about the reliability of an AI writing system.
A better evaluation dataset might include:
Repeat each assignment several times where practical, since generative systems can produce different outputs from identical instructions.
Track the model version, prompt version, generation settings and date of evaluation.
Otherwise, it becomes difficult to reproduce results or identify regressions.
A production content pipeline should include independent source verification.
For example, reviewers can extract factual claims from a draft and classify each one as supported, contradicted or insufficiently supported by the available evidence.
Google's guidance on generative AI content also emphasises reviewing automatically generated information for accuracy before publication.
Structural validation is useful, but it should never be mistaken for a complete editorial quality assessment.
The objective of evaluating an AI writing system shouldn't be to identify whichever tool produces the most convincing prose.
It should be to understand which system reliably helps produce accurate, relevant and useful content for a defined audience.
A combination of deterministic checks, human review and repeatable evaluation datasets provides a more meaningful starting point than subjective first impressions.