agentleFS
strikersamstrikersam/autonomous-ai-agency/.agents/skills/data-quality-audit/SKILL.md

data-quality-audit

Skill9 starsChanged 3 months agoMITView on GitHub

"I spent two weeks debugging a model that kept outputting garbled text. The issue was 0.3% of my training data had HTML entities that the tokenizer split into hundreds of tokens, dominating the loss landscape." Key lessons: 1. Token length distribution matters — outlier-length documents dominate gradient updates disproportionately 2. Deduplication is not optional — even 1% duplicate data causes memorization artifacts 3. Tokenizer fertility (chars/token) should be consistent — sudden drops indicate encoding bugs 4. BOS/EOS tokens must be…

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Tokenizer fertility (chars/token): should be consistent — sudden drops indicate encoding bugs

    line 21
  2. Distinctive:

    Every document has BOS token at start

    line 59
  3. Distinctive:

    Every document has EOS token at end

    line 60
  4. Very specific:

    No document contains raw <unk> tokens (tokenizer coverage issue)

    line 61
  5. Distinctive:

    No document contains padding tokens mid-sequence

    line 62

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: data-quality-audit

Purpose

Audit training data and tokenizer pipelines for quality issues that silently degrade LLM training. Data problems are the #1 underdiagnosed cause of poor model performance — most tutorials skip this entirely.

Trigger

Use when:

  • Preparing a dataset for LLM pretraining or fine-tuning
  • Model outputs seem degenerate (repetition, wrong language, truncated responses)
  • Tokenizer was recently changed or vocabulary was updated
  • Merging datasets from multiple sources

Background (Why This Matters)

From LLM-from-scratch practitioners:

"I spent two weeks debugging a model that kept outputting garbled text. The issue was 0.3% of my training data had HTML entities that the tokenizer split into hundreds of tokens, dominating the loss landscape."

Key lessons:

  1. Token length distribution matters — outlier-length documents dominate gradient updates disproportionately
  2. Deduplication is not optional — even 1% duplicate data causes memorization artifacts
  3. Tokenizer fertility (chars/token) should be consistent — sudden drops indicate encoding bugs
  4. BOS/EOS tokens must be consistent — missing end tokens cause the model to never learn to stop
  5. Language distribution — unlabeled multilingual data causes unexpected behavior in monolingual models

Usage

/data-quality-audit [dataset_path_or_glob] [--tokenizer model_name_or_path] [--sample 10000]

Checks Performed

1. Token Length Distribution

P5:   [tokens]
P50:  [tokens]  
P95:  [tokens]
P99:  [tokens]
MAX:  [tokens]  ← flag if >> context_window

WARNING: Documents at P99+ length will be truncated, losing their tail content.
         Consider splitting or filtering documents > 0.8 * context_window.

2. Deduplication Check

  • Exact match on first 64 tokens (cheap, catches near-duplicates)
  • MinHash LSH for near-duplicate detection (sampled)
  • Reports estimated duplicate % in dataset

3. Tokenizer Fertility Check

# chars_per_token should be stable across document types
# English prose: ~4.0 chars/token
# Code: ~3.0-3.5 chars/token
# Sudden drop to <2.0 suggests tokenizer is splitting on noise
fertility = total_chars / total_tokens

4. Special Token Consistency

  • Every document has BOS token at start
  • Every document has EOS token at end
  • No document contains raw <unk> tokens (tokenizer coverage issue)
  • No document contains padding tokens mid-sequence

5. Language Detection (if langdetect available)

  • Reports language distribution
  • Flags documents with mixed-language content
  • Warns if distribution differs from intended training target

6. Content Quality Signals

  • Repetition ratio: flag documents where any 4-gram repeats >5x
  • Average line length: flag documents with lines >500 chars (likely minified/encoded data)
  • Punctuation density: flag documents with <1% punctuation (may be code or structured data)
  • HTML/XML tag density: flag documents with >5% tag content

Output Format

=== Data Quality Audit Report ===
Dataset: [path]
Sampled: [N] documents

[PASS/WARN/FAIL] Token Length Distribution
[PASS/WARN/FAIL] Deduplication
[PASS/WARN/FAIL] Tokenizer Fertility  
[PASS/WARN/FAIL] Special Token Consistency
[PASS/WARN/FAIL] Language Distribution
[PASS/WARN/FAIL] Content Quality

CRITICAL ISSUES: N
WARNINGS: N

Estimated affected documents: [N] ([%] of dataset)

Recommended Actions:
1. Filter documents where token_length > [threshold]
2. Remove [N] near-duplicate clusters
3. [other specific actions]

Common Dataset Issues by Source

SourceCommon IssueFix
Common CrawlHTML artifacts, boilerplatetrafilatura extraction
GitHubMinified JS/CSS, generated filesFilter by file extension
WikipediaCitation markup, table syntaxWikiExtractor preprocessing
BooksGutenberg headers/footersTrim first/last 1000 chars
RedditDeleted/removed comments ([deleted])Filter short or placeholder text
PDFsOCR noise, column merging artifactsQuality score threshold

Integration Points

  • Pairs with dependency-audit for checking data pipeline library versions
  • Pairs with training-stability-monitor when data issues cause training instability
  • Pairs with insights for tracking data quality metrics across dataset versions

Notes

  • This skill is read-only — it analyzes but does not modify data
  • For large datasets (>100GB), always use --sample to get fast estimates
  • Re-run after any tokenizer change — fertility and special token checks are tokenizer-dependent

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.