WorksEngineering
Demographic Encoding is Not Exposure: Fairness and Privacy in Chest X-ray Foundation Models
Abstract
Medical foundation models encode patient demographics and can reveal whether a patient was in the training set, and these properties are often treated as one problem. We tested whether they are aligned by measuring demographic encoding, diagnostic fairness gaps and membership-inference vulnerability on the same models. We trained 200 linear or multilayer-perceptron (MLP) heads on frozen BiomedCLIP, DINOv2 and RAD-DINO embeddings, with three seeds, and audited them on CheXpert and NIH ChestX-ray14. Demographic encoding explained almost no variance in patient vulnerability, and all 72 CheXpert associations were statistically equivalent to zero. Erasing linearly decodable demographics left leakage unchanged but reduced age-related underdiagnosis gaps. Leakage depended instead on head capacity and training length. On RAD-DINO, a linear head reached a membership-inference area under the curve (AUC) of 0.694, compared with 0.907 for a 30-epoch MLP, at similar test performance. Fairness and privacy should therefore be audited separately, and linear heads or shorter training reduce leakage with little or no loss of utility. The code is available on GitHub for public use.
Introduction
Foundation models are becoming the default starting point for medical imaging, and they raise two concerns for clinical use. The first concern is fairness. Chest X-ray classifiers underdiagnose under-served patient groups [1, 2]. Image representations also encode protected attributes such as sex, age and self-reported race, and race in particular cannot be read from the image by clinicians [3, 4]. The second concern is privacy. Membership inference attacks (MIAs) can reveal whether a patient’s record was used for training [5, 6]. A recent large-scale audit showed that this risk is unevenly distributed across patients and grows with model capacity [7].
These two concerns are usually discussed together, with an implicit causal story. If a representation encodes who the patient is, that patient may be easier to single out, and the encoded attributes may also provide a shortcut for biased predictions [8]. This story predicts that demographic encoding, diagnostic fairness gaps and membership vulnerability are aligned. The question has practical consequences, because it determines whether one mitigation, such as removing demographic information, serves both goals. If the three quantities are aligned, one mitigation could serve both goals. If they are not, each risk needs its own audit. Related studies have examined encoding versus its linear use for prediction [9], persistent demographic information in X-ray embeddings [10], fairness-privacy trade-offs under mitigation [11, 12, 13, 14], and memorization in medical generative and foundation models [15, 16]. However, none of these studies relates the strength of demographic encoding to patient-level membership risk. We are also not aware of a study that measures all three quantities on the same models and tests their alignment directly.
We test whether demographic encoding, diagnostic fairness gaps and MIA vulnerability are aligned or distinct in chest X-ray foundation models. We find that they are distinct. Encoding strength does not predict which patients leak, erasing linearly decodable demographics changes age-related fairness gaps but not leakage, and leakage is governed by head capacity, training length and patient atypicality.
We make four contributions. First, we design a joint audit that measures demographic encoding, diagnostic fairness gaps and patient-level MIA vulnerability for the same 200-model ensembles, on two public chest X-ray datasets and three encoders, with three seeds for the main configurations (§ 3 and Figure 1). Second, we use equivalence tests, rather than non-significant -values, to show that encoding strength is statistically unrelated to leakage. All 72 CheXpert associations are equivalent to zero, and on NIH ChestX-ray14 the only failures are the six fully trained MLP runs for age, all with a negative sign (§ 4.3). Third, we provide intervention evidence with linear concept erasure. Erasure removes most linearly decodable demographic information without changing leakage, but it reduces age-related underdiagnosis gaps, which dissociates privacy from fairness (§ 4.5). Fourth, we identify what drives leakage. Head capacity, training length, embedding family and patient atypicality explain leakage, whereas an apparent image-count effect is largely produced by taking the maximum over a patient’s records (§ 4.2 and § 4.4).

Figure 1. Study design. Frozen embeddings feed 200 heads, each trained on a random half of the audit patients. The same embeddings and heads yield three measurements (encoding, fairness and leakage), which are then related to each other. OOF: out-of-fold; LiRA: likelihood-ratio attack; FNR: false-negative rate; TPR: true-positive rate; FPR: false-positive rate.
Related work
Demographic encoding and fairness in chest radiography
Underdiagnosis by chest X-ray classifiers is larger for female, young, Black and low-income patients [1]. Deep models can predict self-reported race from images, even when the signal is hard to localize [3]. Disease-detection models also encode protected characteristics in ways that relate to performance disparities [4]. Fairness gaps need not transfer across sites [17], and removing demographic information from representations does not guarantee fair behavior [18]. The studies closest to our encoding analysis are those of Kim et al. [9], who contrast what a foundation model encodes with what its linear head uses, and Santos et al. [10], who show that demographic information persists in X-ray foundation embeddings. Neither study measures privacy.
Membership inference and disparate vulnerability
Membership inference asks whether a record was in a model’s training set [5]. Likelihood-ratio attacks calibrate this inference at low false-positive rates [6]. Vulnerability differs across groups [12], and fairness interventions can change it [11]. Knolle et al. [7] audited medical imaging models at scale with a closed-form record-level likelihood-ratio test. They found that risk concentrates in a tail of patients and rises with architecture capacity. They also observed that the over-representation of some groups in this tail is partly explained by group size. In medical generative and fine-tuned foundation models, memorization has been shown to depend on the rarity and distinctiveness of samples [15, 16]. Fairness-privacy trade-offs under mitigation have been audited at the subpopulation level [13], and private training can preserve or erode fairness [14]. These studies relate privacy to group membership, mitigation or sample rarity. To our knowledge, none of them asks whether demographic encoding predicts patient-level leakage, which is the question we address.
Concept erasure
Iterative nullspace projection removes linearly decodable attribute information from representations [19]. Least-squares concept erasure (LEACE) performs this removal in closed form and guarantees that no linear classifier can recover the attribute on the data used to fit it [20]. We use LEACE as an intervention to test whether removing encoded demographic information changes leakage.
Methods
Data and encoders
We used two public chest radiograph datasets (Table 1). CheXpert-small [21] provides sex, age group and self-reported race (race labels from the demographic file released by Stanford AIMI [3]), and NIH ChestX-ray14 [22] provides sex and age group only. From each dataset, we sampled 15,000 patients once (seed 0). For each run seed, we split them at the patient level into audit (10,500), validation (1,500) and test (3,000) sets. The age of a patient is the mean over the records of that patient, grouped into four bins: under 40, 40 to 60, 60 to 80, and 80 years or older, with lower bounds inclusive. CheXpert has 14 labels; we masked uncertain labels and treated blank labels as negative. NIH ChestX-ray14 has 15 labels.
| Dataset | Patients | Images | Audit records | Labels | Attributes | Encoders |
| CheXpert-small | 15,000 | 44,622 | 31,601 | 14 | sex, race, age | BiomedCLIP, DINOv2, RAD-DINO |
| NIH ChestX-ray14 | 15,000 | 54,521 | 38,316 | 15 | sex, age | BiomedCLIP, RAD-DINO |
Table 1. Datasets and encoders. Image counts are those used after sampling 15,000 patients.
Embeddings came from three frozen encoders. BiomedCLIP [23] provides 512-dimensional embeddings from its image tower. DINOv2 [24] provides 768-dimensional class-token (CLS) embeddings and serves as a general-domain control. RAD-DINO [25] provides 768-dimensional CLS embeddings and is specific to radiology. On NIH ChestX-ray14, we used BiomedCLIP and RAD-DINO only (Table 1). The pretraining data of RAD-DINO include CheXpert. We therefore treat its CheXpert results as an upper bound on the behavior of a domain-matched encoder, not as a clean test of generalization. We standardized all embeddings using audit-set statistics.
Heads and membership audit
Following Knolle et al. [7], we trained models, each on a random half of the audit patients, so that every patient was a member of exactly 100 models. Each model was either a linear head or a one-hidden-layer multilayer perceptron (MLP) on the frozen embedding. The loss, the training settings and the metrics are described in § 3.3.
Let be the embedding of record , the logit of model for label , the label and an indicator that the label is valid. The record-level score was the mean signed logit margin over valid labels,
For each record , we computed the closed-form likelihood-ratio attack (LiRA) statistic
where and are the mean and variance of the record score over the models that contain the record, and are the same quantities over the models that exclude it (the record index is omitted for readability), and is the standard normal cumulative distribution function. The statistic equals the area under the curve (AUC) that separates the in and out score distributions when both are Gaussian.
As a calibration check, we re-drew membership at random. This null yielded a patient-level 99th percentile of approximately 0.606 in every run, and the closed-form and empirical AUCs agreed. We also report two alternative patient scores that remove the effect of taking the maximum over records, namely the mean over records and the score of one random record.
Loss, metrics and hyperparameters
Each model minimized the binary cross-entropy over the valid labels of its own member records, averaged over labels and records. We drew minibatches of records with replacement from all audit records and trained all
models on the same minibatch, with the loss of each model restricted to its member records (about half of each minibatch). One epoch corresponds to steps. Table 2 lists the hyperparameters of the heads and of the linear probes used for encoding (§ 3.4). Weights were initialized from a Gaussian distribution scaled by the inverse square root of the fan-in, and biases were set to zero. The reference head of § 3.5 used the same settings but was trained on all audit patients.
| Setting | Value | |
| Heads | Architecture: Linear, or MLP with GELU (512 hidden units; 8 and 64 in the sweep) | |
| Heads | Number of models | 200 (each patient in 100 models) |
| Heads | Optimizer, weight decay | AdamW [26], |
| Heads | Learning rate | (linear), (MLP) |
| Heads | Schedule | Cosine annealing to zero |
| Heads | Batch size , epochs | 2048, 30 (5 in the sweep) |
| Heads | Seeds | 3 (main configurations), 1 (sweep) |
| Probes | Optimizer, weight decay | AdamW, |
| Probes | Learning rate, batch size | , 2048 |
| Probes | Epochs, cross-validation | 30, 5 folds |
Table 2. Hyperparameters of the heads and of the encoding probes of § 3.4. One epoch is minibatch steps. The probes of Table 6 are described in § 3.7.
We measured utility as the macro-averaged area under the receiver operating characteristic curve (AUROC) over the labels with both classes present, computed for the reference head on the test patients.
Leakage was measured at the record, aggregate and patient levels. Let indicate whether record belongs to the training set of model . For the aggregate attack, we computed for every pair of model and record the log-likelihood ratio
where is the Gaussian density and the means and variances are estimated from the models other than . The aggregate MIA AUC is the area under the curve that separates members () from non-members () by , computed on a random sample of at most four million pairs. We also report the true-positive rate (TPR) at a false-positive rate (FPR) of ,
where is the decision threshold. The record-level statistic was aggregated to the patient level by
where is the set of records of patient . We summarize by its 99th percentile and by the share of patients with .
For an attribute with classes, the patient-level encoding score is the prior-corrected posterior probability of the true class of patient ,
where is the out-of-fold logit of class from the linear probe and is the class prior in the training folds. The chance level of is . The overall encoding strength is the one-vs-rest macro-averaged AUROC of the posteriors.
For a group of test patients, and with the per-label thresholds of § 3.5, the macro false-negative rate (FNR) and the underdiagnosis rate are
where FN, TP, FP and TN are record counts at these thresholds, is the set of disease labels with at least 20 positive records in , and index 0 denotes the label “No Finding”. The underdiagnosis rate is therefore the record-level FPR of “No Finding”, computed over records with a valid negative “No Finding” label. The gaps relative to the reference group are
Demographic encoding
For each attribute, we fitted linear probes on patient-mean embeddings and obtained out-of-fold (OOF) predictions with 5-fold cross-validation. The encoding score and the encoding strength are defined in Eq. (6) and § 3.3. The probes used all 15,000 sampled patients, and the scores of the audit patients entered the association analysis. For CheXpert race, we excluded the categories “Unknown” and “Other”.
Diagnostic fairness
We trained a reference head on all audit patients and fixed per-label thresholds on the validation set using the Youden index [27]. On the held-out test patients, we computed the FNR gap and the underdiagnosis gap (Eq. (8)) relative to the largest group of each attribute, which served as the reference group. The underdiagnosis rate is the rate at which patients with disease are called healthy. Within each run, we estimated confidence intervals (CIs) of the gaps with a patient-clustered bootstrap of 500 resamples. For the differences between original and erased embeddings across seeds (§ 4.5), we used a -interval over the three seeds. The Results focus on the underdiagnosis gap, which is the primary measure of Seyyed-Kalantari et al. [1]. The FNR gap was computed with the same procedure but is not analyzed further.
Association and equivalence analysis
We related patient encoding scores to patient MIA vulnerability in two ways. The first was the rank-transformed partial correlation . The second was the increment that encoding adds to a regression that also contains log record count, -nearest-neighbor sparsity (, cosine distance), number of findings and log group size. A non-significant -value does not show that an association is absent, so we used equivalence tests [28, 29]. We call an association equivalent to zero if two conditions hold. The 95% CI of must lie within , which is a conservative two-one-sided-test criterion, and the upper bound of the CI of must be below 0.01. All variables were rank-transformed. Sparsity was computed on patient-mean embeddings within the audit set, the number of findings is the mean number of positive findings per record, and log group size is the logarithm of the number of audit patients in the group of the patient. The CIs of and are percentile intervals from a patient-level bootstrap of 500 resamples.
For the analysis of § 4.4, we fitted a broader rank regression with eight predictor blocks on the seed-0 runs. The blocks were log record count, sparsity, number of findings, the mean fraction of uncertain labels per record, the mean number of rare findings per record (labels with a prevalence below 5%), the fraction of records with support devices, patient age, and demographic encoding (the mean of the attribute encoding scores). For each block, we report the drop-one , that is, the decrease in when the block is removed from the full model. Because the blocks are correlated, these values do not sum to the total .
Interventions and sweeps
We applied LEACE [20] to erase the one-hot sex, race and age concepts jointly on CheXpert and then repeated the audit. We fitted LEACE at the record level on all records of the 15,000 sampled patients, including validation and test patients, with one-hot columns for all observed race categories. Because LEACE serves here as an analytical intervention rather than a deployable mitigation, this transductive fit applies the same erasure map to every audited and evaluated record. To measure residual demographic information (Table 6), we fitted separate 5-fold probes on re-standardized patient-mean embeddings of all sampled patients. These were a linear probe and an MLP probe with one hidden layer of 256 ReLU units, trained with class-weighted cross-entropy, AdamW (learning rate , weight decay ), 20 epochs and a batch size of 512. They report the macro-AUROC of uncorrected posteriors, so their values differ from the encoding strengths of § 4.3, which use the probes of § 3.4.
| Encoder | Embedding | Linear probe Age | Linear probe Race | Linear probe Sex | MLP probe Age | MLP probe Race | MLP probe Sex |
| BiomedCLIP | Original | 0.746 | 0.704 | 0.893 | 0.820 | 0.683 | 0.914 |
| BiomedCLIP | LEACE | 0.442 | 0.512 | 0.564 | 0.561 | 0.591 | 0.794 |
| RAD-DINO | Original | 0.872 | 0.802 | 0.998 | 0.853 | 0.804 | 0.998 |
| RAD-DINO | LEACE | 0.511 | 0.541 | 0.683 | 0.692 | 0.666 | 0.994 |
Table 6. Probe macro-AUROC on patient-mean embeddings before and after LEACE on CheXpert, using the probes described in § 3.7. The macro-AUROC chance level is 0.5.
To study capacity and training length, we varied the MLP width (8, 64 and 512 hidden units) and the number of epochs (5 and 30) for BiomedCLIP and RAD-DINO on seed 0. On NIH CheXstX-ray14, the sweep included only the 5-epoch MLP. Table 5 pools these sweep runs under “MLP reduced”. The main configurations (linear and 30-epoch MLP heads) used three seeds, and each seed re-drew the patient split, the membership assignment and the head initialization. We report the mean standard deviation (s.d.).
| Dataset | Head regime / attribute | Runs | Partial range | Widest 95% CI | -equiv. | max (CI upper) | -equiv. |
| CheXpert | Linear / Sex | 9 | [-0.012, +0.020] | [-0.029, +0.039] | 9/9 | 0.0009 | 9/9 |
| Linear / Race | 9 | [-0.027, +0.016] | [-0.049, +0.037] | 9/9 | 0.0013 | 9/9 | |
| Linear / Age group | 9 | [-0.032, +0.013] | [-0.051, +0.034] | 9/9 | 0.0016 | 9/9 | |
| MLP-512, 30 ep / Sex | 9 | [+0.001, +0.027] | [-0.016, +0.048] | 9/9 | 0.0014 | 9/9 | |
| MLP-512, 30 ep / Race | 9 | [-0.005, +0.035] | [-0.027, +0.056] | 9/9 | 0.0018 | 9/9 | |
| MLP-512, 30 ep / Age group | 9 | [-0.008, +0.028] | [-0.028, +0.047] | 9/9 | 0.0011 | 9/9 | |
| MLP reduced / Sex | 6 | [-0.033, +0.017] | [-0.050, +0.037] | 6/6 | 0.0015 | 6/6 | |
| MLP reduced / Race | 6 | [-0.020, +0.013] | [-0.041, +0.033] | 6/6 | 0.0012 | 6/6 | |
| MLP reduced / Age group | 6 | [-0.018, +0.010] | [-0.038, +0.027] | 6/6 | 0.0009 | 6/6 | |
| NIH CXR14 | Linear / Sex | 6 | [-0.024, +0.003] | [-0.043, +0.022] | 6/6 | 0.0012 | 6/6 |
| Linear / Age group | 6 | [-0.050, -0.029] | [-0.069, -0.010] | 6/6 | 0.0030 | 6/6 | |
| MLP-512, 30 ep / Sex | 6 | [-0.060, -0.024] | [-0.078, -0.005] | 6/6 | 0.0027 | 6/6 | |
| MLP-512, 30 ep / Age group | 6 | [-0.145, -0.088] | [-0.165, -0.068] | 0/6 | 0.0114 | 5/6 | |
| MLP reduced / Sex | 2 | [-0.025, -0.007] | [-0.044, +0.012] | 2/2 | 0.0010 | 2/2 | |
| MLP reduced / Age group | 2 | [-0.062, -0.050] | [-0.079, -0.029] | 2/2 | 0.0039 | 2/2 |
Table 5. Equivalence tests by dataset, head regime and attribute. For the linear and 30-epoch MLP regimes, the column Runs counts encoder and seed combinations. “MLP reduced” pools the seed-0 sweep runs of BiomedCLIP and RAD-DINO (8- and 64-unit MLPs and the 5-epoch 512-unit MLP on CheXpert; the 5-epoch MLP on NIH ChestX-ray14), so Runs counts encoder and configuration combinations.
Results
Leakage depends on encoder and head, not on utility
Leakage varied widely while test performance changed little (Table 3 and Figure 2). On CheXpert, a 30-epoch MLP on RAD-DINO reached an aggregate MIA AUC of 0.907. It placed 59.6% of patients above an AUC of 0.9 and achieved a TPR of 12.4% at an FPR of . A linear head on BiomedCLIP gave corresponding values of 0.568, 0.0% and 0.5%. Its test AUROC was modestly lower, at 0.733 compared with 0.766 for the RAD-DINO MLP and 0.772 for the RAD-DINO linear head.
| Dataset | Encoder / head | Test AUROC | MIA AUC | TPR@FPR (%) | Patient AUC p99 | Patients AUC (%) |
| CheXpert | BiomedCLIP / Linear | |||||
| BiomedCLIP / MLP | ||||||
| DINOv2 / Linear | ||||||
| DINOv2 / MLP | ||||||
| RAD-DINO / Linear | ||||||
| RAD-DINO / MLP | ||||||
| NIH CXR14 | BiomedCLIP / Linear | |||||
| BiomedCLIP / MLP | ||||||
| RAD-DINO / Linear | ||||||
| RAD-DINO / MLP |
Table 3. Utility and leakage (mean s.d. over three seeds). The column Patients AUC gives the share of patients whose max-over-records membership AUC is at least 0.9.

Figure 2. Leakage is decoupled from utility. (a, b) Aggregate MIA AUC versus test AUROC on CheXpert and NIH ChestX-ray14. (c) Survival curve of patient-level membership AUC on CheXpert; the gray curve shows the null with random membership.
For all three encoders, the MLP head leaked more than the linear head without a gain in test AUROC. The MIA AUC rose from 0.568 to 0.698 for BiomedCLIP, from 0.653 to 0.827 for DINOv2 and from 0.694 to 0.907 for RAD-DINO. The pattern replicated on NIH ChestX-ray14, where the MIA AUC rose from 0.692 to 0.810 for RAD-DINO and from 0.566 to 0.618 for BiomedCLIP. This result is consistent with the capacity effect reported for end-to-end models [7] and shows the same effect for small heads on frozen features. Variation across seeds was negligible, with an s.d. of at most 0.002 in MIA AUC.
Training length and capacity control leakage
Leakage is not a property of the encoder alone (Table 4; all values in this subsection are from seed 0). With RAD-DINO on CheXpert, a 512-unit MLP trained for 5 epochs matched the MIA AUC of the linear head (0.694) at a test AUROC of 0.770. Training the same MLP for 30 epochs raised the MIA AUC to 0.907 without a utility gain. A narrow MLP with 8 units leaked little (0.552) but lost utility (test AUROC of 0.665). An MLP with 64 units already leaked about as much as the linear head (0.689). BiomedCLIP showed the same shape, with the 512-unit MLP reaching an MIA AUC of 0.555 after 5 epochs and 0.698 after 30 epochs, at test AUROCs of 0.725 and 0.734, respectively. On NIH ChestX-ray14, the MIA AUC of RAD-DINO rose from 0.693 to 0.808. Shorter training was not always free on this dataset: for BiomedCLIP, the 5-epoch MLP lost about 0.02 in test AUROC relative to the 30-epoch MLP (0.741 versus 0.762). The 5-epoch setting is a fixed proxy for early stopping and does not use validation-based early stopping.
| Encoder | Head | Test AUROC | MIA AUC | TPR@FPR (%) | Patients AUC (%) |
| CheXpert / BiomedCLIP | Linear | 0.736 | 0.568 | 0.51 | 0.0 |
| CheXpert / BiomedCLIP | MLP-8, 30 ep | 0.632 | 0.503 | 0.11 | 0.0 |
| CheXpert / BiomedCLIP | MLP-64, 30 ep | 0.724 | 0.550 | 0.24 | 0.0 |
| CheXpert / BiomedCLIP | MLP-512, 5 ep | 0.725 | 0.555 | 0.35 | 0.0 |
| CheXpert / BiomedCLIP | MLP-512, 30 ep | 0.734 | 0.698 | 1.67 | 2.9 |
| CheXpert / RAD-DINO | Linear | 0.779 | 0.694 | 3.02 | 1.4 |
| CheXpert / RAD-DINO | MLP-8, 30 ep | 0.665 | 0.552 | 0.41 | 0.0 |
| CheXpert / RAD-DINO | MLP-64, 30 ep | 0.765 | 0.689 | 1.54 | 1.0 |
| CheXpert / RAD-DINO | MLP-512, 5 ep | 0.770 | 0.694 | 2.46 | 2.9 |
| CheXpert / RAD-DINO | MLP-512, 30 ep | 0.770 | 0.907 | 12.63 | 59.3 |
| NIH CXR14 / BiomedCLIP | Linear | 0.752 | 0.565 | 0.82 | 0.1 |
| NIH CXR14 / BiomedCLIP | MLP-512, 5 ep | 0.741 | 0.539 | 0.37 | 0.0 |
| NIH CXR14 / BiomedCLIP | MLP-512, 30 ep | 0.762 | 0.617 | 1.28 | 1.2 |
| NIH CXR14 / RAD-DINO | Linear | 0.799 | 0.692 | 4.58 | 1.4 |
| NIH CXR14 / RAD-DINO | MLP-512, 5 ep | 0.801 | 0.693 | 4.02 | 2.8 |
| NIH CXR14 / RAD-DINO | MLP-512, 30 ep | 0.806 | 0.808 | 7.05 | 16.9 |
Table 4. Capacity and training-length sweep over MLP width and number of epochs (seed 0).
Demographic encoding is statistically unrelated to patient vulnerability
All three encoders encoded demographics linearly. On CheXpert, the encoding macro-AUROC for age, race and sex was 0.78, 0.68 and 0.89 for BiomedCLIP, 0.85, 0.76 and 0.98 for DINOv2, and 0.90, 0.78 and 1.00 for RAD-DINO. On NIH ChestX-ray14, the values for age and sex were 0.72 and 0.94 for BiomedCLIP and 0.87 and 1.00 for RAD-DINO.
However, within a model, the strength with which the demographics of a patient were encoded did not predict the vulnerability of that patient (Figure 3 and Table 5). On CheXpert, all 72 associations (attributes × head regimes × encoders × seeds) were equivalent to zero. Their absolute partial correlations were at most 0.035, the widest 95% CI was ±0.056, and the largest upper bound on was 0.0018. On NIH ChestX-ray14, 22 of 28 associations passed the criterion and 27 of 28 passed the criterion. All six exceptions to the criterion were fully trained MLP runs for age, with between −0.145 and −0.088, and the single exception to the criterion (upper bound 0.0114) occurred in the same group of runs. Their sign was negative, so stronger age encoding went with lower leakage. For these runs, we therefore claim only that encoding strength did not increase leakage, not that the association was equivalent to zero.
Figure 3. Partial rank correlation between demographic encoding and membership vulnerability. Points are individual runs with 95% CIs, and the shaded band is the equivalence region of ±0.1.
At the model level, encoding strength and leakage gave the same ranking of encoders, with RAD-DINO first, DINOv2 second and BiomedCLIP third. This observation is suggestive but not conclusive, because it rests on only three encoders and the patient-level association is null. We interpret it as a possible shared driver, such as embedding richness, rather than as evidence of causation.
Patient atypicality, not demographics, predicts vulnerability
Under the max-over-records score, log record count alone explained a of 0.19 to 0.33 of patient vulnerability (Figure 4). This effect largely disappeared when patients were scored by the mean over records or by one random record (). The exception was the RAD-DINO linear head, with values of 0.143 and 0.108, respectively. The record-count effect therefore mainly reflects taking a maximum over more draws. The remaining explained variance came from features of patient atypicality. These features were the number of findings (up to 0.124 for the RAD-DINO MLP), rare findings and sparse embedding neighborhoods (up to 0.064 for the BiomedCLIP MLP), and support devices (at most 0.021). Demographic encoding contributed approximately zero under every score. The total under the alternative scores was 0.07 to 0.30, so these features leave most of the patient-level variance unexplained.

Figure 4. Incremental of each feature block for patient vulnerability on CheXpert under three patient scores (maximum over records, mean over records and one random record). Cells show the drop-one of each block for the seed-0 runs, and Total is the of the full model. BC: BiomedCLIP; RD: RAD-DINO.
Erasing demographics changes fairness, not leakage
LEACE substantially reduced linearly decodable demographic information (Table 6). Nonlinear probes still recovered sex, with an MLP-probe macro-AUROC of 0.994 for RAD-DINO, so the erasure was incomplete. Linear probes also retained some information (for example 0.683 for RAD-DINO sex). One possible reason is that LEACE was fitted on records, whereas the probes use patient-mean embeddings. Leakage did not change (Figure 5a). The MIA AUC was 0.568 before and after erasure for the BiomedCLIP linear head. It moved from 0.698 to 0.700 for the BiomedCLIP MLP, from 0.694 to 0.695 for the RAD-DINO linear head and from 0.907 to 0.913 for the RAD-DINO MLP. The linear-head values come from one seed and the MLP values from three seeds. The cost in test AUROC was about 0.02 for BiomedCLIP and 0.01 for RAD-DINO.
Fairness, in contrast, responded to erasure (Figure 5b). With MLP heads over three seeds, the underdiagnosis gap for patients under 40 years decreased from 0.167 to 0.054 on BiomedCLIP. The difference was 0.113 (95% CI [0.073, 0.153]) and had the same direction in all three seeds. On RAD-DINO, the same gap decreased from 0.136 to 0.101 (difference 0.035, 95% CI [0.027, 0.042]). The gap for patients aged 40 to 60 years decreased from 0.086 to 0.035 on BiomedCLIP and from 0.069 to 0.051 on RAD-DINO. For patients aged 80 years and over, the BiomedCLIP gap changed sign, from −0.027 to +0.035. The Black-White gap on BiomedCLIP shrank from 0.095 to 0.044, but its CI included zero, so we report this change as directional only. On RAD-DINO, this gap changed little, from 0.106 to 0.096. Sex and Asian gaps remained near zero throughout. These CIs are based on a -interval over three seeds (two degrees of freedom) and are therefore crude.

Figure 5. Effect of LEACE on leakage and fairness on CheXpert. (a) Aggregate MIA AUC before and after erasure (linear heads: one seed; MLP heads: mean over three seeds). (b) Underdiagnosis gap relative to the reference group for MLP heads. Values are means over three seeds, and bars show ±1 s.d. across seeds.
Taken together, these results separate the two problems. Removing the age information that a linear model can read reduced age-related disparity, but it did not make patients less identifiable as training members.
Results on NIH ChestX-ray14
NIH ChestX-ray14 reproduced the encoder and capacity ordering of leakage observed on CheXpert (Table 3 and Table 4). The fairness results, however, differed. The gaps were small, and the reference age group was 40 to 60 years. The gap for patients aged 60 to 80 years ranged from −0.057 to −0.098, and the female gap ranged from +0.008 to +0.041. We therefore do not pool fairness findings across datasets.
Discussion
The intuitive view that encoding leads to exposure would justify a single remedy for both fairness and privacy, but our data do not support it. Encoding strength did not predict which patients leaked (§ 4.3), and erasing linearly decodable demographic information did not change leakage (§ 4.5), although nonlinear demographic information remained. Instead, leakage depended on how the head was trained and on how atypical the patient was (§ 4.2 and § 4.4). Erasure did, however, reduce age-related underdiagnosis. In our setting, encoding is therefore relevant to fairness without being relevant to membership exposure, and practitioners should audit the two risks separately.
The results have three practical implications for frozen-embedding pipelines. First, linear heads or shorter training reduced patient-level leakage substantially with little or no utility cost. For RAD-DINO on CheXpert, the MIA AUC fell from 0.907 for the 30-epoch MLP to 0.694 for the linear head with no loss of test AUROC, whereas BiomedCLIP on NIH ChestX-ray14 lost about 0.02 in test AUROC with a linear head or shorter training. Second, analyses based on the maximum over the records of a patient overstate the role of image count. Third, the most vulnerable patients were those with unusual findings or sparse embedding neighborhoods. These characteristics are not demographic attributes, which suggests that the patients most exposed to membership inference need not coincide with the groups at risk of underdiagnosis.
Our capacity result is consistent with Knolle et al. [7], who found that leakage increases with model capacity and that the enrichment of groups in the patient tail partly tracks group size. We add two observations for frozen features. Training length mattered about as much as head width, and demographic encoding did not predict patient vulnerability once atypicality features were included in the model.
Limitations
Our conclusions apply to the setting we audited, which is small heads trained on frozen embeddings of chest radiographs from two public datasets. This setting corresponds to using a foundation model as a fixed feature extractor, and it allowed us to train 200-model ensembles with controlled membership. Whether the same dissociation holds for end-to-end fine-tuned models, other imaging modalities or differentially private training remains to be tested. Frozen embeddings can also discard small-lesion signal [30], so leakage at the backbone level may differ.
Several design choices define how far the intervention and encoding results extend. LEACE removes linear information only, and nonlinear probes still recovered some demographic signal (Table 6). We fitted it on all records, including test patients, because we used it as an analytical intervention and not as a deployable mitigation. Our encoding scores are likewise linear and therefore measure linearly decodable demographic information. The capacity sweep and the linear-head LEACE runs used one seed, the confidence intervals of the fairness differences rest on three seeds, and the agreement between encoding and leakage at the encoder level rests on three encoders. We therefore treat these results as supporting evidence, and the main conclusions rest on the three-seed analyses. The 5-epoch setting is a fixed proxy for early stopping. The pretraining data of RAD-DINO include CheXpert, so its CheXpert results are an upper bound for a domain-matched encoder, and DINOv2 is only a partial control.
The demographic labels also bound the analysis. The CheXpert race labels are coarse, self-reported categories from the Stanford AIMI demographic file [3] in which Hispanic ethnicity is folded into the race groups, and “Unknown” and “Other” were excluded. NIH ChestX-ray14 has no race labels, and its fairness pattern differs from that of CheXpert. We did not analyze intersectional subgroups.
Conclusion
Demographic encoding, diagnostic fairness and membership vulnerability are separable in heads trained on chest X-ray foundation-model embeddings. Encoding strength was statistically equivalent to zero as a predictor of patient leakage in all 72 CheXpert tests. Linear erasure of demographics left leakage unchanged but reduced age-related underdiagnosis, although nonlinear demographic information remained. Leakage instead tracked head capacity, training length, embedding family and patient atypicality. Fairness and privacy should therefore be audited separately, and simple choices of head and training length can reduce exposure considerably. Future work should test whether these findings hold for end-to-end fine-tuned models, other imaging modalities and differentially private training.
Data and code availability
Both datasets are publicly available. CheXpert [21] is released by the Stanford ML Group, and NIH ChestX-ray14 [22] is released by the NIH Clinical Center. Race labels for CheXpert were obtained from the demographic file released by Stanford AIMI [3]. We obtained copies through Kaggle: CheXpert-v1.0-small (https://www.kaggle.com/datasets/ashery/chexpert) and NIH Chest X-rays (https://www.kaggle.com/datasets/nih-chest-xrays/data). The source code is available at https://github.com/SAMZ2610/privacy_bias_fairness.
Declaration of generative AI in scientific writing
During the preparation of this work, the authors used Claude Sonnet 5.5 to improve the English language, correct grammar, and enhance the overall flow of the text. After using this tool, the authors reviewed and edited the content as needed and take full responsibility for the final content of the publication.
Declaration of competing interest
The authors declare no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
CRediT authorship contribution statement
Sahar Askari: Conceptualization, Methodology, Software, Visualization, Investigation, Writing - Original Draft, Writing - Review & Editing. Amin Golnari: Writing - Review & Editing.
References
- [1]Laleh Seyyed-Kalantari, Haoran Zhang, Matthew B. A. McDermott, Irene Y. Chen, and Marzyeh Ghassemi. Underdiagnosis bias of artificial intelligence algorithms applied to chest radiographs in under-served patient populations. Nature Medicine, 27:2176–2182, 2021.
- [2]Laleh Seyyed-Kalantari, Guanxiong Liu, Matthew McDermott, Irene Y. Chen, and Marzyeh Ghassemi. CheXclusion: Fairness gaps in deep chest X-ray classifiers. In Pacific Symposium on Biocomputing, volume 26, pages 232–243, 2021.
- [3]Judy Wawira Gichoya, Imon Banerjee, Ananth Reddy Bhimireddy, et al. AI recognition of patient race in medical imaging: a modelling study. The Lancet Digital Health, 4(6):e406–e414, 2022.DOI
- [4]Ben Glocker, Charles Jones, Mélanie Bernhardt, and Stefan Winzeck. Algorithmic encoding of protected characteristics in chest X-ray disease detection models. eBioMedicine, 89:104467, 2023.DOI
- [5]Reza Shokri, Marco Stronati, Congzheng Song, and Vitaly Shmatikov. Membership inference attacks against machine learning models. In IEEE Symposium on Security and Privacy (S&P), 2017.arxiv.org/abs/1610.05820
- [6]Nicholas Carlin, Steve Chien, Milad Nasr, Shuang Song, Andreas Terzis, and Florian Tramèr. Membership inference attacks from first principles. In IEEE Symposium on Security and Privacy (S&P), 2022. arXiv:2112.03570.
- [7]Moritz A. Knolle, Martin J. Menten, Friederike Jungmann, Felix Meissen, Ben Glocker, Daniel Rueckert, and Georgios Kaissis. Disparate privacy risks from medical AI. Nature, 656:192–198, 2026.DOI
- [8]Robert Geirhos, Jörn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias Bethge, and Felix A. Wichmann. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2:665–673, 2020.DOI
- [9]Yeonsu Kim, Yangwon Kim, Yoojin Nam, Namjoon Kim, and Pa Hong. Encoding versus linear use of patient characteristics in chest X-ray foundation models on MIMIC-CXR. Diagnostics, 16(13):2030, 2026.DOI
- [10]Filipe Santos, Aldo Marzullo, Alessandro Quarta, João M. C. Sousa, Susana M. Vieira, Leo Anthony Celi, Francesco Calimeri, and Laleh Seyyed-Kalantari. Persistent demographic information in X-ray foundation embeddings: a risk for a safe and fair deployment in healthcare. In ICML 2025 Workshop on Actionable Interpretability, 2025.
- [11]Hongyan Chang and Reza Shokri. On the privacy risks of algorithmic fairness. In IEEE European Symposium on Security and Privacy (EuroS&P), pages 292–303, 2021.arxiv.org/abs/2011.03731
- [12]Bogdan Kulynych, Mohammad Yaghini, Giovanni Cherubin, Michael Veale, and Carmela Troncoso. Disparate vulnerability to membership inference attacks. Proceedings on Privacy Enhancing Technologies, 2022(1):460–480, 2022.arxiv.org/abs/1906.00389
- [13]Umid Suleymanov, Ilhama Novruzova, Khalid Mammadov, Natavan Hasanova, and Murat Kantarcioglu. Auditing fairness-privacy trade-offs: Subpopulation-level effects of fairness-enhancing algorithms, 2026. arXiv:2607.14607.arxiv.org/abs/2607.14607
- [14]Soroosh Tayebi Arasteh, Alexander Ziller, Christiane Kuhl, et al. Preserving fairness and diagnostic accuracy in private large-scale AI models for medical imaging. Communications Medicine, 4:46, 2024.DOI
- [15]Salman Ul Hassan Dar et al. Unconditional latent diffusion models memorize patient imaging data. Nature Biomedical Engineering, 2025.
- [16]Santhosh Parampottupadam, Sinem Sav, Dimitrios Bounias, Saikat Roy, Klaus Maier-Hein, Adam Dziedzic, Franziska Boenisch, and Ralf Floa. Rare, distinctive, memorized: Auditing memorization in fine-tuned medical foundation models. In International Conference on Machine Learning (ICML), 2026.
- [17]Yuzhe Yang, Haoran Zhang, Judy W. Gichoya, Dina Katabi, and Marzyeh Ghassemi. The limits of fair medical imaging AI in real-world generalization. Nature Medicine, 30(10):2838–2848, 2024.DOI
- [18]Eike Petersen, Enzo Ferrante, Melanie Ganz, and Aasa Feragen. Are demographically invariant models and representations in medical imaging fair?, 2023. arXiv:2305.01397.arxiv.org/abs/2305.01397
- [19]Shauli Ravfogel, Yanai Elazar, Hila Gonen, Michael Twiton, and Yoav Goldberg. Null it out: Guarding protected attributes by iterative nullspace projection. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7237–7256, 2020.arxiv.org/abs/2004.07667
- [20]Nora Belrose, David Schneider-Joseph, Shauli Ravfogel, Ryan Cotterell, Edward Raff, and Stella Biderman. LEACE: Perfect linear concept erasure in closed form. In Advances in Neural Information Processing Systems, volume 36, 2023. arXiv:2306.03819.arxiv.org/abs/2306.03819
- [21]Jeremy Irvin, Pranav Rajpurkar, Michael Ko, et al. CheXpert: A large chest radiograph dataset with uncertainty labels and expert comparison. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 590–597, 2019.arxiv.org/abs/1901.07031
- [22]Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammad hadi Bagheri, and Ronald M. Summers. ChestX-Ray8: Hospital-scale chest X-ray database and benchmarks on weakly-supervised classification and localization of common thorax diseases. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 2097–2106, 2017.DOI
- [23]Sheng Zhang, Yanbo Xu, Naoto Usuyama, et al. BiomedCLIP: a multimodal biomedical foundation model pretrained from fifteen million scientific image-text pairs, 2023. arXiv:2303.00915.arxiv.org/abs/2303.00915
- [24]Maxime Oquab, Timothée Darcet, Théo Moutakanni, et al. DINOv2: Learning robust visual features without supervision, 2023. arXiv:2304.07193.
- [25]Fernando Pérez-García, Harshita Sharma, Sam Bond-Taylor, et al. Exploring scalable medical image encoders beyond text supervision. Nature Machine Intelligence, 2025.
- [26]Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019. arXiv:1711.05101.arxiv.org/abs/1711.05101
- [27]W. J. Youden. Index for rating diagnostic tests. Cancer, 3(1):32–35, 1950.pubmed.ncbi.nlm.nih.gov/15405679
- [28]Donald J. Schuirmann. A comparison of the two one-sided tests procedure and the power approach for assessing the equivalence of average bioavailability. Journal of Pharmacokinetics and Biopharmaceutics, 15(6):657–680, 1987.
- [29]Daniël Lakens. Equivalence tests: a practical primer for t tests, correlations, and meta-analyses. Social Psychological and Personality Science, 8(4):355–362, 2017.
- [30]Raajitha Muthyala, Zhenan Yin, Alekhya Jilla, Frank Li, Theo Dapamede, Bardia Khosravi, Mohammadreza Chavoshi, Judy Gichoya, and Saptarshi Purkayastha. Frozen foundation-model embeddings discard small-lesion signal in chest radiography: Implications for pre-deployment evaluation, 2026. arXiv:2606.11606.arxiv.org/abs/2606.11606
