agenttables

.com xAI Data Engineer take-home · sample + real-shard results
xAI Data Engineer take-home — sample + real-shard results

agenttables.com

This site is the visual companion to the submitted zip (pipeline.py · requirements.txt · README.md · ARCHITECTURE.md) — every diagram and number below traces to those files or to a real measured run of the code in them.

A data-cleaning pipeline for an LLM-pretraining corpus, built and verified against the provided 100MB / 55,336-row sample (sampled_parqeut.parquet), then run end-to-end against the provided full corpus shard (part.9.parquet, 2.16GB, 1,162,062 rows → 980,341 retained, 17.2 min — see the validation page for the full measured results and the two real failures that run surfaced and fixed). Offline, CPU-bound — pandas/pyarrow for vectorized filtering, datasketch for MinHash+LSH near-dedup, tiktoken for real token counting — schema validation → quality filters → composite quality score → exact + near-duplicate dedup → sharded parquet output.

Pipeline architecture

Every node below is a real function in pipeline.py — nothing invented for this diagram, including compute_quality_score (new) and the datasketch-backed near_dedup_lsh. Violet border = parallelized across --workers processes; amber border = single-process by design.

discover_ input_files per-shard, parallel across --workers (ProcessPoolExecutor) validate_ schema drop_null_ or_empty compute_ signals +tiktoken apply_quality_ filters (×11) compute_ quality_ score exact_dedup sort by filename determinism guard pd.concat all shards near_dedup_lsh (datasketch) signature computation: parallel LSH index + union-find: single-process write_output sharded parquet, zstd
55,336 rows / 100MB 3,536 exact dups dropped 11 quality filters 3.4× near-dedup speedup

What those numbers mean, and what we did about each one:

What's in the sample

5,718 rows (10.3%) belong to a duplicate group; keeping one copy per group means 3,536 rows (6.4%) are actually dropped — the largest confirmed contamination source. Heavy line repetition, digit-dense tables, extreme punctuation: checked for directly, not present here — thresholds stayed generous rather than tuned against evidence that doesn't exist.

11 independent quality filters

Length, language_score (r = -0.28 with punctuation density — a real signal, not just language-ID), alpha/digit/punct-fraction bounds, mean-word-length, line-repetition — each threshold justified against real sample percentiles. A full correlation matrix shows alpha/digit/punct fractions are strongly inter-correlated (not fully independent checks).

Dedup: library-based, not hand-rolled

SHA-256 exact hash (O(n)), then datasketch MinHash+LSH (64 hashes/16 bands, Jaccard ≥0.8) for near-duplicates — replacing an earlier hand-rolled implementation. Near-dup count changed 138→388 (different hash function, same correct algorithm) — reproducibility and cross-chunk correctness re-verified against the new implementation directly.

Real tiktoken counts + a composite ranking score

token_count (real tiktoken cl100k_base, not a char/4 proxy) and quality_score (weighted composite of language_score/alpha_fraction/ unique_line_fraction, ranks within the already-filtered set) are both new output columns — answering the take-home's "top-10B-token cut" ordering question with real, computed signals.

Data shape

A real profile of sampled_parqeut.parquet, computed by a typed (Pydantic-validated) profiler against the actual file — row/column counts, per-column null rates, numeric percentiles, categorical breakdowns. Every number below is copied verbatim from that run's JSON output, never hand-typed.

sampled_parqeut.parquet 55,336 rows × 4 columns · 103,454,104 bytes (~98.7 MB) doc_id text · 0% null text text · 0% null language categorical · 0% null language_score numeric · 0% null language — categorical breakdown (1 distinct value) en — 55,336 / 55,336 (100.0%) language_score — numeric range (real percentiles, not estimated) min 0.235 p25 0.921 median 0.945 p75 0.961 max 0.999

Warehouse: fact_/dim_ tables for this pipeline

A Kimball star schema modeling the pipeline's own run metrics — one run-grain fact plus two child facts (run × filter reason, run × pipeline stage), each joined to its own dimension, with cube-style semantics declared alongside the DDL. Seeded from a fresh, reproduced pipeline run (not README prose) — every drop count reconciles exactly against total_before − total_after, and NULL means "not individually measured," never fabricated.

data/warehouse_corpus_pipeline/ — real Kimball star schema solid border (accent color) = fact table · amber border = dimension · seeded only from real README.md/pipeline.py numbers, NULL where undocumented fact_pipeline_run run_id (PK)total_before = 55,336total_after = 50,944elapsed_seconds = 37.6n_workers = 1source_ref, loaded_at fact_filter_drop run_id, reason_id (PK)dropped_count exact_duplicate = 3,536 near_duplicate = 388 all 14 reasons measured fact_stage_timing run_id, stage_id (PK)elapsed_seconds compute_signals = 15.31 near_dedup_lsh = 21.94 9 stages, 7 measured dim_filter_reason reason_id (PK)labelstage (CHECK enum)threshold_desc14 rows total dim_pipeline_stage stage_id (PK)function_namesequence_nois_per_file9 rows total

Data quality issues, with real example rows

One real row per filter, snippets short and truncated — this corpus is unvetted, CommonCrawl-style scraped web content, so each diagram leads with the computed statistic that triggered the filter rather than the document text.

Exact duplicate — SHA-256 hash match filter: exact_dedup Two real rows, byte-identical text (confirmed via SHA-256 content hash) — one is dropped, keep-first. urn:uuid:67071862-e24e-4a53-8d70-4aba731c78db “"Artificial Intelligence and Its Implications for Income…” 862 chars, sha256 match KEPT (first) urn:uuid:8032dfc2-b48f-47fd-8a31-d59bd1c3aa00 “"Artificial Intelligence and Its Implications for Income…” 862 chars, sha256 match DROPPED
Two byte-identical rows (SHA-256 match) — first kept, second dropped.
Too short — below the char-length floor filter: too_short_chars (char_len < 200) A real row under the 200-char threshold — not enough content to justify a training slot. urn:uuid:d9da71ce-9c7f-459e-ada5-8c4cb7624f12 “{"question": "Chemiosmosis occurs in…” 188 chars (threshold: 200) DROPPED
188 chars, under the 200-char floor — not enough content to justify a training slot.
Low language_score — real outlier, not noise filter: low_language_score (language_score < 0.65) language_score 0.235 — well below the sample's mean of 0.930, in the confirmed-real low tail. urn:uuid:cd5e38ba-76e2-496c-b481-a67cb9d977b1 “{"question": "Freud’s notion of the ‘ego’ referred to:"…” language_score: 0.235 DROPPED
language_score 0.235 vs. sample mean 0.930 — a real outlier, not noise.
Repetitive lines — boilerplate contamination filter: repetitive_lines (unique_line_fraction < 0.30) unique_line_fraction 0.008 — a real example of the internal line-repetition signal firing (rare in this sample: 99.7% of docs had zero repeated lines). urn:uuid:e7b0ca5b-8e66-4e97-956d-e93aeef7dded “"Subscribe to our newsletter for the latest updates…” unique_line_fraction: 0.008 DROPPED
unique_line_fraction 0.008 — boilerplate contamination (rare: 99.7% of docs had none).
A document that passes every filter filter: no filter triggered For contrast: a real row well inside every threshold — this is what "clean" looks like in this sample. urn:uuid:525941c9-1f46-49e5-8740-547760d51a64 “In January, I began a journey of exploration…” 2,138 chars, language_score: 0.989 KEPT
For contrast: a row well inside every threshold — this is what "clean" looks like here.

Next

Run: a real 2.16GB corpus shard (2026-07-09). Still open: the full 40GB.

Stages 1–2 of the staged plan have now executed against real corpus data: 1,162,062 → 980,341 rows (84.4% retained) in 17.2 minutes, surfacing two real failures the sample never could (a worker OOM on whole-shard reads, and a 1-in-1.16M document whose literal <|endoftext|> text crashed the tokenizer) — both fixed and verified. The README's required full-40GB runtime estimate is now grounded: 45–60 minutes on the stated 64-core/256GB machine, an 18.5× extrapolation from the real measurement. The full-corpus run itself is performed on xAI's infrastructure post-submission, per the assessment — see the validation page for the measured results.