AI向けデータのガバナンス

読了まで約90 分分、12 節 節の 10 例 例。

第2026.11.31版 2026年11月19日時点で例が通過 108 例中 108 例が合格 変更点

AIによる翻訳。英語版は人による検証済みである。 当社の書籍の作り方

英語版の書籍(版2026.11.31)から翻訳した。 原文を読む

本章を終えると、AI アシスタントが学習に用いるデータを、プラットフォームにおける他のあらゆる読み取りと同じ規則のもとで構築できるようになる。著者がその用途に同意したレコードだけを受け入れ、個人データを仮名に置き換えたうえで検出器が見逃した分を測定し、MinHash で見つけた重複を取り除き、各レコードにその出所を持たせ、実行のたびにパイプラインにデータセットカードを書き出させて検査させる。また、学習データについて EU AI Act が定めている内容を引用できるようにもなる。

本書が追うオンライン学習プラットフォームは、学習者がレビューに書いた内容をもとに回答するコース用アシスタントを求めている。計画では、まずその文章に基づいてアシスタントの回答を根拠づけ、のちに同じ文章でファインチューニングを行う。review_corpusは、第4章がリネージを取得する 4 本の SQL パイプラインの一つであり、learning.reviewsの全行を、各レビューのコースと評価を付けてai.review_corpusにコピーする。第2章ではai.review_corpusに所有者も分類もないことが分かったが、このコピーにはさらに四つの問題がある。第一に、著者が自分の文章を AI の学習に使うことに同意したかどうかにかかわらず、すべてのレビューを含んでいる。第二に、その本文には氏名やメールアドレスが含まれており、これらは第3章がレビューの中に見つけたものである。第三に、レビューの大半が互いに重複している。第四に、レコードの出所を示すものが何もないため、レビューの受け入れが許可されていたことを誰も示せず、著者が考えを変えたときにそのレビューを探し出すこともできない。

本章では、本書共通の AI データ用モジュールlib.ai_dataを使ってこのジョブを作り直し、アシスタントはこのガバナンス済みのビルドからのみ学習する。pipelines/review_corpus.sqlは第4章のガバナンスのないコピーとして残すので、CIは引き続きそのリネージを検査する。モジュールは、第6章で構築した強制層を通してパイプライン自身の SQL を実行し、本文に残った個人データを置き換え、重複を取り除いたうえで、コーパス、そのリネージ、およびデータセットカードを書き出す。設定はgovernance/ai_data.tomlにあり、ポリシーと同様にレビューされる。コードが必要とする法的な問いへの答えも同じ場所にあり、それぞれがプレースホルダーになっていて、プラットフォームの法務チームが自らの答えと理由に置き換える。

この部分はまだ翻訳されていないため、英語で表示している。

Admit only reviews whose authors consented

最終変更:版2026.11.27

On the platform, consent to one use doesn't cover another, because the question a learner answers names the use. Article 5(1)(b) of the EU's General Data Protection Regulation (GDPR) says that personal data shall be "collected for specified, explicit and legitimate purposes and not further processed in a manner that is incompatible with those purposes" (GDPR). The code reads the recorded answer to whether training an AI is covered from [legal.consent] in governance/ai_data.toml, and decides consent per record when the corpus is built, not from the account's sign-up and not once for the whole table.

crm.learners.ai_training_consent records whether a learner agreed to their text training the platform's AI. Chapter 5 made it an attribute the access policy reads, so a read of learning.reviews for the purpose ai-training keeps only the reviews whose author's answer is true, with contact details removed. lib.ai_data.read runs the SELECT of pipelines/review_corpus.sql through the enforcement layer as analyst-1, the data-science principal, stating the purpose. lib.ai_data.build refuses to run unless the layer filters on the column the consent answer names. Compare three builds: the plain pipeline, pipelines/review_corpus.sql run as written; the governed read; and a consent filter written by hand.

Copied as written, the plain pipeline would put 120 labelled emails and 798 labelled names into the corpus, from 3,000 reviews.

The governed read keeps 436 reviews, the ones whose authors said yes. Without a purpose, the same principal gets 3,000 reviews, 0 of them with their text, so a job that forgets to state its purpose gets nothing it could train on.

Notice that the filter written by hand looks like respect for consent, which is why it's the one to recognize: it leaves out the learners who said no. It keeps 2,045 reviews, and 1,609 of them, 79%, are by learners who were never asked. The README of the platform's generated data says consent is unknown for sign-ups before Jun 1, 2025, and every learner with no answer signed up from Jan 1, 2024 to May 31, 2025. An unknown answer isn't a yes. A corpus built with that filter would be mostly text that no consent covers, and nothing about it would look wrong: no error, a plausible row count, and a condition on the consent column that a reviewer would read as correct. The enforcement layer's filter tests IS TRUE, so an unknown answer counts as no, which chapter 6 built for exactly this case.

On the platform, every review was written under one set of terms, so the card states one licence, read from [legal.licence]. A corpus that mixes sources, such as reviews and forum posts, needs a licence per record too, which is one reason every record keeps its source table.

Working rule: Decide consent per record, when the corpus is built, from the answer your legal team says covers the use, and admit only records whose answer is yes: never filter out the refusals and keep the rest. Build the corpus through the enforcement layer with its purpose stated, and have the build check that the layer filters on that answer. Keep the legal team's answers, with their reasons, in a reviewed file the code reads, and carry licences per record when a source mixes them.

この部分はまだ翻訳されていないため、英語で表示している。

Replace personal data in the text, then measure what's left

最終変更:版2026.11.27

Consent decides whose text may enter the corpus. It doesn't make the text free of personal data: a review names its instructor, or gives its author's email for questions. Before such text trains or grounds a model, the corpus job detects the personal data in it, replaces each value, and measures what's left, because a detector's output lists what it found and never what it missed. The truth, chapter 3's labelled spans, marks every piece of personal data the generator placed in the reviews. lib.ai_data.left counts how many labelled values are still in the text after a step, matching by value, since every replacement moves the offsets after it.

The reviews arrive from the enforcement layer with its redact_contacts mask applied, which replaces emails and phone numbers with [email] and [phone] (chapter 6). Chapter 3's detector, lib.pii.platform_detector, runs Presidio's pattern recognizers with no language model, and no pattern finds a name. So lib.ai_data.detector adds a Presidio deny list of the names the platform knows: every word of every instructor's name, which Presidio escapes and matches as a whole word, ignoring case unless told otherwise (Presidio's pattern recognizer). The list comes from crm.instructors, which analyst-1 may not read. So the platform team's own job, named in [names] in governance/ai_data.toml, builds it with the platform's own access, as the enforcement layer reads crm.learners for consent, and hands the corpus job the list, never the table. The card records which job built it and how many words it holds. lib.ai_data.known_names stands for that job. Each value found becomes a keyed pseudonym, which the next section builds. Measure each step on the reviews the corpus reads, then try a longer list, with every learner's name in it too:

corpus-personal-data-left.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Counts the labelled names and emails still in the reviews after each step of the corpus job, and the false positives of the instructors' list and of a longer one. The prose's point rests on the "then the instructors' names, PERSON left" line and the false-positive lines."""from lib import ai_data, piifrom lib.catalog import open_catalogfrom lib.enforce import Enforcer# The reviews the corpus job reads: consenting authors only, with emails and phone numbers already masked.rows = ai_data.read(Enforcer(open_catalog(["crm.learners", "learning.courses", "learning.reviews"])))texts = {row["review_id"]: row["body"] for row in rows}    # keyed by review ID, to match the labelled values row by row# What's left of the labelled personal data after each step, matched by value against the generator's truth.detectors = {"then the pattern recognizers": pii.platform_detector(), "then the instructors' names": ai_data.detector()}# the texts as the enforcement layer leaves them, before any detector runsstages = {"masked by the enforcement layer": texts}# each detector runs alone on the masked texts; pseudonymize returns the text firststages |= {name: {i: ai_data.pseudonymize(engine, text)[0] for i, text in texts.items()} for name, engine in detectors.items()}for stage, done in stages.items():    for entity, (placed, still) in ai_data.left(done).items():        print(f"{stage}, {entity} left: {still} of {placed}")# the instructors' words, from the governance team's listnames = ai_data.known_names()print("words in the list of instructors' names:", len(names))# short words are the ones ordinary text could containprint("words in the list of 3 characters or fewer:", ", ".join(word for word in names if len(word) <= 3))false_positives = sum(ai_data.unlabelled(ai_data.detector(), texts).values())assert false_positives == 0print("false positives, instructors' names:", false_positives)# Every name the platform holds, learners' too, on the same reviews: in any case, then only as written.# the union of the instructors' words and every learner's, which the table holdslonger = sorted(set(names) | set(ai_data.known_names("crm.learners")))# matched in any case, as the platform's detector matches by defaulteveryone = ai_data.detector(longer)wrong = ai_data.unlabelled(everyone, texts)print("words in the list, with learners' names:", f"{len(longer):,}")print("false positives, with learners' names:", sum(wrong.values()))print("most common false positives:", ", ".join(f"{word} ({n})" for word, n in wrong.most_common(2)))# review 24, which the longer list changesprint("a review after:", ai_data.pseudonymize(everyone, texts[24])[0])# a word matches only as written, so a lowercase word no longer matches a capitalized namecased = ai_data.detector(longer, match_case=True)cased_wrong = sum(ai_data.unlabelled(cased, texts).values())assert cased_wrong == 0print("false positives, with learners' names, matching case:", cased_wrong)# pseudonymize with the cased detector, then count what is left by valueleft = ai_data.left({i: ai_data.pseudonymize(cased, text)[0] for i, text in texts.items()})assert left["PERSON"][1] == 0print("names left, with learners' names, matching case:", f"{left['PERSON'][1]} of {left['PERSON'][0]}")
出力python corpus-personal-data-left.py
masked by the enforcement layer, EMAIL_ADDRESS left: 0 of 19
masked by the enforcement layer, PERSON left: 120 of 120
then the pattern recognizers, EMAIL_ADDRESS left: 0 of 19
then the pattern recognizers, PERSON left: 120 of 120
then the instructors' names, EMAIL_ADDRESS left: 0 of 19
then the instructors' names, PERSON left: 0 of 120
words in the list of instructors' names: 106
words in the list of 3 characters or fewer: Ray, Roy, Ulf, Uss, de, la
false positives, instructors' names: 0
words in the list, with learners' names: 4,316
false positives, with learners' names: 147
most common false positives: best (80), date (67)
a review after: Some videos are out of <PERSON_8e2b63a6>.
false positives, with learners' names, matching case: 0
names left, with learners' names, matching case: 0 of 120

The enforcement layer's mask leaves 0 of 19 emails and 120 of 120 names, and the pattern recognizers leave 120 of 120 names, since no pattern finds a name.

Only the instructors' list removes names. With its names added, the detector leaves 0 of 120 names and makes no false positives, although its list holds short words that ordinary text could contain: Ray, Roy, Ulf, Uss, de, la.

The longer list, with every learner's name in it too, makes 147 false positives. The most common, best (80), date (67), are surnames that are also English words, and the list turns Some videos are out of date. into Some videos are out of <PERSON_8e2b63a6>. in the corpus.

Matching case avoids both. Matched only as written, the longer list makes no false positives and leaves no names, because every name in these reviews is capitalized. On real text it would miss the names typed in lowercase that chapter 3 found in tickets. The platform keeps the instructors' list, matched in any case: instructors are the people reviews talk about, and the corpus job then holds their names instead of every learner's.

The list's result holds for this data only. The labelled spans are generated, and the generated reviews name only instructors, so they can't contain the case a list of instructors misses, such as a classmate's name. For names nobody listed, the detector to try is a named-entity model. Chapter 3 compared one, OpenAI's Privacy Filter, from a recording of its detections, scored against the labelled spans with lib.pii.score. Score it the same way, on the reviews the corpus reads:

privacy-filter-on-the-corpus.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Scores OpenAI's Privacy Filter, from its recorded detections, against the labelled spans in the reviews the corpus reads. The prose's point rests on the "names the model finds, exactly" and "names the model misses" lines."""from collections import Counterfrom lib import ai_data, piifrom lib.catalog import open_catalogfrom lib.enforce import Enforcer# Privacy Filter's eight labels, mapped to the labelled spans' entity types. A label with no type matches nothing.MATCHES = {"private_person": {"PERSON"}, "private_email": {"EMAIL_ADDRESS"}, "private_phone": {"PHONE_NUMBER"},           "private_address": {"LOCATION"}, "account_number": {"CREDIT_CARD", "IBAN_CODE"},           "private_date": {"DATE_TIME"}, "private_url": set(), "secret": set()}# The reviews the corpus job reads, with the model's recorded detections and the labelled spans in them. The model read# each review as written, before the enforcement layer's mask, which changes no name.corpus = {row["review_id"] for row in ai_data.read(Enforcer(open_catalog(["crm.learners", "learning.courses",                                                                          "learning.reviews"])))}# the model's detections as recorded, not a live call to the modelmodel, manifest = pii.recorded("pii-entities")found = [span for span in model if span.source == "reviews" and span.row_id in corpus]labelled = [span for span in pii.truth() if span.source == "reviews" and span.row_id in corpus]print("model:", manifest["model"])print("reviews measured:", len(corpus))# per entity type: [labelled, found exactly, found overlapping], then per detector label: [found, exact, overlapping]scores = pii.score(found, labelled, MATCHES)# the overlap count is unused here: the prose counts exact matches onlyplaced, exact, _ = scores.recall["PERSON"]print("labelled names:", placed)print("names the model finds, exactly:", exact)# private_person is the model's label for a name, so only that label counts as a matchmissed = pii.missed([span for span in labelled if span.entity == "PERSON"], found, {"private_person"})print("names the model misses:", len(missed))often = Counter(map(pii.text_of, missed)).most_common(3)print("names it misses most often:", ", ".join(f"{name} ({n})" for name, n in often))# What the model finds where no labelled span of the type its label maps to is: text it would replace for nothing.wrong = sum(n - overlap for n, _, overlap in scores.precision.values())print("the model's detections:", len(found))print("of them, overlapping no labelled span of their type:", wrong)
出力python privacy-filter-on-the-corpus.py
model: openai/privacy-filter
reviews measured: 436
labelled names: 120
names the model finds, exactly: 83
names the model misses: 37
names it misses most often: Marie (4), Liwia (4), Luigi (4)
the model's detections: 102
of them, overlapping no labelled span of their type: 0

On these reviews the model can't replace the list, and this data can't show what it adds, since every name in it is on the list. It finds 83 of the 120 labelled names exactly and misses 37, most often Marie (4), Liwia (4), Luigi (4), where the list misses none.

Of its 102 detections, 0 overlap no labelled span of their type. Where text names people no list holds, run both, measured this way first.

The text that comes out can still identify people. A detector misses spans, the text can identify someone without a name, and each record keeps a review ID that leads back to its author through learning.reviews. The GDPR's Recital 26 says: "Personal data which have undergone pseudonymisation, which could be attributed to a natural person by the use of additional information should be considered to be information on an identifiable natural person" (GDPR, Recital 26). So we call the corpus pseudonymized, never anonymized.

Working rule: Detect personal data in corpus text after the enforcement layer's masks, add the identifiers your platform holds about the people the text is about, and measure what's left against labelled data, by value, after every change to the detector. Prefer a short list of the names your text is about to every name you hold, since a long list matches ordinary words. Have a job that may read the names build the list, and record which list each corpus used. Measure a named-entity model the same way before you rely on it for names no list holds. Keep the list out of the corpus, and call the result pseudonymized.

キー付きハッシュで仮名を一貫させる

最終変更:版2026.11.27

検出された名前は、プレースホルダ <PERSON> で置き換えることも、仮名で置き換えることもできる。仮名とは、ある一つの名前に対応するトークンであり、その名前が現れるたびに同じものになる。このプラットフォームのレビューでは、講師を名のみで呼んでおり、名が同じ講師は二人といないため、ここではトークンが一人の人物を表す。仮名は誰が誰であるかを保つので、同じ講師を称賛する二つのレビューは、仮名にしても同じ講師を称賛していることが分かる。

Presidio の anonymizer には hash オペレータがあり、バージョン 2.2.361 以降は、セキュリティのため、既定でハッシュごとにランダムなソルトを加える(Presidio anonymizer)。ランダムなソルトを使うと、各ハッシュは互いに関連付けられなくなり、仮名としては役に立たない。同じ値から同じハッシュを得るには、ドキュメントにあるとおり、少なくとも 128 ビット(16 バイト)の長さの salt パラメータを「明示的に指定しなければならない」。

コーパスのジョブは、代わりに独自のキー付きハッシュを用いる。これには Presidio の custom オペレータを使い、文字列を返さなければならないラムダを渡す。lib.ai_data.pseudonym は、エンティティ型と大文字小文字を畳み込んだ値に対して、コーパスのジョブだけが持つキーの下で SHA-256 による HMAC を計算し、16 進数 8 桁を残す。HMAC は、ハッシュにキーを組み込む方法として RFC 2104 が記述する構成であり、その目的の一つとして「基礎となるハッシュ関数についての妥当な仮定に基づき、認証機構の強度について十分に理解された暗号解析を得ること」が挙げられている(RFC 2104)。Python の標準ライブラリには hmac としてこれが備わっているので、ジョブがハッシュにキーを組み込む方法として、ほかを選ぶ理由はない。

コーパスの二つのレビューが同じ講師の名を挙げている。その名を二通りの方法で置き換えると、どちらの方法が二つの関連を保つかが分かる。

keyed-pseudonyms.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Replaces the same instructor's name in two reviews by Presidio's hash, by the corpus's keyed hash and by the enforcement layer's mask. The prose's point rests on the Presidio hash lines and the keyed pseudonym line."""from collections import Counterfrom presidio_anonymizer import AnonymizerEnginefrom presidio_anonymizer.entities import InvalidParamError, OperatorConfigfrom sqlglot import expfrom lib import ai_data, enforcefrom lib.catalog import open_catalogfrom lib.enforce import Enforcerfrom lib.platform import load# Two of the corpus's reviews that name the same instructor, with what the detector found in each.layer = Enforcer(open_catalog(["crm.learners", "learning.courses", "learning.reviews"]))engine = ai_data.detector()found = [(row["body"], engine.analyze(row["body"], language="en")) for row in ai_data.read(layer)]# the first two reviews whose only detected name is Patricknamed = [(text, spans) for text, spans in found if [text[s.start:s.end] for s in spans] == ["Patrick"]][:2]print("reviews naming Patrick:", len(named))def replaced(operator: OperatorConfig) -> list[str]:    """The value that replaced the name in each of the two reviews."""    results = [AnonymizerEngine().anonymize(text, spans, {"PERSON": operator}) for text, spans in named]    return [result.text[item.start:item.end] for result in results for item in result.items]# Presidio's hash salts each value at random, so the same name gets a different hash in each reviewhashed = replaced(OperatorConfig("hash"))assert hashed[0] != hashed[1]print("Presidio's hash, the same name in two reviews gets one value:", hashed[0] == hashed[1])# and hashing the same review again gives it a different hash toorehashed = replaced(OperatorConfig("hash"))[0]assert rehashed != hashed[0]print("Presidio's hash, one review hashed twice gets one value:", rehashed == hashed[0])# a fixed salt must be at least 16 bytes; this one is 10, so Presidio refuses ittry:    replaced(OperatorConfig("hash", {"salt": "ten bytes!"}))except InvalidParamError as error:    print("a fixed salt of 10 bytes:", error)# the custom operator's lambda returns the keyed pseudonym as the replacementkeyed = replaced(OperatorConfig("custom", {"lambda": lambda value: ai_data.pseudonym("PERSON", value)}))print("keyed pseudonyms:", ", ".join(keyed))print("the name typed in lowercase:", ai_data.pseudonym("PERSON", "patrick"))# the first word of each instructor's full namefirst_names = Counter(name.split()[0] for name in load("crm.instructors").column("full_name").to_pylist())shared = sum(n for n in first_names.values() if n > 1)assert shared == 0print("instructors who share a first name with another:", shared)# What the enforcement layer's pseudonymize mask makes of the same name, run by the layer under its own key.mask = enforce.masked("pseudonymize", exp.Literal.string("Patrick"), "VARCHAR").sql(enforce.DIALECT)print("the enforcement layer's pseudonymize mask, on the same name:", layer.run(f"select {mask}").fetchall()[0][0])# functions whose name mentions HMAC: the prose says DuckDB has nonehmac = layer.connection.sql("select count(*) from duckdb_functions() where function_name ilike '%hmac%'").fetchall()[0][0]assert hmac == 0print("HMAC functions in DuckDB:", hmac)
出力python keyed-pseudonyms.py
reviews naming Patrick: 2
Presidio's hash, the same name in two reviews gets one value: False
Presidio's hash, one review hashed twice gets one value: False
a fixed salt of 10 bytes: Salt must be at least 16 bytes (128 bits). Provided salt is 10 bytes.
keyed pseudonyms: <PERSON_d14171be>, <PERSON_d14171be>
the name typed in lowercase: <PERSON_d14171be>
instructors who share a first name with another: 0
the enforcement layer's pseudonymize mask, on the same name: 23b3d8671d01840655296f752121aecc4f7991694260e5e1431d2b57c5e3d53f
HMAC functions in DuckDB: 0

Presidio の hash は、二つのレビューで同じ名前に異なる値を与え、同じレビューでもハッシュするたびに異なる値を与える。また、ドキュメントにあるとおり、Presidio は短すぎる固定ソルト(ここでは 10 バイト)も Salt must be at least 16 bytes (128 bits). Provided salt is 10 bytes. で拒否する。キー付きハッシュは両方のレビューに <PERSON_d14171be>, <PERSON_d14171be> を与え、小文字で入力した名前にも <PERSON_d14171be> を与える。

強制レイヤの pseudonymize マスクを、レイヤが同じ名前に対して実行すると、23b3d8671d01840655296f752121aecc4f7991694260e5e1431d2b57c5e3d53f になる。これは、第6章の記述どおり、レイヤのキーに値を続けたものに対する SHA-256 であり、HMAC ではない。レイヤのマスクは SQL であり、DuckDB 2.0.0 には HMAC 関数がないためである。両者は異なるキーの下にある異なる構成なので、コーパスの仮名を、レイヤがアナリストに見せる仮名と結合することはできない。

一貫性には二つのコストがある。第一に、キーと名前の一覧を持つ者は、第6章でメールアドレスについて示したように、すべての仮名を計算できる。したがってキーはシークレットマネージャに置き、コーパス、リポジトリ、ログには決して置かない。第二に、キー付きの仮名は、プレースホルダなら一つにまとめてしまうレビューを区別したままにする。異なるテキストの数は、キー付きの仮名では 96、プレースホルダでは 21 であり、これは次の節で測定する。テキストの意味が人を区別することに依存する場合、たとえば担当者と学習者の名が挙がるチケットでは、キー付きの仮名を勧める。下流で人を区別する必要がない場合は、プレースホルダを勧める。

実践ルール: 仮名は、ジョブだけが持つキーの下で HMAC を用いて作り、仮名を結合させてはならないコーパスや対象ごとに、それぞれ専用のキーを与える。仮名に Presidio の hash オペレータをソルトなしで使ってはならない。固定されたバージョンでは、ハッシュごとに値がランダムになるためである。二人が名前を共有しうる場合は、名前の語ではなく人物の ID を仮名化し、下流で人を区別する必要がない場合は、単純なプレースホルダを使う。

この部分はまだ翻訳されていないため、英語で表示している。

Find near-duplicates with MinHash

最終変更:版2026.11.31

Once its names are pseudonymized, the corpus's next problem is repetition: templates, copies, a review pasted twice, the same sentence from many people. Repetition is a privacy problem as well as a quality one. Kandpal, Wallace and Raffel found that "a sequence that is present 10 times in the training data is on average generated ~1000 times more often than a sequence that is present only once" (Kandpal et al., 2022).

Near-copies need a measure of similarity. Broder defined the resemblance of two documents as the Jaccard similarity of their sets of shingles, the overlapping runs of characters or words in a text. He showed that sampling the smallest shingles under a random permutation gives an unbiased estimate of that resemblance (Broder, 1997). Taking the smallest shingle under each of many permutations gives a MinHash signature, which estimates the similarity of two texts without comparing their sets (Mining of Massive Datasets, section 3.3).

lib.ai_data.deduplicate removes exact copies first, by SHA-256 of the case-folded text with runs of white space made one. It compares what's left as sets of 5-character shingles with datasketch's MinHash and MinHashLSH, which returns candidate pairs, and confirms each candidate by its exact Jaccard similarity. A confirmed pair at 0.8 or more is a near-duplicate, unless it differs only in a name, and of each group of duplicates the record with the lowest review ID stays. The duplicate step runs on the pseudonymized reviews, and each stage reports what it removed:

corpus-duplicates.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Runs the corpus's duplicate step on the pseudonymized reviews: exact copies, then near-duplicates by MinHash LSH, each confirmed exactly, and the records kept. The prose's point rests on the "of them, differing only in a name" and "near-duplicates removed" lines."""from collections import Counterfrom lib import ai_datafrom lib.catalog import open_catalogfrom lib.enforce import Enforcer# The reviews the corpus job reads, pseudonymized, then deduplicated: exact copies, then near-duplicates.# the reviews read, each text pseudonymized; the second value counts the replacementsrows, _ = ai_data.read_pseudonymized(Enforcer(open_catalog(["crm.learners", "learning.courses", "learning.reviews"])))# groups of reviews that stand for one record, and how many each step removedgroups, removed = ai_data.duplicate_groups(rows)print("reviews read:", len(rows))# one review per distinct normalized text: the one with the lowest review IDprint("distinct texts:", len(ai_data.exact_distinct(rows)))for step, count in removed.items():    print(f"{step}:", count)print("records kept:", len(groups))print("share of the reviews read that duplicate another:", f"{1 - len(groups) / len(rows):.0%}")# identical texts only, before normalizationtext, copies = Counter(row["body"] for row in rows).most_common(1)[0]print("the most repeated text:", text)print("its copies:", copies)# A pair MinHash finds and the exact comparison confirms, and whether it differs only in a name.distinct = [row["body"] for row in ai_data.exact_distinct(rows)]# the first confirmed pair, by position among the distinct textsi, j = sorted(ai_data.near_duplicates(distinct).confirmed)[0]print("a near-duplicate pair:", distinct[i], "|", distinct[j])print("its Jaccard similarity:", f"{ai_data.jaccard(distinct[i], distinct[j]):.2f}")# equal once each pseudonym is a placeholder: the pair differs only in which names it holdsprint("it differs only in a name:", ai_data.placeholders(distinct[i]) == ai_data.placeholders(distinct[j]))# Each record kept stands for its group's reviews, under the review ID and course of the first.# a group whose reviews come from more than one courseseveral = sum(len({row["course_id"] for row in group}) > 1 for group in groups)print("records that stand for reviews of several courses:", several)
出力python corpus-duplicates.py
reviews read: 436
distinct texts: 96
exact duplicates removed: 340
near-duplicate pairs from LSH: 381
near-duplicate pairs confirmed: 8
of them, differing only in a name: 8
near-duplicates removed: 0
records kept: 96
share of the reviews read that duplicate another: 78%
the most repeated text: Clear explanations and good exercises.
its copies: 56
a near-duplicate pair: Some videos are out of date. <PERSON_85783bac> explains things well. Happy to talk about it, write to me at [email]. | Some videos are out of date. <PERSON_967f9ae8> explains things well. Happy to talk about it, write to me at [email].
its Jaccard similarity: 0.81
it differs only in a name: True
records that stand for reviews of several courses: 23

Most of the corpus repeats itself. Of the 436 reviews read, 78% repeat another: 340 are exact copies, and only 96 texts are distinct. That's mostly the generator's doing, since it builds reviews from a handful of fixed sentences, so measure the share on your own text before training on it.

The most repeated text, "Clear explanations and good exercises.", alone appears 56 times.

MinHash then confirms 8 pairs at 0.8 or more, such as two reviews at a similarity of 0.81 that differ only in their instructor's pseudonym. Of those pairs, 8 differ only in a name, which the platform keeps apart, so near-duplicates remove 0.

Why pairs that differ only in a name stay apart comes down to what one threshold means at different lengths. Compare the corpus's reviews with the names as written, with keyed pseudonyms and with plain placeholders, then split every pair of distinct texts by whether it differs only in a name:

names-and-near-duplicates.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Counts near-duplicate pairs of the corpus's reviews with names as written, with keyed pseudonyms and with placeholders, then splits the pairs that differ only in a name by length. The prose's point rests on the pair counts and the length ranges."""from itertools import combinationsfrom lib import ai_datafrom lib.catalog import open_catalogfrom lib.enforce import Enforcer# The reviews the corpus job reads, three ways: names as written, keyed pseudonyms, and plain placeholders.layer = Enforcer(open_catalog(["crm.learners", "learning.courses", "learning.reviews"]))keyed, _ = ai_data.read_pseudonymized(layer)# the same reviews with each pseudonym replaced by a plain placeholder, as the third wayways = {"names as written": ai_data.read(layer), "keyed pseudonyms": keyed,        "placeholders": [row | {"body": ai_data.placeholders(row["body"])} for row in keyed]}# the similarity at which a pair is a near-duplicatethreshold = ai_data.DUPLICATES["threshold"]for way, rows in ways.items():    texts = [row["body"] for row in ai_data.exact_distinct(rows)]    print(f"{way}, distinct texts:", len(texts))    print(f"{way}, pairs at {threshold} or more:", len(ai_data.near_duplicates(texts).confirmed))# Every pair of distinct pseudonymized texts, split by whether the pair differs only in a name.# distinct texts only, so each text appears once in the pairstexts = [row["body"] for row in ai_data.exact_distinct(keyed)]name_only, other = [], []for a, b in combinations(texts, 2):    # similarity comes first, so min and max over these tuples order the pairs by it    pair = (ai_data.jaccard(a, b), len(a), a, b)    (name_only if ai_data.placeholders(a) == ai_data.placeholders(b) else other).append(pair)print("pairs that differ only in a name:", len(name_only))# the lowest and highest similarity among the name-only pairsprint("their Jaccard similarity:", f"{min(name_only)[0]:.2f} to {max(name_only)[0]:.2f}")for label, lengths in [(f"below {threshold}", [n for s, n, _, _ in name_only if s < threshold]),                       (f"at {threshold} or more", [n for s, n, _, _ in name_only if s >= threshold])]:    print(f"their length in characters, {label}:", f"{min(lengths)} to {max(lengths)}")# the most similar pair among those that differ in more than a namesimilarity, _, a, b = max(other)print("the most similar pair that differs in more than a name:", f"{similarity:.2f}")print("that pair:", a, "|", b)
出力python names-and-near-duplicates.py
names as written, distinct texts: 96
names as written, pairs at 0.8 or more: 10
keyed pseudonyms, distinct texts: 96
keyed pseudonyms, pairs at 0.8 or more: 8
placeholders, distinct texts: 21
placeholders, pairs at 0.8 or more: 0
pairs that differ only in a name: 459
their Jaccard similarity: 0.68 to 0.83
their length in characters, below 0.8: 66 to 78
their length in characters, at 0.8 or more: 116 to 119
the most similar pair that differs in more than a name: 0.66
that pair: Clear explanations and good exercises. Happy to talk about it, write to me at [email]. | Clear explanations and good exercises. <PERSON_3026fb67> explains things well. Happy to talk about it, write to me at [email].

Which pairs reach 0.8 depends on what stands in for each name. With the names as written, 10 pairs reach 0.8, and with keyed pseudonyms 8, since a pseudonym is longer than most first names and so a larger share of a short review. With plain placeholders, the 21 distinct texts hold 0.

Among the pseudonymized texts, 459 pairs differ only in which pseudonym they hold, at similarities from 0.68 to 0.83, and the threshold splits them by length alone: those below 0.8 are 66 to 78 characters long, and those at 0.8 or more are 116 to 119 characters long.

So the task, not the threshold, decides whether such reviews are duplicates: for a model that learns how learners describe courses, they are, and for one that learns what learners say about each instructor, they aren't. The platform's assistant answers about each course and its instructor, so name_only_pairs_are_duplicates = false in governance/ai_data.toml, and deduplicate never merges two texts that are the same once their pseudonyms are placeholders. The threshold decides the other pairs. The most similar of those, at 0.66, is a review with and without its sentence about the instructor: two different reviews. The platform keeps 0.8, above that pair with a margin.

Deduplicating on text folds reviews of different courses into one record, under the review ID and course of its first review, so the corpus keeps 96 records, and 23 of them stand for reviews of several courses. For training that's the point, since the model learns from the text. For grounding an answer about one course it costs recall, which the provenance section takes up.

Working rule: Deduplicate training text in two steps, exact copies by a hash of the normalized text and then near-duplicates by MinHash, each confirmed by its exact similarity, and report how much each step removed. Pseudonymize first, so that no name reaches the comparison or the sketches and the comparison can tell which pairs differ only in a name. Keep those pairs apart when the text's meaning depends on whom it names, and compare on placeholders when it doesn't. Choose the threshold by reading the pairs close above and below it in your own text.

この部分はまだ翻訳されていないため、英語で表示している。

Tune LSH for recall, then confirm every pair

最終変更:版2026.11.31

MinHash signatures make each comparison cheap; locality-sensitive hashing (LSH) avoids most comparisons. LSH cuts each signature into b bands of r rows, and two texts become a candidate pair when all the rows of any one band match. Leskovec, Rajaraman and Ullman derive the chance that a pair with Jaccard similarity s becomes a candidate pair (Mining of Massive Datasets, chapter 3):

P(candidate) = 1 − (1 − sʳ)ᵇ

It's an S-shaped curve: a pair well below the threshold is rarely a candidate, a pair well above it nearly always, and near the threshold it's close to a coin toss. The curve's approximate threshold is (1/b)^(1/r). datasketch's documentation warns of both kinds of error: "There will be false positives - sets that do not satisfy your threshold but returned, and false negatives - qualifying sets that are not returned" (datasketch, MinHash LSH).

With 96 distinct texts, the platform can afford to compare every pair exactly, 4,560 pairs, and that gives the exact pairs to measure LSH against. LSH sees only similarity, so it must return every pair at 0.8, whatever the name rule then decides. Score LSH against the exact comparison, tuned for 0.8 and tuned lower, each under datasketch's default hashing and under the hashing it used before its 2.0.0 release:

lsh-misses-near-duplicates.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Measures the pairs LSH misses against every pair compared exactly, under two tunings and two hashing schemes, and shows what datasketch does with sketches of two schemes. The prose's point rests on the "missed" lines."""from itertools import combinationsfrom datasketch import MinHashLSHfrom lib import ai_datafrom lib.catalog import open_catalogfrom lib.enforce import Enforcerrows, _ = ai_data.read_pseudonymized(Enforcer(open_catalog(["crm.learners", "learning.courses", "learning.reviews"])))texts = [row["body"] for row in ai_data.exact_distinct(rows)]# the similarity at which a pair is a near-duplicatethreshold = ai_data.DUPLICATES["threshold"]# Every pair compared exactly: possible at this size, and the truth LSH is measured against.pairs = {(i, j) for i, j in combinations(range(len(texts)), 2) if ai_data.jaccard(texts[i], texts[j]) >= threshold}print("pairs compared exactly:", f"{len(texts) * (len(texts) - 1) // 2:,}")print(f"pairs at a Jaccard similarity of {threshold} or more:", len(pairs))found = {}for scheme in ["affine32", "legacy"]:    # LSH tuned for the threshold, and for the lower candidate threshold    for tuned_for in [threshold, ai_data.DUPLICATES["candidate_threshold"]]:        # the bands and rows LSH chose, its candidates, and the candidates the exact check confirms        found[scheme, tuned_for] = result = ai_data.near_duplicates(texts, threshold, tuned_for, scheme)        setting = f"{scheme}, LSH tuned for {tuned_for}"        print(f"{setting}, bands:", result.bands)        print(f"{setting}, rows per band:", result.rows)        print(f"{setting}, candidate pairs:", len(result.candidates))        print(f"{setting}, confirmed:", len(result.confirmed))        # pairs the exact comparison found that LSH never proposed as candidates        missed = len(pairs - result.candidates)        print(f"{setting}, missed:", missed)        if tuned_for != threshold:            assert missed == 0  # tuned lower, LSH finds every pair under either scheme# The chance that a pair of similarity s becomes a candidate, with b bands of r rows: 1 - (1 - s^r)^b.# the bands and rows LSH chose for the threshold, as the formula uses themb, r = found["affine32", threshold].bands, found["affine32", threshold].rowsfor s in [0.8, 0.9]:    print(f"chance of a candidate at similarity {s}, LSH tuned for {threshold}:", f"{1 - (1 - s ** r) ** b:.2f}")# the S-curve's approximate threshold, which the prose compares with the threshold asked forprint("the approximate threshold, (1/b)^(1/r):", f"{(1 / b) ** (1 / r):.2f}")# What datasketch does with a sketch made under the other scheme.# an index takes sketches of one scheme, so the legacy sketch below is refusedindex = MinHashLSH(threshold=threshold, num_perm=ai_data.DUPLICATES["num_perm"])index.insert(0, ai_data.minhash(texts[0], "affine32"))try:    index.insert(1, ai_data.minhash(texts[1], "legacy"))except ValueError as error:    print("a legacy sketch in an index of affine32 sketches:", error)
出力python lsh-misses-near-duplicates.py
pairs compared exactly: 4,560
pairs at a Jaccard similarity of 0.8 or more: 8
affine32, LSH tuned for 0.8, bands: 9
affine32, LSH tuned for 0.8, rows per band: 13
affine32, LSH tuned for 0.8, candidate pairs: 36
affine32, LSH tuned for 0.8, confirmed: 1
affine32, LSH tuned for 0.8, missed: 7
affine32, LSH tuned for 0.6, bands: 18
affine32, LSH tuned for 0.6, rows per band: 7
affine32, LSH tuned for 0.6, candidate pairs: 381
affine32, LSH tuned for 0.6, confirmed: 8
affine32, LSH tuned for 0.6, missed: 0
legacy, LSH tuned for 0.8, bands: 9
legacy, LSH tuned for 0.8, rows per band: 13
legacy, LSH tuned for 0.8, candidate pairs: 52
legacy, LSH tuned for 0.8, confirmed: 6
legacy, LSH tuned for 0.8, missed: 2
legacy, LSH tuned for 0.6, bands: 18
legacy, LSH tuned for 0.6, rows per band: 7
legacy, LSH tuned for 0.6, candidate pairs: 406
legacy, LSH tuned for 0.6, confirmed: 8
legacy, LSH tuned for 0.6, missed: 0
chance of a candidate at similarity 0.8, LSH tuned for 0.8: 0.40
chance of a candidate at similarity 0.9, LSH tuned for 0.8: 0.93
the approximate threshold, (1/b)^(1/r): 0.84
a legacy sketch in an index of affine32 sketches: MinHash scheme 'legacy' does not match scheme 'affine32' of the MinHash previously given to this index

Tuned for 0.8, datasketch's default LSH returns 36 candidate pairs, misses 7 of the 8 pairs that reach 0.8, and so confirms only 1 of them.

The formula says why. With the 9 bands of 13 rows datasketch chose, a pair at similarity 0.8 becomes a candidate with a probability of 0.40, one at 0.9 with 0.93, and the approximate threshold is 0.84, above the threshold asked for.

Under the default scheme, tuned for 0.6, LSH finds every pair and returns 381 candidates. Each candidate costs one exact comparison, against 4,560 for comparing every pair, and the exact comparison discards every pair below 0.8. So the platform tunes LSH for 0.6 and confirms at 0.8, both settings in governance/ai_data.toml.

datasketch's 2.0.0 release made affine32 the default permutation scheme of MinHash, and its release notes say that hash values differ from earlier versions, so they advise rebuilding persisted sketches and LSH indexes, or passing MinHash(..., scheme="legacy"). With the legacy scheme, LSH tuned for 0.8 returns 52 candidates and confirms 6, so a count recorded under one scheme isn't reproduced under the other.

Tuned for 0.6, both schemes find all 8 pairs. With high recall and an exact check, the result depends on the similarity, not on the hash functions.

datasketch refuses to mix schemes in one index, with MinHash scheme 'legacy' does not match scheme 'affine32' of the MinHash previously given to this index, but it won't stop you comparing old counts with new ones. The book's examples pin datasketch at 2.0.0 and write scheme = "affine32" into the settings, so an upgrade can't change a recorded count without a reviewed change.

Working rule: Tune LSH below your similarity threshold, so that it misses few pairs, and confirm every candidate by its exact similarity. Measure LSH's misses against an exhaustive comparison on a sample of your corpus whenever its settings, its library or the text change. Pin the MinHash library, write its hashing scheme into your settings, and never compare counts or stored sketches made under different schemes.

すべてのレコードに来歴を持たせる

最終変更:版2026.11.27

出典までたどれないレコードは、検査することも、訂正することも、削除することもできない。レコード単位の来歴は、三つの問いに答える。どのテーブルのどの行に由来するか、そしてどのジョブのどの実行がそれをコーパスに入れたか、である。第4章は、このうち最後の部分をプラットフォームに与える。ジョブの実行ごとに OpenLineage イベントが送られ、その実行 ID は実行時刻とジョブ名から導かれる。また、列レベルのリネージュはジョブの SQL から解析される。

lib.ai_data.build は、レビュー自身の列の隣に来歴を付けて、すべてのレコードを書き出す。来歴の列は source_table、review_id、job、run_id である。ジョブの実行イベントは lib.lineage.record で送る。ここで重要な選択が一つある。リネージュは pipelines/review_corpus.sql の SQL からではなく、強制レイヤーが実行したとおりのクエリから解析する。そのクエリには同意フィルタとマスクが含まれている。コーパスを構築し、一つのレコードをその実行までたどってみる。

corpus-provenance.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Builds the corpus and follows one record back to its source row, its job and the run that wrote it, then checks that run's lineage against the query as written. The prose's point rests on the "rows filtered by" and "body" lines."""from lib import ai_data, lineage, pipelinesfrom lib.catalog import open_catalogcatalog = open_catalog(["crm.learners", "learning.courses", "learning.reviews"])built = ai_data.build(catalog)# the second record, whose text holds a pseudonymrecord = built.records.to_pylist()[1]print("a record's text:", record["body"])for column in ["source_table", "review_id", "job"]:    print(f"its {column}:", record[column])# The run that wrote it, from the lineage events: the query as the enforcement layer ran it.# the job's COMPLETE event, which carries the run's lineagecomplete = [e for e in lineage.read_events(built.folder / "events.jsonl") if e["eventType"] == "COMPLETE"][0]same_run = record["run_id"] == complete["run"]["runId"]assert same_runprint("its run_id is the COMPLETE event's run:", same_run)print("the run's inputs:", ", ".join(dataset["name"] for dataset in complete["inputs"]))# column lineage: the inputs that filter the rows, and how each field is transformedfacet = complete["outputs"][0]["facets"]["columnLineage"]# a FILTER transformation marks an input whose values decide which rows the output holdsfilters = [f"{i['name']}.{i['field']}" for i in facet["dataset"] if any(t["subtype"] == "FILTER" for t in i["transformations"])]print("rows filtered by, as run:", ", ".join(filters))# the lineage of the review text, from the reviews tabletext = [i for i in facet["fields"]["body"]["inputFields"] if (i["name"], i["field"]) == ("learning.reviews", "body")]# IDENTITY means copied unchanged; TRANSFORMATION means the value was changed on its wayprint("body, as run:", text[0]["transformations"][0]["subtype"])# the same lineage parsed from the SQL as written, with no enforcement rewritefields, rows = lineage.column_lineage(pipelines.sql(ai_data.BUILD["job"]), lineage.schema(catalog))print("rows filtered by, as written:", ", ".join(i.source for i in rows if i.subtype == "FILTER") or "nothing")print("body, as written:", fields["body"][0].subtype)# Back from every record to its review's author, with the platform's own access, against today's answers.# each record's review ID, checked against the author's consent today, not at build timeids = built.records.column("review_id").to_pylist()print("records whose author consented:", f"{ai_data.consenting(catalog, ids)} of {len(ids)}")
出力python corpus-provenance.py
a record's text: Too fast in the second half. <PERSON_85783bac> explains things well.
its source_table: learning.reviews
its review_id: 18
its job: platform/review_corpus
its run_id is the COMPLETE event's run: True
the run's inputs: crm.learners, learning.courses, learning.reviews
rows filtered by, as run: crm.learners.ai_training_consent, learning.reviews.learner_id
body, as run: TRANSFORMATION
rows filtered by, as written: nothing
body, as written: IDENTITY
records whose author consented: 96 of 96

レコードをさかのぼると、リネージュが何を記録しなければならないかが分かる。レコード「Too fast in the second half. <PERSON_85783bac> explains things well.」は learning.reviews のレビュー 18 に由来し、ジョブ platform/review_corpus によって書き出された。その run_id は、このジョブの COMPLETE イベントの実行を指す。

その実行は crm.learners, learning.courses, learning.reviews を読み込んでいる。リネージュによれば、行は crm.learners.ai_training_consent, learning.reviews.learner_id によってフィルタされている。これはどの行が存在するかを決める INDIRECT の入力 である。また、body はレビュー本文の TRANSFORMATION である。

パイプラインの SQL を書かれたとおりに解析すると、同じジョブの行は nothing でフィルタされ、body は IDENTITY のコピーになる。これは、同意の列が関与しないまま個人のテキストがそのままコピーされた、という意味になってしまう。実際に起きたことは実行されたクエリのほうであるから、リネージュにはそれを記録する。

来歴によって、コーパスは事後に検査できるようになる。すべてのレコードを learning.reviews 経由で著者まで結合すると、著者が同意しているレコードが 96 of 96 件見つかる。この検査は、プラットフォームが過去のどのビルドに対しても、現在の回答と照らして実行できる。

来歴は、検索が読み手ごとの権限を尊重することも可能にする。OWASP は、言語モデルを用いたアプリケーションに対し、「きめ細かなアクセス制御と、権限を考慮したベクトルおよび埋め込みストアを実装する」ことを求めている(OWASP LLM08:2025)。プラットフォームは、このコーパスから構築したインデックスを使って一人の人に回答する。このインデックスでは、各レコードの review_id をそのベクトルとともに保持する。取得したレコードがモデルに届く前に、検索レイヤーは、回答する相手本人として強制レイヤーに問い合わせ、それらのレビューのうち読めるものがどれかを尋ねる。これは、第6章がアシスタントのクエリを実行する方法と同じである。そして読めないものは取り除く。こうして、講師は自分のコースのレコードだけを受け取る。複数のコースのレビューを表すレコードは、最初のレビューの ID を持つ。そのため、この検査は安全側に倒れる。そのようなレコード 23 件のそれぞれについて、本人が読めたはずのテキストを隠すことはあっても、読めないテキストを見せることはない。

実践ルール: すべてのレコードに、出典テーブル、その行の ID、それを書き出したジョブと実行を持たせる。ジョブのリネージュは、フィルタとマスクを含め、実行されたとおりのクエリから記録する。古いビルドは、この来歴を通じて現在の同意と照らして検査する。すべての検索は、モデルが結果を見る前に、各レコードの出典行に対する読み手本人の判断でフィルタする。

この部分はまだ翻訳されていないため、英語で表示している。

Generate the dataset card from the run

最終変更:版2026.11.27

A dataset card tells whoever trains or audits a model what's in its data, where it came from and what was done to it. Croissant is MLCommons' metadata format for machine-learning datasets (Akhtar et al., 2024). Its 1.1 specification makes a card checkable: "Croissant datasets must declare that they conform to the versioned schema, e.g. http://mlcommons.org/croissant/1.1", and every dataset must give a description, licence, name, URL, creator and publication date. For provenance, the specification recommends the W3C PROV Ontology (PROV-O) (Croissant 1.1). Its responsible-AI vocabulary adds properties such as rai:dataCollection and rai:personalSensitiveInformation (Croissant RAI 1.0). A card written by hand describes the data someone meant to build; a card generated by the run describes the data it built.

lib.ai_data.card generates the platform's card with mlcroissant 1.1.1, MLCommons' Python library for Croissant. The run supplies the counts, the corpus file's SHA-256, a field for every column, and three PROV-O properties: the tables the pipeline's own SQL reads, which the values come from, as prov:wasDerivedFrom; the table the enforcement layer's rewrite adds, which only decides which rows exist, as prov:wasInfluencedBy; and the run, as prov:wasGeneratedBy. mlcroissant writes them through its extra_properties argument but adds no prov prefix to the card's context, so the module adds it. The creator is the owner of ai.review_corpus in governance/metadata.toml. The licence, the name, URL, description and use cases come from governance/ai_data.toml, and lib.ai_data.card_problems is the platform's own check of the result. Generate the card, first with mlcroissant's default conformsTo:

corpus-dataset-card.py Python 3.12.15 · datasketch 2.0.0 · duckdb 2.0.0 · mlcroissant 1.1.1 · openlineage-python 1.55.0 · phonenumbers 9.0.43 · presidio-analyzer 2.2.366 · presidio-anonymizer 2.2.366 · pyarrow 26.0.1 · pyiceberg 0.12.0 · pyyaml 6.0.3 · regopy 1.5.2 · sqlglot 30.33.0 · tldextract 5.4.0 合格
"""Generates the corpus's Croissant card twice, first with mlcroissant's default conformsTo and then as the platform writes it, and runs the platform's own check on it. The prose's point rests on the "conformsTo" lines and the "problems" line."""from lib import ai_datafrom lib.catalog import open_catalogbuilt = ai_data.build(open_catalog(["crm.learners", "learning.courses", "learning.reviews"]))# mlcroissant's default, then the card the pipeline writes, with Croissant 1.1 written out.# an empty list leaves conformsTo to mlcroissant, which writes its own defaultdefault, _ = ai_data.card(built, conforms_to=[])print("conformsTo, mlcroissant's default:", default["conformsTo"])# the card as the platform writes it: Croissant 1.1 and the RAI vocabulary, written outcard, warnings = ai_data.card(built)ai_data.write_card(card, built.folder)print("conformsTo, written out:", ", ".join(card["conformsTo"]))print("datePublished, the run's:", card["datePublished"])# the build's date as the major number: a nightly build may remove recordsprint("version, the run's:", card["version"])print("the sources the card names:", ", ".join(source["@id"] for source in card["prov:wasDerivedFrom"]))print("the tables that decided which rows, as the card names them:",      ", ".join(table["@id"] for table in card["prov:wasInfluencedBy"]))print("the activity the card names:", card["prov:wasGeneratedBy"]["prov:label"])# the card names every column of the corpus as a fieldprint("fields in the record set:", ", ".join(f["name"] for f in card["recordSet"][0]["field"]))for line in card["rai:dataPreprocessingProtocol"] + card["rai:personalSensitiveInformation"]:    print("-", line)# What mlcroissant reports, and what the platform's own check of the card reports.# the message after mlcroissant's severity tagprint("mlcroissant's warnings:", len(warnings))for warning in warnings:    print("- mlcroissant:", warning.split("] ", 1)[1])# the platform's own check: the library's validator doesn't report every requirementproblems = ai_data.card_problems(card, built.folder)print("problems the book's check finds:", len(problems))for problem in problems:    print("-", problem)
出力python corpus-dataset-card.py
conformsTo, mlcroissant's default: http://mlcommons.org/croissant/1.0
conformsTo, written out: http://mlcommons.org/croissant/1.1, http://mlcommons.org/croissant/RAI/1.0
datePublished, the run's: 2026-10-01T02:00:00Z
version, the run's: 20261001.0.0
the sources the card names: iceberg://platform/learning.courses, iceberg://platform/learning.reviews
the tables that decided which rows, as the card names them: iceberg://platform/crm.learners
the activity the card names: platform/review_corpus
fields in the record set: review_id, course_id, course_title, rating, body, source_table, job, run_id
- Read 436 of 3,000 reviews, filtered on crm.learners.ai_training_consent, learning.reviews.learner_id.
- Replaced personal data with keyed pseudonyms (PERSON 120).
- Removed 340 exact duplicates and 0 near-duplicates (MinHash LSH, Jaccard similarity of 0.8 or more, confirmed exactly; 8 pairs that differ only in a name kept apart).
- Kept 96 records, each with its source table, review ID, job and run.
- Values replaced by keyed pseudonyms: PERSON 120.
- Emails and phone numbers replaced by [email] and [phone] by the enforcement layer's redact_contacts mask.
- Names found with a list of 106 words from crm.instructors, built by the governance team's job governance/instructor_names; the list isn't part of the corpus.
- Measured against labelled spans: 0 of 139 labelled values left in the text.
mlcroissant's warnings: 1
- mlcroissant: Property "http://mlcommons.org/croissant/citeAs" is recommended, but does not exist.
problems the book's check finds: 1
- creator: missing

Left to its default, mlcroissant writes http://mlcommons.org/croissant/1.0, although its own LATEST_VERSION is 1.1 (mlcroissant source), so a card would declare a version it wasn't written for. The platform writes http://mlcommons.org/croissant/1.1, http://mlcommons.org/croissant/RAI/1.0.

The card's datePublished, 2026-10-01T02:00:00Z, is the build's time, because the platform publishes a card only with the build it describes. Its version, 20261001.0.0, takes the build's date as its major number. Croissant recommends MAJOR.MINOR.PATCH, where a new major version means "the existing data has been changed (edited, removed or shuffled records across splits)", and any nightly build may remove records.

The card names the sources iceberg://platform/learning.courses, iceberg://platform/learning.reviews, the influence iceberg://platform/crm.learners and the activity platform/review_corpus, and lists preprocessing steps with the run's counts.

The warnings mlcroissant reports, 1 in all, are about recommended properties, here citeAs, not about the problem the platform's check finds: creator is missing. ai.review_corpus has no owner in the metadata file, the gap chapter 2 found, so the card stays unpublished until the table has an owner. Chapter 10 reports the same gap on every run, as a finding already on main.

mlcroissant can also read a card back, with mlc.Dataset, but at 1.1.1, with rdflib 7.6.0 and pandas 3.1.1, reading emits a DeprecationWarning from rdflib and a Pandas4Warning, and returns text fields as bytes. So the book's examples only write cards, and check them with the platform's own code.

Working rule: Generate the card in the run that builds the data, with every count, hash, source and version taken from that run, and write the format's version out. Check the card with your own code for every property the specification requires, since the library's validator doesn't report them all, and don't publish or train on a corpus whose card fails.

EU AI Act が訓練データについて述べる内容を引用する

最終変更:版2026.11.27

EU の人工知能法(Artificial Intelligence Act)、規則(EU)2024/1689 は、訓練データを複数の箇所で扱っている。本節ではそのうち第10条と第53条(1)(d)の2か所を引用し、どちらについても解釈は加えない。

高リスク AI システムについて、第10条(2)は、訓練用、検証用およびテスト用のデータセットが「データガバナンスおよびデータ管理の実務の対象となる」と定め、その実務が対象とする事項を列挙している。そこには、データの収集過程とデータの出所(個人データについては収集の本来の目的を含む)、ならびにアノテーション、ラベル付け、クリーニング、更新、拡充、集約といったデータの準備が含まれる(AI Act)。

第10条(3)は、「意図された目的に照らして、関連性があり、十分に代表的であり、可能な限り誤りがなく、かつ完全である」データセットを求めている(AI Act)。

2026年7月24日に公表された規則(EU)2026/1744(AI に関するデジタル・オムニバス)は、これらの条文を引用したとおりのまま残している。同規則は、第10条の第1項と第6項を置き換え、第5項を削除し、第4a条「バイアスの検出および是正のための特別な種類の個人データの処理」を挿入する。また、第10条を含む第III章第1節から第3節の適用時期も定めている。第6条(2)および附属書 III に基づいて分類される高リスク AI システムには2027年12月2日から、第6条(1)および附属書 I に基づいて分類されるものには2028年8月2日から適用される(Regulation (EU) 2026/1744)。

汎用 AI モデルの提供者については、第53条(1)(d)が、「AI オフィスが提供する様式に従って、汎用 AI モデルの訓練に使用されたコンテンツについて、十分に詳細な概要を作成し、公開すること」を求めている。欧州委員会はこの様式を C(2025) 8311 として公表した(Commission template、PDF)。

その解説通知によれば、すでに EU 市場に投入されたモデルを改変する川下の主体は、通知が挙げる汎用 AI モデルに関する欧州委員会のガイドラインに基づき、改変後のモデルの提供者となることがある。その場合、改変を行った主体が報告するのは、改変に使用した訓練コンテンツのみである。

同法の附属書 III の表題は「第6条(2)にいう高リスク AI システム」であり、その第3項「教育および職業訓練」には、「(b) あらゆる段階の教育機関および職業訓練機関において、学習成果を評価することを意図した AI システム(その成果が自然人の学習過程を方向づけるために用いられる場合を含む)」が含まれる(AI Act)。これを引用するのは、このプラットフォームが教育プラットフォームだからであり、引用にとどめる。プラットフォームのいずれかのシステムが第6条の下で高リスクに当たるかどうかは別の問題であり、この章のコードはいずれもその答えに依存しない。

実践ルール: 同法は、官報に掲載された改正後の条文を、リンクと閲覧した日付を付けて引用すること。オムニバスによって条文も日付も変わったためである。法律はパイプラインのロジックに組み込まないこと。カードの事実は実行結果から生成し、どの条文が適用されるかは、法的な問いに答える担当者に判断させること。

本番環境で何が問題になるか

最終変更:版2026.11.27

コーパスは前触れなく問題を起こす。モデルは学習を終え、カードは公開されるが、問題は後になって、モデルの出力や、誰も答えられない問い合わせという形で現れる。

この部分はまだ翻訳されていないため、英語で表示している。

A learner withdraws after the build

最終変更:版2026.11.27

Like marketing's list in chapter 7, a corpus records who had consented on the day it was built. Take the corpus that lib.ai_data.build writes in the nightly run of Oct 1, the Oct 1 build, and withdraw the consent of the author of one of its records. Then rebuild the corpus in the same folder the next night, without generating its card again, and check each build against today's consent, as a training run does before it starts:

The Oct 1 build holds 1 record by that learner, and the Oct 2 build holds 0, so the next corpus leaves the learner out. The two builds are different runs, with their own run IDs. The next training run has to leave the learner out too, and so does the next index.

Checked through provenance against today's answers, the Oct 1 build has 95 of 96 records whose author consents, so a training run that makes the check refuses it. The Oct 2 build passes with 95 of 95.

What was made from the Oct 1 build before the withdrawal keeps the review: a copy of its file, an index built from it, a model fine-tuned on it. The European Data Protection Board considers that "AI models trained with personal data cannot, in all cases, be considered anonymous" (EDPB Opinion 28/2024).

Article 7(3) of the GDPR gives the right to withdraw consent at any time. It says that withdrawing doesn't affect the lawfulness of processing based on consent before the withdrawal, that the person must be told of this right before giving consent, and that withdrawing must be no harder than giving it (GDPR). Chapter 7 quotes the first sentences of the same article and says what a withdrawal changes in the platform's code.

The code's part is to find, through provenance, every build that holds the record, and, by run ID, every model and index made from those builds. It then reads what happens to them from [legal.withdrawal] in governance/ai_data.toml. The legal team's answer for a model made from the Oct 1 build is undecided, a placeholder under which the job lists such models for the legal team and changes nothing. If the answer is that a model must not keep the review, the one way to remove it that we can vouch for is to train the model again on a build without it.

The card failed too, without a sound. Its last preprocessing step still reads "Kept 96 records, each with its source table, review ID, job and run." The file holds 95 records, and the platform's check finds 2 problems: the missing creator, and a file whose SHA-256 isn't the one the card states. A card that isn't generated again with its data describes another dataset.

Working rule: Record which build, by run ID, every model and index was made from. Before every training run, check the build's records against today's consent and the file's hash against its card, and refuse a build that fails either. When a learner withdraws, find the builds that hold their records and the models made from them, and let your legal team's answer in config decide what happens to those.

この部分はまだ翻訳されていないため、英語で表示している。

Other failures

最終変更:版2026.11.27
  • A filter on refusals that keeps the unknowns. Built with it, the corpus held 2,045 reviews instead of 436, mostly by learners never asked. Notice it by counting the corpus's records per consent answer, through their provenance: any answer but yes is a defect.
  • Personal data a model memorizes from its text. Carlini and colleagues extracted training text from a language model, including public personal information such as names, phone numbers and email addresses, even though each such sequence appeared in a single document (Carlini et al., 2021). The plain pipeline's corpus holds 120 labelled emails, 113 of them distinct and 106 written only once, and duplicates repeat whatever a detector misses in every copy. Measure what's left against labelled samples of your own text, and deduplicate before training.
  • A pseudonym key that leaks. With the corpus's key and a list of instructors' names, anyone can compute every pseudonym in the corpus. When the key may have leaked, rotate it, rebuild every corpus made with it, and find by run ID the copies and models made from builds under the old key, as for a withdrawal.

この部分はまだ翻訳されていないため、英語で表示している。

What this chapter decided

最終変更:版2026.11.27
  • The corpus is built through the enforcement layer, as analyst-1 for ai-training: only reviews whose author's ai_training_consent is true, contacts masked, an unknown consent counted as no.
  • Every legal answer the code needs is a placeholder for the legal team in [legal] in governance/ai_data.toml: the consent that admits a record, the card's licence, and what happens to models made before a withdrawal.
  • Personal data is detected after the enforcement layer's masks, with the pattern recognizers and the platform team's list of instructors' names, and replaced by keyed pseudonyms. Privacy Filter is measured, not added. The corpus is pseudonymized, never anonymized.
  • Pseudonyms are HMAC-SHA256 under the corpus job's own key, not the enforcement layer's SHA-256 over key and value, and never Presidio's randomly salted hash.
  • Duplicates are removed in two steps, exact copies by SHA-256, then near-duplicates from MinHash LSH tuned for 0.6 and confirmed at a Jaccard similarity of 0.8, never merging texts that differ only in a name. datasketch and its scheme, affine32, are pinned.
  • Every record keeps its provenance, source_table, review_id, job and run_id, and a training run checks its build against today's consent first.
  • The dataset card is Croissant 1.1 with RAI 1.0, generated by the run, checked by the platform's own code, and unpublished until ai.review_corpus has an owner.
  • Answers for one person come from an index of the corpus, filtered by that person's decision on each record's source review.
  • The EU AI Act is quoted as amended and linked, never interpreted. A corpus is only as clean as what was admitted into it. Each record is decided when the corpus is built, each record keeps its source, so a decision can be traced back to the review it came from, and the card says what was done with the rest.

この版における本章

第2026.11.31版2026年11月19日時点で例が通過この章の10 例件のうち10件が合格

英語版の書籍(版2026.11.31)から翻訳した。

この節を引用する

形式

いずれの形式も、本訳書が従う英語版の書籍を出典として示す。

いずれの形式もこの版を明示している。そのリンクは現行版を開き、節の見出しには本文が最後に変更された日付が示される。アクセス日と取得日は、これを開いた日である。

このページの内容

全10章中の第9章: AI向けデータのガバナンス

  1. Admit only reviews whose authors consented
  2. Replace personal data in the text, then measure what's left
  3. キー付きハッシュで仮名を一貫させる
  4. Find near-duplicates with MinHash
  5. Tune LSH for recall, then confirm every pair
  6. すべてのレコードに来歴を持たせる
  7. Generate the dataset card from the run
  8. EU AI Act が訓練データについて述べる内容を引用する
  9. 本番環境で何が問題になるか
  10. A learner withdraws after the build
  11. Other failures
  12. What this chapter decided

ページの先頭に戻るすべての章