code-pii / DATA_DICTIONARY.md
josh-hud's picture
Release v3 cross-document coreference dataset
80a02b9 verified
|
Raw History Blame Contribute Delete
30.4 kB

code-pii POC dataset: data dictionary

Version 3 (cross-document coreference; v2 = charset-recalibrated, 40 GB). Span-labeled source code for training detectors of code-related sensitive data (passwords, API keys, tokens, private keys, emails) plus, new in v3, synthetic person identities (names, usernames, their emails) and cross-document entity labels: files are grouped into clusters, the same entity recurs across the files of a cluster under one entity_id, and every entity carries a gold replacement so consistent anonymization can be graded. Not classic PII beyond names/usernames (no addresses/SSNs). Proof of concept; everything is generated by generate_dataset.py and reproducible with --seed. v2 consumers: all v2 fields are unchanged; v3 only adds fields (section 2) and two labels (person_name, username; disable with --no-persons).

1. How the dataset is built

Seed dataset. The only human-labeled input is Samsung/CredData (Apache-2.0): 67,896 candidate lines in 11,565 real GitHub files across 337 repositories, each line marked GroundTruth T (real credential, 15,753), F (looks like a credential but is not, 48,061) or X (ambiguous, 4,082), with a category and, for most T rows, the column range of the secret value. CredData's own pipeline (download_data.py) clones the repos, keeps only files that have at least one labeled line and format-preservingly obfuscates every true secret, so no live credential is ever present. build_priors.py parses the CSVs plus the rebuilt files and extracts priors.json: the label distribution (after collapsing ~200 fine-grained CredData categories into api_key/password/token/private_key, with UUID demoted to a hard negative), the syntactic context of each secret (assignment, JSON key, YAML key, env assignment, comment, URL credential, auth header, function argument, PEM block, derived by regexes over the text preceding the value), the variable-name vocabulary per label (top 40, e.g. password 1,383, key 3,454, sharedsecret 846), value length/charset statistics per label, quote style, file-extension frequencies for both true and false rows, and the number of secrets per file. The same pass emits eval_creddata.jsonl: every labeled CredData line with +-3 lines of context, as real, non-synthetic evaluation data (true positives and the F rows as gold hard negatives).

Base corpus. codeparrot/github-code-clean (880 parquet shards, 30 languages, per-file license column, not gated: the Hub API reports gated: false). Shards are fetched directly over HTTPS so nothing but the shards actually consumed is downloaded. Rows are kept only if license is in {mit, apache-2.0, bsd-2-clause, bsd-3-clause, isc, unlicense, cc0-1.0} (about 63% of rows) and the file is 200 B to 200 KB. Of the dropped rows, GPL/LGPL/AGPL/MPL/EPL account for nearly all.

Injection. For each kept file a coin with --inject-frac (0.75) decides whether anything is injected; 85% of those receive 1-5 secrets (count sampled from CredData's secrets-per-file histogram with the "10+" bucket damped) and 0-3 hard negatives. The rest (~36% of records end up with zero secret spans) are pure negatives. For each secret: a label is drawn from the CredData label distribution (plus a fixed 12% share for email, which CredData does not annotate); a syntactic context is drawn from CredData's per-label context distribution; a variable name from the per-label vocabulary; a value from the generators below. A language table (31 languages + generic fallback) renders the construct in the file's syntax: assignments (const x = "...", String x = "...", #define X "...", ENV X=..., set(X "...")...), dictionary/object keys, .env/shell exports, comments with the language's comment leader, URL credentials (postgres://user:PASS@host/db, span = password only), Authorization: Bearer/Basic headers in the language's HTTP idiom, and PEM blocks as heredocs/template literals/concatenated string literals. The rendered line is inserted at a uniformly random line boundary, indented like the following line. Offsets are computed during assembly and asserted (text[start:end] == value) for every span before writing.

Value generators (v2, charset-calibrated). Values are drawn in two steps: first a target charset class (which of lower/upper/digit/symbol occur in the value) is sampled from CredData's per-label charset distribution (priors.json: charset_by_label), then a generator is chosen proportionally to its base weight times the empirically profiled probability that it produces that class, and rejection-sampled (<=12 tries) until the value matches. This makes the synthetic charset mix track CredData within ~2 points per class (v1 had 25% plain-hex api keys vs 70% real, and <1% pure-lowercase passwords vs 49% real). api_key: AWS access key id (AKIA+16), AWS secret (40 base64), Google (AIza+35), Stripe (sk_live_/sk_test_/rk_live_+24), SendGrid, Twilio, Mailgun, OpenAI, Anthropic, Azure client secret, and generic hex (32-64, lower or upper case), base64 (24-64 raw bytes), alphanumeric, lowercase-only, uppercase/digit, digit-only and dashed-hex keys. Vendor-prefixed formats end up at ~14% of api keys and ~35% of tokens (CredData's own vendor-specific categories are <10% of its true positives; the synthetic share is kept a little higher on purpose so each format is seen tens of thousands of times). token: GitHub classic (ghp_/gho_/ghs_+36) and fine-grained PATs, Slack tokens and webhooks, JWTs (real base64url header.payload.signature), GitLab, npm, Discord, DigitalOcean, Hugging Face, opaque bearer tokens, Basic-auth base64 of user:password, plus generic hex, alphanumeric, dashed-lowercase and uppercase tokens. password: lowercase dictionary words and word pairs (the largest real class), word+digits, word+symbol, Faker strong passwords, capitalised word+digits, digit-only (length distribution follows CredData: median 9, p90 21). private_key: PEM blocks (RSA/EC/DSA/OPENSSH/PKCS8 headers, 64-char base64 lines, realistic lengths). email: Faker free/company/domain emails, never example.*.

Clusters and entities (v3). Before injection every kept file of a base shard is assigned to a cluster: files of the same GitHub repo that happen to be in the same shard form repo clusters (37% of permissive rows sit in a repo with >=2 files in their shard; repos with more than --cluster-cap 8 files are split into near-equal chunks), the remaining files either stay singletons (--singleton-frac 0.35) or are grouped into synthetic bundles of 2-8 unrelated files (size histogram 2:35% 3:25% 4:15% 5:10% 6:7% 7:4% 8:4%; half of the bundles are single-language). Each cluster gets an entity pool seeded from the cluster id: 0-3 synthetic persons (multi-file clusters: 30/40/20/10%; singletons: 70/30% for 0/1) and secrets created lazily. For each secret slot of a file (same count/label/context/name/charset sampling as v2) the generator either repeats an entity already mentioned in that file (--p-repeat 0.15), reuses a pool entity not yet in that file (--p-reuse 0.7, any label: the reused entity's label replaces the drawn one), or creates a new entity; when persons exist a new secret is owned by one of them with --p-owner 0.5, and owned secrets surface the owner's username in constructs that carry a user (scheme://USER:pass@host, login as USER / pass, SQL CREATE USER, and base64 USER:password for basic_auth_b64; owned JWTs carry the owner's full name in the payload, unlabeled). Files in clusters with persons additionally get 0-2 person mentions (65/25/10%): a surface form drawn as full name 40%, username 25%, email 20%, first name 10%, last name 3%, handle 2% (bare first names only when unique in the cluster), rendered as a comment (# Author: Vasana Sur, // TODO(vsur): ..., Copyright (c) 2017 ...), an assignment (author = "...", owner := "vsur") or a JSON/YAML key. Persons are Faker personas (70% en_US, 30% other locales, ASCII-folded) whose username/email derive from the name through one of six templates (jsmith, john.smith, jsmith87, johns, smithj, john_smith; email username@domain or first.last@freemail). Every entity also gets a replacement: a second value of the same format (vendor prefix kept, same length and per-position character class, hex stays hex, PEM keeps header kind and line count, JWT regenerated, passwords/emails redrawn with the same charset class, persons = a fresh persona run through the same templates and domain), unique within the cluster and different from every original. Persons that end up with no mention are dropped from the entity table.

Hard negatives (label not_secret): placeholders (CHANGEME, <YOUR_API_KEY>, AWS's documented AKIAIOSFODNN7EXAMPLE, ghp_xxx..., ********), example.com/test.com/localhost emails, UUIDs, MD5/SHA-1/SHA-256 hex digests, environment-variable references (os.environ["API_KEY"], ${{ secrets.TOKEN }}...), public keys (PEM PUBLIC KEY, ssh-rsa ...), base64 of plain text, version/IP/path/package identifiers and (v3) placeholder names in author-like slots (John Doe, Your Name, admin, nobody; value_type placeholder_name). Negatives are rendered with the same constructs but with names that fit the value (checksum, commit, request_id, public_key, version, ...), except placeholders, example emails and env references, which deliberately use secret-like names (password = "<YOUR_API_KEY>").

Validation. validate.py re-checks offsets on every span, tabulates labels/value types/contexts/languages, runs a gitleaks-style regex scanner for 15 value types (100% of injected spans of those types are found exactly at the labeled offsets, i.e. quoting/escaping/indentation did not mangle them) and, in v3, checks cluster/entity consistency as hard failures: clusters contiguous with doc_index 0..n-1 and the entity table only on doc 0; every entity_id referenced by a span exists in its cluster's table and every table entity has >=1 span; n_mentions/n_docs match; each span's value equals the entity form named by surface_form_type (after PEM escaping) and its replacement equals the corresponding replacement form; the span label matches the entity type; replacements differ from all originals in the cluster, pass the same scanner regex, keep charset class and (for fixed formats) length; owner links resolve to persons; entity ids unique across the run; long random values never recur across clusters; the gold-anonymized text of a document keeps the scanner hits and contains none of the original values. It prints 20 random clusters for eyeballing.

Known limitations and biases. (1) Injected lines are syntactically plausible but semantically disconnected from the surrounding file (a Java constant may land inside a method body, a PEM block inside HTML); a model can learn "line that does not fit" as a cue. (2) Placement is at random line boundaries, not where a human would put config; CredData priors drive what and in which construct, not where in the file. (3) The base corpus is "clean-ish": github-code-clean removed auto-generated files and near-duplicates but was never scrubbed for secrets or PII, so unlabeled real emails, keys or tokens exist in the base text and are implicitly negatives (label noise; eval on eval_creddata.jsonl instead of on synthetic splits). (4) Variable-name vocabulary inherits CredData quirks (e.g. sharedsecret, nonce, salt are frequent because a few repos dominate). (5) generic_hex_key positives and hash negatives are the same character class; they are disambiguated only by the variable name, which is intentional but means a 40-hex value is not labelable in isolation. (6) Scope is secrets + emails only; names, addresses, phone numbers, SSNs are neither injected nor labeled. (7) Language mix mirrors github-code-clean (Java/JS/HTML/PHP/C heavy; little YAML/JSON/.env, which are where CredData sees most real secrets). (8) CredData values in the eval set are obfuscated by CredData's pipeline (format-preserving), not the originals. (9) Charset calibration (v2) matches CredData's per-label charset classes to within ~2 points but not its exact lengths per class or its vendor mix; classes CredData reaches with <1% mass (upper-only keys, digit+symbol) are not generated. (10) v3 person labels cover injected persons only: the base corpus contains many real author names, usernames and emails (license headers, @author, commit tags) that stay unlabeled, so recall on real names is not trained and the negative class is noisier for person_name/username than for secrets. (11) bundle clusters are semantically unrelated files; train coreference on repo clusters only if that matters (filter on cluster_kind). (12) Cross-document recurrence is literal (same string in every file); real repos also reference the same secret through indirection (env var names, config keys), which is not modeled. (13) The real eval set has almost no cross-document recurrence (section 2), so coreference/anonymization must be evaluated on held-out synthetic clusters.

2. Record schema (data/*.parquet, sample.jsonl)

One record per source file. Identical schema in JSONL and Parquet. Records of one cluster are contiguous in one Parquet file, ordered by doc_index; a cluster never spans two files.

field type nullable description
id string no ghcc-<shard:05d>-<sha1(repo/path)[:16]>; unique within the dataset
source string no always codeparrot/github-code-clean
repo string no GitHub owner/name of the base file
license string no base-file license, one of mit, apache-2.0, bsd-3-clause, bsd-2-clause, isc, unlicense, cc0-1.0
language string no github-code-clean language name (30 values, e.g. Python, JavaScript, GO, C#, Shell, Markdown)
path string no path of the file inside its repo
text string no full file content after injection (UTF-8; may be identical to the base file)
spans list no (may be empty) secret spans; empty list = file has no injected secret
hard_negatives list no (may be empty) spans that look like secrets but are labeled not_secret
cluster_id string no v3. c-<shard:05d>-<blake2b(kind:key)[:16]>; key = repo#chunk for repo clusters, the sorted member ids for bundles, the record id for singletons, so ids are stable under re-sharding/subsetting
cluster_kind string no v3. repo (files of one real repo), bundle (synthetic project of unrelated files), singleton
cluster_size int32 no v3. number of records in the cluster (1 for singletons)
doc_index int32 no v3. 0..cluster_size-1, the record's position in the cluster
entities list yes v3. the cluster's entity table, only on the record with doc_index == 0, null on all other records

Span (same struct in both lists):

field type nullable description
start int64 no start offset into text, 0-based, counted in Unicode code points (Python str indexing), not bytes
end int64 no end offset, exclusive: text[start:end] == value
label string no api_key, password, token, private_key, email in spans; always not_secret in hard_negatives
value_type string no fine-grained generator id (tables below)
context string yes (null for hard negatives) syntactic construct the span was rendered in: assignment, json_key, yaml_key, env_assignment, comment, url_credential, auth_header, function_arg, pem_block
synthetic bool no always true in the generated data; false only in eval_creddata.jsonl
value string no the exact surface string (redundant with offsets; convenient for checks and for byte-offset recomputation)
entity_id string yes v3. <cluster_id>/e<idx:03d>; same id = same entity, across all documents of the cluster. Set on every span in spans (singletons too); null in hard_negatives
surface_form_type string yes v3. which form of the entity this span is: literal (secrets, standalone emails), escaped_literal (PEM inside a Java/C/C#/C++ string concatenation: value contains \n" +\n " sequences), or a person form full_name, first_name, last_name, username, handle, email
replacement string yes v3. the gold anonymized surface string for this span (the entity's replacement in the same form and escaping). Replacing text[start:end] by replacement for every span yields the gold anonymized file; null in hard_negatives

Entity (struct embedded in the entities column of each cluster's doc 0 record):

field type nullable description
entity_id string no as above
entity_type string no api_key, password, token, private_key, email, person
value_type string no generator id for secrets (section 3); person for persons
canonical string no the secret literal / email, or the person's full name
forms struct no surface forms; secrets: only literal; persons: full_name, first_name, last_name, username, handle (@username), email. Unused fields are null
replacement_canonical string no replacement value, same format class as canonical
replacement_forms struct no replacement surface forms (same keys as forms; persons: derived with the same username/email templates and domain)
owner_entity_id string yes person entity that owns this secret (set for ~50% of secrets in clusters with persons); null for persons and unowned secrets
n_mentions, n_docs int32 no number of spans / number of documents of the cluster that mention the entity (n_docs >= 2 = cross-document recurrence)

Spans never overlap and are sorted by start. Multi-line spans occur only for private_key and public_key_pem (value contains \n; inside Java/C/C#/C++ string concatenations the value contains literal \n" +\n " sequences, exactly as it appears in text). To convert to UTF-8 byte offsets: len(text[:start].encode()).

Example record (abridged text):

{"id": "ghcc-00001-e57c494c57748745", "source": "codeparrot/github-code-clean",
 "repo": "acme/widgets", "license": "mit", "language": "Python", "path": "app/settings.py",
 "text": "import os\n\nDEBUG = False\nSTRIPE_KEY = 'sk_live_4neiV5Vb5n0oSUNB7MWmlEfQ'\n# login as deploy / Hd7!kq2z\nrequest_id = \"b044a92c-d543-47f6-874a-2ff8411d9576\"\nDATABASE_URL = os.environ['DATABASE_URL']\n",
 "spans": [
  {"start": 39, "end": 71, "label": "api_key", "value_type": "stripe_secret_key", "context": "assignment", "synthetic": true, "value": "sk_live_4neiV5Vb5n0oSUNB7MWmlEfQ"},
  {"start": 93, "end": 101, "label": "password", "value_type": "password", "context": "comment", "synthetic": true, "value": "Hd7!kq2z"}],
 "hard_negatives": [
  {"start": 116, "end": 152, "label": "not_secret", "value_type": "uuid", "context": null, "synthetic": true, "value": "b044a92c-d543-47f6-874a-2ff8411d9576"}]}

eval_creddata.jsonl schema (real data, different fields)

field type description
id string creddata-<repo>-<CredData row Id>
source string Samsung/CredData
path, repo string CredData's anonymized path/repo id (data/<repo>/<scope>/<file>.<ext>)
language_ext string file extension (py, go, yml, json, txt, ...); (none) if absent
line_start, line_end int 1-based line range of the labeled candidate in the original file
ground_truth string CredData label: T real credential, F false positive, X ambiguous
category string CredData's raw category string (e.g. Password, AWS Client ID, Key:Secret)
label string / null collapsed label for T rows (api_key, password, token, private_key, uuid, other); null otherwise
text string the labeled line(s) with 3 lines of context before and after
spans list one span (synthetic: false, value_type = raw category) when T and CredData gave value columns; 14,626 of 15,753 T rows have a span (the rest are line-level only)
hard_negatives list one span with label: not_secret when F and value columns exist
cluster_id, cluster_kind, cluster_size, doc_index, entities v3. cluster = CredData repo (creddata-<repo>, kind repo), rows of a repo in file order; entities on the first row of each repo lists one entity per distinct secret value (entity_type/value_type/replacements null)
span entity_id, surface_form_type, replacement v3. entity_id by exact value match (quotes trimmed) within the repo; surface_form_type always literal; replacement always null (no gold replacement for real data). Only 14 of 14,598 distinct (repo, value) pairs occur in more than one file (CredData obfuscates per occurrence and rows are 7-line snippets), so this set evaluates detection, not coreference

3. Label taxonomy

label value_type format fake example placement prior
api_key aws_access_key_id AKIA[A-Z0-9]{16} AKIASEL09DPS7UX387YV CredData "AWS Client ID"/"Key" rows (assignment 73%, json/yaml 14%)
api_key aws_secret_access_key 40 base64 chars cl8MIYQhAPh1mI57o/dTl/GqlHyezZbNRAi84pOC same
api_key google_api_key AIza[0-9A-Za-z_-]{35} AIzaSyD9x... same
api_key stripe_secret_key (sk|rk)_(live|test)_[A-Za-z0-9]{24} sk_live_4neiV5Vb5n0oSUNB7MWmlEfQ same
api_key sendgrid_api_key SG.<22>.<43> SG.abc... same
api_key twilio_api_key SK[0-9a-f]{32} SK3f... same
api_key mailgun_api_key key-[0-9a-f]{32} key-7a... same
api_key openai_api_key sk-(proj-)?[A-Za-z0-9]{48} sk-Fc8sLrF4g3dRlV... same
api_key anthropic_api_key sk-ant-api03-<93>AA sk-ant-api03-...AA same
api_key azure_client_secret 40 chars [A-Za-z0-9~._-] YJYGkd2XGEbq0xHBUYUN9wY7-ts1F1dO0raZXm1s same
api_key generic_hex_key 32/40/48/64 lowercase hex b4a9fa3ca185cc40da7c9edce315ac17f112fbd4 CredData "Key"/"Secret"/"Salt"/"Nonce" (hex is the dominant charset: 70%)
api_key generic_hex_key_upper 32/40/64 uppercase hex 0A4396E2885F2D6F9965B81B44051234 CredData digit+upper class (8%)
api_key generic_lower_key / generic_upper_key / generic_digit_key 16-32 lowercase letters / uppercase+digits / digits qzkmwvbtxaplrfhsncyd, 7KQ2M9XWBP4RZ1TY6LC3, 4981234509871234 CredData lower (3%), digit+upper, digit classes
api_key generic_hex_dashed_key 3-5 groups of 8 hex joined by - 3fa85f64-5717b4d2-9c1e8a7f CredData digit+lower+symbol class (2%)
api_key generic_base64_secret base64 of 24-64 bytes r/Y+kPmu4sQFtSoBF4iSX7XKFgdpVk4QiiAx2H5Lwk8= same
api_key generic_alnum_key 20-40 alphanumerics PU5lRtqn363qL3CA2bH1jYRJ same
token github_pat gh[pos]_[A-Za-z0-9]{36} ghp_Ig187tXPStYwqtbfh7hArK9jNHCrkejKHHRL CredData "Token"/"Bearer Authorization" (auth header 37%, json 24%)
token github_fine_grained_pat github_pat_<22>_<59> github_pat_... same
token slack_token xox[abp]-<digits>-<digits>-<24> xoxb-8270581127-6265886739-yPzdfqWY1JoCvnD1cSnmLsxS same
token slack_webhook https://hooks.slack.com/services/T../B../.. ... same
token jwt eyJ..\.eyJ..\.<sig> eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOi... same
token gitlab_pat / npm_token / hf_token / digitalocean_pat / discord_bot_token glpat-<20>, npm_<36>, hf_<34>, dop_v1_<64hex>, <24>.<6>.<27> hf_Lk... same
token bearer_token_opaque 32-64 base64url YJYGkd2XGEbq0xHBUYUN9wY7... same
token generic_hex_token / generic_alnum_token / generic_dashed_token / generic_upper_token 32-64 hex / 24-48 alnum / abcd-ef12-... lowercase groups / 20-32 uppercase+digits 9f1c..., Lk3P..., k9x2-7hqa-m1zt-04pd, Q7MZ2... CredData token charset classes digit+lower 17%, digit+lower+upper 20%, digit+lower+symbol 15%, digit+upper 4%
token basic_auth_b64 base64(user:password) ZGVwbG95OkhkNyFrcTJ6 CredData "Basic Authorization"
password password 5-20 chars; charset classes follow CredData (lower 49%, digit+lower 16%, mixed+symbol 10%, ...) secretgarden, summer2019, dbComputer@1601 CredData "Password"/"URL Credentials" (assignment 33%, yaml 22%, comment 11%, url 8%)
private_key pem_private_key -----BEGIN (RSA|EC|DSA|OPENSSH|) PRIVATE KEY----- + base64 lines see example in sample.jsonl CredData "PEM Private Key" (89% standalone block)
email email RFC-ish local@domain.tld, never example.* stacie16@gardner.com not in CredData; fixed mix: assignment 40%, comment 35%, json/yaml 20%
not_secret placeholder known dummy values AKIAIOSFODNN7EXAMPLE, <YOUR_API_KEY> secret-like names
not_secret example_email *@example.com/.org, test.com, localhost, company.com nroman@company.com email names
not_secret uuid RFC 4122 v4, upper or lower b044a92c-d543-47f6-874a-2ff8411d9576 id-like names (CredData labels some UUIDs T; here always negative)
not_secret md5_hash / sha1_git_sha / sha256_hash 32/40/64 hex 18ee391e0f19f9f2ed705859ee729aba checksum/commit names
not_secret env_var_reference code that reads a secret os.getenv('SECRET_KEY'), ${{ secrets.TOKEN }} secret-like names
not_secret public_key_pem / ssh_public_key -----BEGIN PUBLIC KEY-----, ssh-rsa AAAA... user@host ... public-key names
not_secret base64_non_secret base64 of an English sentence QXVkaWVuY2UgYXJndWUg... payload/body names
not_secret version_or_id IPv4, semver, package id, path, numeric id v7.20.44, 151.134.43.138 version/host names
person_name full_name / first_name / last_name v3. synthetic persona (Faker, ASCII letters and hyphens) Vasana Sur, Vasana, Sur comment 45%, assignment 35%, json/yaml 20% (author/owner/maintainer/created_by names)
username username / handle v3. derived from the persona by one of six templates; handle = @username vsur, vasana.sur, @vsur same, plus the user slot of url credentials, login as, SQL CREATE USER
email email (surface_form_type: email, entity_id of a person) v3. the persona's email vasana.sur@gmail.com as email
not_secret placeholder_name v3. dummy names in author-like slots John Doe, Your Name, nobody author/owner/user names

Label shares are stable across runs (v3: api_key ~37%, password ~18%, token ~13%, email ~12%, private_key ~8%, person_name ~7%, username ~5%; the secret-only mix is unchanged from v2); exact counts for the current release are in stats.md.

4. Files

file what size / count
data/train-AAAAA-BBBBB.parquet generated records; each Parquet file (zstd) merges base-corpus shards AAAAA..BBBBB (3 shards, ~225k records, ~2 GB JSONL, ~550 MB Parquet); clusters never cross files see stats.md for the exact file count, records and bytes
sample.jsonl ~500 records = whole clusters reservoir-sampled from shards 0-1, same schema
eval_creddata.jsonl real CredData lines (+-3 lines context), not synthetic; use only for evaluation / threshold tuning, never for training if you want an honest number. T rows = positives, F rows = hard negatives, X rows = ignore. Offsets are code-point based like the synthetic data 67,896 rows; 15,753 T / 48,061 F / 4,082 X; ~90 MB
priors.json CredData-derived statistics that drive the generator 12 KB
stats.md counts by label/value_type/context/language, size histogram, throughput
notebooks/eda.ipynb, notebooks/stats_summary.json executed EDA notebook (runs on sample.jsonl + aggregated full-run stats)
generate_dataset.py, build_priors.py, validate.py, to_parquet.py, preview_subset.py, make_stats.py, requirements.txt code

There is no train/validation split inside the synthetic data; split by cluster_id hash (never by record id, which would split clusters) or by shard (shards are independent samples of the base corpus; a cluster never crosses shards). Records from the same repo can appear in several shards as different clusters.

5. Quick start

import pyarrow.parquet as pq, glob
for f in sorted(glob.glob("data/part-*.parquet")):      # or: datasets.load_dataset("josh-hud/code-pii", data_files="data/*.parquet", streaming=True)
    for batch in pq.ParquetFile(f).iter_batches(batch_size=1000):
        for rec in batch.to_pylist():
            text = rec["text"]
            for s in rec["spans"]:                        # positives
                assert text[s["start"]:s["end"]] == s["value"]
                print(rec["language"], s["label"], s["value_type"], s["context"], s["value"][:40])
            for s in rec["hard_negatives"]:               # label == "not_secret"
                pass

# v3: iterate clusters (contiguous rows), build the gold anonymized documents
import itertools
rows = pq.read_table("data/train-00000-00002.parquet").to_pylist()
for cid, docs in itertools.groupby(rows, key=lambda r: r["cluster_id"]):
    docs = list(docs); entities = {e["entity_id"]: e for e in docs[0]["entities"]}
    for d in docs:
        t, out, pos = d["text"], [], 0
        for s in d["spans"]:                               # sorted by start, non-overlapping
            out += [t[pos:s["start"]], s["replacement"]]; pos = s["end"]
        gold_anonymized = "".join(out) + t[pos:]
        recurring = {s["entity_id"] for s in d["spans"] if entities[s["entity_id"]]["n_docs"] > 1}

Regenerate (any size): python generate_dataset.py --out ./out --target-bytes 40e9 --workers 8 (see README).