Renaissance Labs · Skills

Skills / dataset-quality

Evaluation & Trust

dataset-quality

Evaluate LLM pre-training and post-training datasets (raw text, SFT/chat/CoT, preference/DPO, and RL/verifiable tasks) using multi-signal quality checks — schema integrity, exact and MinHash LSH near-deduplication, Gopher/FineWeb heuristics, zlib information density, lexical and prompt diversity, PII/secret scanning, post-training diagnostics, and optional train/eval contamination checks — producing a transparent 0-100 quality score and JSON receipt.

npx skills add RenaissanceLabs-EU/skills --skill dataset-quality

scripts/dataset_quality.py evaluates local LLM training datasets across pre-training and post-training stages and emits a structured JSON quality receipt (schema_version: 1) plus a Markdown summary. Standard library only (Python 3.9+); supports .jsonl, .ndjson, .json, .csv, .tsv, .txt, .gz variants, directories, and optional .parquet (when pyarrow or duckdb is available).

Run it from this skill's folder:

# Auto-detect dataset type (pretrain, sft, preference, rl) and score it
python3 scripts/dataset_quality.py eval /path/to/dataset.jsonl --out receipt.json

# Evaluate an SFT dataset and check for train/eval contamination
python3 scripts/dataset_quality.py eval train.jsonl --type sft --eval-path eval.jsonl --out sft_receipt.json

# Evaluate a code pre-training corpus (relaxes symbol/prose thresholds)
python3 scripts/dataset_quality.py eval /path/to/code_corpus/ --type pretrain --domain code --max-rows 20000

# Render a Markdown report or compare before/after cleaning receipts
python3 scripts/dataset_quality.py report receipt.json
python3 scripts/dataset_quality.py compare before.json after.json

Supported dataset types

Type (--type)Auto-detected whenExtra checks enabled
pretraintext, content, document, body, or plain .txtStricter min-length (30 words), Gopher/FineWeb heuristics, zlib density, MinHash LSH near-dedup
sftmessages, conversations, instruction/output, prompt/completion, question/answerChat role alternation, refusal rate, AI-slop clichés, truncated fences, <think>...</think> CoT balance
preferencechosen + rejected (or accepted + rejected)Verbosity/length bias (len(chosen) > len(rejected)), identical/near-identical pairs, prefix mismatch, refusal-as-chosen
rlPrompt column + ground_truth, verifier, tests, solution, oracle, or expected_answerEmpty ground truth, answer distribution entropy, verbatim prompt-answer leakage

Scoring dimensions (0–100)

Every dimension starts at 100 and applies documented, capped deductions for each measured defect. The overall quality_score is the weighted sum of active dimensions (A: >= 90, B: >= 80, C: >= 70, D: >= 55, F: < 55).

DimensionPretrain weightSFT / RL weightPreference weightTechniques combined
schema12%15% / 18%15%JSON/row parse errors, missing required fields, UTF-8 mojibake/U+FFFD, null/control bytes, chat role alternation, identical preference pairs
dedup25%18%16%Normalized SHA-256 exact dedup, pure-Python 64-hash MinHash LSH near-dedup (5-shingles), intra-document line/5-gram repetition, duplicate prompts, optional exact + 13-gram train/eval contamination (--eval-path)
heuristics28%17% / 16%15%Gopher/FineWeb rules (min words, mean word length, symbol/word ratio, stopword presence), web boilerplate & raw HTML detection, zlib compression ratio (flags repetitive templates < 0.18 and random/encoded noise > 0.85)
diversity20%15% / 16%14%Moving-Average Type-Token Ratio (MATTR-50), corpus distinct-2 / distinct-3 n-gram diversity, token-length percentiles (p10/p50/p90/p99), top prompt-prefix concentration, Unicode script distribution
safety15%13% / 10%12%Regex + Luhn-validated credit cards, SSNs, emails, phone numbers, IPv4, exposed API/private keys (sk-, ghp_, AKIA, hf_, PEM blocks), unresolved TODO/[INSERT ...] placeholders
posttrain—22%28%Stage-specific diagnostics for SFT/CoT, Preference/DPO, and RL/verifiable tasks

Verdicts & critical flags

  • ready: quality_score >= 80 and critical_flags == 0.
  • needs_cleaning: 60 <= quality_score < 80 and critical_flags == 0.
  • high_risk: quality_score < 60 or critical_flags > 0.

Critical flags are triggered immediately by exposed API/private keys or exact train/eval overlap when --eval-path is supplied.

Useful flags

  • --max-rows N (default 10000, 0 = all): streams large files with deterministic reservoir sampling (--seed 42) so multi-gigabyte corpora can be audited quickly in constant memory.
  • --domain general|code (default general): code relaxes symbol-to-word, HTML, and prose stopword rules.
  • --text-field NAME: explicitly pick the text column for pretrain datasets with custom schemas.
  • --near-dup-threshold 0.80: tune the MinHash LSH Jaccard threshold.
  • --format json|markdown: print raw JSON receipt or Markdown summary to stdout.

Reading scores honestly

  • High score != semantic truth or benchmark gain: this skill measures structural, statistical, deduplication, hygiene, and post-training failure modes locally without running a model. It does not verify factual accuracy, mathematical correctness of CoT traces, code execution, or downstream training lift.
  • Sampling trade-offs: with --max-rows 10000 on a 10M-row corpus, global exact/near-duplicate rates are lower bounds on true corpus-wide duplication. Increase --max-rows or run a dedicated full-corpus dedup pass before large pre-training runs.
  • PII & safety are heuristic: regex + Luhn checks catch common leaks (keys, emails, SSNs, cards) but are not a legal compliance audit or a full toxicity classifier.
  • Domain calibration: non-Latin scripts skip the Latin stopword check automatically, and code corpora should be evaluated with --domain code. Always inspect top_issues and the raw dimensions.*.metrics rather than relying on the headline number alone.