TExcelTAD
Home › Deployment & MLOps: Serving, Pipelines, Monitoring › Governance: Model Cards, Audit Trails and Fairness Checks

Governance: Model Cards, Audit Trails and Fairness Checks

A model that decides who gets a loan, which transaction is blocked or which CV a recruiter reads is not only a piece of software; it is a decision process that customers, auditors, regulators and your own colleagues will ask questions about. What is it for, and what not? What data was it trained on, and were we allowed to use it? Who approved it, and on what evidence? Does it treat groups of people differently? Which version decided this application, eight months ago? Governance is the set of documents, records and checks that let you answer those questions, from facts written down at the time rather than reconstructed afterwards. Most of it can be generated by the pipeline you already have.

Documents: model cards and datasheets

A model card (Mitchell et al., FAT* 2019) is a short document that travels with a model version. A useful one answers:

  • Intended use and out-of-scope uses ("scores consumer loan applications in country X; not for business loans, not for employment decisions").
  • Training data: which dataset version, time range, population, known gaps, with a link to its datasheet.
  • Evaluation: metrics with the split, the period and n written out, broken down by the segments that matter (region, product, age band, and protected groups where lawful), plus calibration.
  • Limitations and risks: where it is known to be weak, feedback loops (retraining strategies), what monitoring watches.
  • Owner, version, approval and date.

A datasheet for datasets (Gebru et al., 2018; published in Communications of the ACM in 2021) does the same for data: why it was collected, how, by whom, with what consent and licence, what preprocessing was applied, how long it may be kept. The data courses cover the sourcing side (privacy, consent and licensing).

The key practice is to generate these from the pipeline, not to write them by hand at the end: the metrics, the data version and the hashes already exist in the experiment tracker and the registry, so the card is always the one of the version it describes.

python · try it yourself
meta = {   # in a real pipeline: read from the tracker and the registry for this version
    "name": "risk-model", "version": 7, "owner": "credit-risk team",
    "intended_use": "score consumer loan applications (country X) for manual or automatic approval",
    "out_of_scope": ["business loans", "employment or housing decisions", "applicants under 18"],
    "data": {"dataset": "applications", "version": "2026-09-30", "rows": 48210,
             "period": "2024-01 to 2026-06", "sha256_prefix": "9f2c41d07b3e"},
    "evaluation": {"split": "time-based, test = 2026-04 to 2026-06", "n_test": 6120,
                   "auc": 0.812, "brier": 0.141,
                   "by_segment_auc": {"region north": 0.818, "region south": 0.797, "age < 25": 0.771}},
    "limitations": ["only approved applicants have outcomes (selective labels)",
                    "few applicants under 25 (n = 410 in test)"],
    "approved_by": "model risk committee, 2026-10-14",
}

def model_card(m):
    lines = [f"# Model card: {m['name']} v{m['version']}", f"Owner: {m['owner']}",
             f"Intended use: {m['intended_use']}",
             "Out of scope: " + "; ".join(m["out_of_scope"]),
             f"Data: {m['data']['dataset']}@{m['data']['version']}, {m['data']['rows']} rows, "
             f"{m['data']['period']} (sha256 {m['data']['sha256_prefix']}...)",
             f"Evaluation: {m['evaluation']['split']}, n = {m['evaluation']['n_test']}, "
             f"AUC {m['evaluation']['auc']}, Brier {m['evaluation']['brier']}"]
    lines += [f"  AUC {seg}: {auc}" for seg, auc in m["evaluation"]["by_segment_auc"].items()]
    lines += ["Limitations:"] + [f"  - {x}" for x in m["limitations"]]
    lines.append(f"Approved by: {m['approved_by']}")
    return "\n".join(lines)

print(model_card(meta))
missing = [k for k in ("intended_use", "out_of_scope", "evaluation", "limitations", "approved_by") if not meta.get(k)]
print("release check, missing card fields:", missing or "none")
# Model card: risk-model v7
Owner: credit-risk team
Intended use: score consumer loan applications (country X) for manual or automatic approval
Out of scope: business loans; employment or housing decisions; applicants under 18
Data: applications@2026-09-30, 48210 rows, 2024-01 to 2026-06 (sha256 9f2c41d07b3e...)
Evaluation: time-based, test = 2026-04 to 2026-06, n = 6120, AUC 0.812, Brier 0.141
  AUC region north: 0.818
  AUC region south: 0.797
  AUC age < 25: 0.771
Limitations:
  - only approved applicants have outcomes (selective labels)
  - few applicants under 25 (n = 410 in test)
Approved by: model risk committee, 2026-10-14
release check, missing card fields: none

The last lines are the point: a release check in CI (CI/CD for ML) can refuse to promote a version whose card lacks an intended use, segment metrics or an approval.

Records: lineage and the audit trail

Lineage links every model version to what produced it: data versions (DVC), code commit, parameters, pipeline run, and onward to the images and deployments that served it. With lineage plus the prediction log (request id, timestamp, model version), you can answer "which model, trained on what, decided application 4711, and why".

An audit trail records the human and automatic decisions along the way: who approved a release, who moved an alias, who turned on the kill switch, when, and why. It must be append-only and tamper-evident. Databases and cloud services offer write-once storage; the idea underneath is simple enough to build: each entry stores the hash of the previous one, so changing any past entry breaks every hash after it.

python · try it yourself
import hashlib
import json

def entry_hash(entry):
    return hashlib.sha256(json.dumps(entry, sort_keys=True).encode()).hexdigest()

def append(log, **event):
    event["prev"] = log[-1]["hash"] if log else "0" * 64
    event["hash"] = entry_hash({k: v for k, v in event.items() if k != "hash"})
    log.append(event)

def verify(log):
    prev = "0" * 64
    for i, e in enumerate(log):
        body = {k: v for k, v in e.items() if k != "hash"}
        if e["prev"] != prev or entry_hash(body) != e["hash"]:
            return f"broken at entry {i} ({e['action']})"
        prev = e["hash"]
    return f"ok, {len(log)} entries"

log = []
append(log, ts="2026-10-02", actor="pipeline", action="trained", model="risk-model:7", data="applications@2026-09-30")
append(log, ts="2026-10-03", actor="pipeline", action="evaluated", model="risk-model:7", auc=0.812)
append(log, ts="2026-10-14", actor="j.doe (model risk)", action="approved", model="risk-model:7")
append(log, ts="2026-10-15", actor="deploy-bot", action="alias champion -> 7", model="risk-model:7")
append(log, ts="2026-11-03", actor="on-call", action="alias champion -> 6", reason="approval rate +11 pts")
for e in log:
    print(e["ts"], f"{e['actor']:20s}", f"{e['action']:22s}", e["hash"][:12])
print("verify:", verify(log))

log[2]["actor"] = "someone else"                  # rewrite history: who approved?
print("after editing entry 2, verify:", verify(log))
2026-10-02 pipeline             trained                1700aea36cea
2026-10-03 pipeline             evaluated              15de9c48c927
2026-10-14 j.doe (model risk)   approved               8a77fb9649c2
2026-10-15 deploy-bot           alias champion -> 7    5a34cd43e044
2026-11-03 on-call              alias champion -> 6    bec5aaa752a6
verify: ok, 5 entries
after editing entry 2, verify: broken at entry 2 (approved)

The log prints each entry's hash prefix; each one depends on all entries before it. After the approver's name in entry 2 is changed, verification recomputes that entry's hash, finds that it no longer matches the stored one, and reports "broken at entry 2 (approved)". Practice question 2 asks what stops an attacker from simply recomputing every hash.

Checks: fairness by subgroup

A model can be accurate on average and still treat groups differently, usually without using the group as a feature: other features (income, postcode, employment history) carry the same information. A fairness check computes the usual metrics per group and compares them. Three comparisons are common, and they answer different questions:

  • Selection rate (share approved) per group. The ratio of the lowest to the highest is the disparate impact ratio; the "four-fifths rule" from US employment guidance (the Uniform Guidelines on Employee Selection Procedures, 1978) treats a ratio below 0.8 as a warning sign.
  • True positive rate per group: of the applicants who would repay, how many are approved? The gap is the equal opportunity difference.
  • False positive rate and precision per group: of those approved, how many default, by group?

The data below is simulated: group B (30 % of applicants) has lower incomes on average, and the model, a logistic regression on income and debt ratio only, never sees the group. The test rows are a later, held-out part of the data.

python · try it yourself
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression

rng = np.random.default_rng(0)
n = 6000
group = np.where(rng.random(n) < 0.3, "B", "A")
income = rng.normal(np.where(group == "B", 2.6, 3.0), 0.5)     # thousands per month
debt = rng.beta(2, 5, n)
repays = (0.9 * income - 2.0 * debt + rng.normal(0, 0.6, n) > 1.9).astype(int)
X = np.c_[income, debt]
train, test = slice(0, 4000), slice(4000, n)
model = LogisticRegression().fit(X[train], repays[train])
approve = (model.predict_proba(X[test])[:, 1] >= 0.5).astype(int)

df = pd.DataFrame({"group": group[test], "repays": repays[test], "approved": approve})
rows = {}
for g, d in df.groupby("group"):
    tp = ((d.approved == 1) & (d.repays == 1)).sum()
    fp = ((d.approved == 1) & (d.repays == 0)).sum()
    rows[g] = {"n": len(d), "repay_rate": d.repays.mean(), "selection": d.approved.mean(),
               "TPR": tp / (d.repays == 1).sum(), "FPR": fp / (d.repays == 0).sum(),
               "precision": tp / max(tp + fp, 1)}
table = pd.DataFrame(rows).T.astype(float)
table["n"] = table["n"].astype(int)
print(table.round(3).to_string())
print(f"accuracy overall {(df.approved == df.repays).mean():.3f}")
print(f"disparate impact ratio (selection B / A): {table.selection['B'] / table.selection['A']:.2f}")
print(f"equal opportunity difference (TPR A - B): {table.TPR['A'] - table.TPR['B']:.3f}")
      n  repay_rate  selection    TPR    FPR  precision
A  1417       0.602      0.645  0.836  0.356      0.780
B   583       0.439      0.383  0.633  0.187      0.726
accuracy overall 0.752
disparate impact ratio (selection B / A): 0.59
equal opportunity difference (TPR A - B): 0.203

On the 2,000 test rows, the model approves 0.645 of group A and 0.383 of group B: a disparate impact ratio of 0.59, well below 0.8. Part of that gap is in the outcome itself (0.602 of A and 0.439 of B repay in this simulation). The error rates show the rest: of the applicants in group B who would repay, only 0.633 are approved, against 0.836 in A, an equal opportunity difference of 0.203. Meanwhile group A has the higher false positive rate (0.356 against 0.187) and the higher precision (0.780 against 0.726). The model is not "using" the group; income is a strong feature and its distribution differs by group, and one global threshold on the score lands differently in the two populations. The single accuracy figure, 0.752, shows none of this.

What to do with such a table is not a purely technical question. Some differences follow from real differences in the outcome (the repay rates differ too), and when base rates differ it is mathematically impossible to equalise selection rates, error rates and calibration all at once, so the organisation has to choose which notion of fairness the product needs, and document why. The technical part is to measure it on every release, per group and with n next to every number (small groups give noisy rates), to keep the result in the model card, and to fail the release gate when a gap moves beyond what was approved. Remedies range from better data for the under-served group, through reviewing features that act as proxies, to group-aware thresholds, which may themselves be restricted by law; that decision belongs to people with legal and domain responsibility.

Privacy and retention

  • Minimise: train and log only the features the model needs; pseudonymise identifiers in the prediction log; keep personal data out of experiment trackers and model cards.
  • Retain on purpose: set how long training data, prediction logs and audit trails are kept, and why (the audit trail often longer than the raw inputs). Deleting a person's data may require removing it from future training sets; whether it must also be removed from trained models is an open question in law and practice, which is one reason to keep training data versioned.
  • Access: prediction logs and training data get the same access controls as the source systems; secrets and keys never in artifacts.

Regulation, briefly

Laws increasingly require exactly the artifacts above. The EU AI Act (Regulation (EU) 2024/1689) sorts AI systems into risk tiers: unacceptable practices that are banned (for example social scoring and some kinds of manipulation), high-risk systems (including credit scoring of individuals, Annex III point 5(b), many employment and education uses, and safety components of regulated products) that need risk management, data governance, technical documentation, logging, human oversight, accuracy and robustness, and conformity assessment before release, limited-risk systems with transparency duties (people must know they are talking to a chatbot, synthetic content must be marked), and minimal-risk systems with no new duties; general-purpose AI models have separate obligations. It entered into force on 1 August 2024 and applies in stages: the prohibitions from 2 February 2025, the general-purpose AI rules from 2 August 2025, most other provisions from 2 August 2026. The high-risk obligations were moved back by the Digital Omnibus on AI (Regulation (EU) 2026/1744, in force since 27 July 2026): to 2 December 2027 for Annex III systems such as credit scoring, and to 2 August 2028 for AI in products regulated under Annex I. Data protection law (in the EU, the GDPR, including Article 22 on solely automated decisions with legal or similarly significant effects), consumer credit and anti-discrimination law apply in parallel. This summary is a pointer, not legal advice: check the current text, dates and guidance with your legal team, because both the rules and their timelines are still being refined.

Pitfalls

  • Documents written after the fact. A card written at the end from memory drifts from the model; generate it from the pipeline and version it with the model.
  • An audit trail that can be edited. If entries can be changed or deleted silently, it is not evidence.
  • Fairness checked once. Group differences change with drift and retraining; check every release and in monitoring.
  • "We do not use the protected attribute, so the model is fair." Proxies carry the same information; you usually need the attribute (under strict access rules) to measure the effect.
  • Tiny groups. A rate from 40 people has a wide confidence interval; report n and intervals, and do not chase noise.

Practice

  1. Add a check to the model card release step that fails when any segment AUC is more than 0.03 below the overall AUC. Which segment would fail for version 7?
  2. In the audit trail, could an attacker who can edit the log simply recompute all hashes after changing entry 2? What prevents that?
  3. In the fairness example, the model never saw the group. Why do the selection rates still differ, and is that alone proof of an unfair model?
Answers
  1. For example bad = [s for s, a in meta["evaluation"]["by_segment_auc"].items() if a < meta["evaluation"]["auc"] - 0.03]. With an overall AUC of 0.812, the limit is 0.782: "age < 25" (0.771) fails, "region south" (0.797) passes.
  2. Yes, if the whole log is under their control. Tamper evidence needs an anchor outside it: publish or store the latest hash elsewhere (a separate system, a write-once bucket, a signed checkpoint, a ticket), so a rewritten chain no longer matches the anchored hash.
  3. Income is a feature and its distribution differs by group, so income acts as a proxy for group. A difference in selection rates alone is not proof of unfairness, since repay rates differ too, but it is a signal that must be explained: compare the error rates (TPR, FPR) by group, check whether the features are legitimate for the decision, and document the chosen fairness criterion.

Test yourself

Which of these belongs in a model card?

  1. The model's source code
  2. Intended and out-of-scope uses, training data version, metrics by segment with n, limitations, owner and approval
  3. The prediction log
  4. API keys for the registry

Why does the hash-chained audit log detect the edit of entry 2?

  1. Because entry 2 is encrypted
  2. Because each entry's hash covers its content and the previous hash, so the recomputed hash of entry 2 no longer matches
  3. Because the timestamp changed
  4. Because the log is sorted

A selection-rate ratio between two groups is 0.7. What does the four-fifths rule of thumb suggest?

  1. The model is certainly illegal
  2. A warning sign that needs investigation, since it is below 0.8
  3. Nothing, it only applies above 1
  4. Retrain with more epochs

Under the EU AI Act's risk tiers, credit scoring of individuals is generally classed as:

  1. Prohibited
  2. High-risk
  3. Limited risk
  4. Minimal risk