Problem definition
This section formally defines algorithmic bias and fairness in AI recruitment systems. Let the recruitment dataset be
$$D=\{ ({x_i},{a_i},{y_i})\} _{{i=1}}^{n}$$
(1)
where \({x_i} \in \mathcal{X}\) represents the non-sensitive feature vector of the i-th candidate (such as educational background, work experience, skills, etc.), \({a_i} \in \mathcal{A}\) represents the sensitive attribute vector (such as gender, race, age, etc.), and \({y_i} \in \{ 0,1\}\) represents the true label, where \({y_i}=1\) indicates the candidate is suitable for the position. The AI recruitment system is modeled as a prediction function \(f:\mathcal{X} \times \mathcal{A} \to [0,1]\), outputting the probability \({\hat {y}_i}=f({x_i},{a_i})\) that a candidate will be hired.
Algorithmic bias refers to systematic unfair treatment by the prediction function toward candidates with different sensitive attributes. We categorize bias into three types: Direct bias occurs when prediction results directly depend on sensitive attributes, formally defined as
$$\exists a,a^{\prime} \in \mathcal{A},x \in \mathcal{X}:f(x,a) \ne f(x,a^{\prime})$$
(2)
Indirect bias indirectly depends on sensitive attributes through proxy variables highly correlated with sensitive attributes, defined as
$$\frac{{\partial f(x,a)}}{{\partial {x_j}}} \cdot \frac{{\partial {x_j}}}{{\partial {a_k}}} \ne 0$$
(3)
Intersectional bias is generated by the interaction of multiple sensitive attributes, defined for sensitive attribute combinations \({a^{(1)}},{a^{(2)}}\) as
$${\mathbb{E}}[\hat {y}|{a^{(1)}}={v_1},{a^{(2)}}={v_2}] \ne {\mathbb{E}}[\hat {y}|{a^{(1)}}={v_1}]+{\mathbb{E}}[\hat {y}|{a^{(2)}}={v_2}] – {\mathbb{E}}[\hat {y}]$$
(4)
For different fairness concepts, we define corresponding mathematical constraints. Group fairness constraints include: demographic parity \(P(\hat {y}=1|a=0)=P(\hat {y}=1|a=1)\), equal opportunity \(P(\hat {y}=1|y=1,a=0)=P(\hat {y}=1|y=1,a=1)\), and predictive rate parity \(P(y=1|\hat {y}=1,a=0)=P(y=1|\hat {y}=1,a=1)\). Individual fairness constraint requires that for similarity functions \({d_\mathcal{X}}\) and \({d_\mathcal{Y}}\), the condition
$${d_\mathcal{X}}({x_i},{x_j}) \leqslant \delta \Rightarrow {d_\mathcal{Y}}(f({x_i},{a_i}),f({x_j},{a_j})) \leqslant \epsilon$$
(5)
is satisfied, meaning similar candidates should receive similar prediction results. Causal fairness constraint, based on counterfactual reasoning, requires that changing sensitive attributes should not affect prediction results:
$$f(x,a)=f(x,do(a \leftarrow a^{\prime}))$$
(6)
where \(do( \cdot )\) represents the causal intervention operation.
Given a recruitment dataset D and prediction function f, the bias detection problem is formalized into four sub-problems: first, bias existence detection, determining whether bias exists; second, bias type identification, determining the bias type and involved sensitive attributes; third, bias degree quantification, quantifying the severity of bias by defining a bias measure function \(B(f,D,a)\); fourth, bias source localization, identifying key features and decision paths that lead to bias by finding a feature subset \(S \subseteq \mathcal{X}\) such that \(B(f{|_{x \in S}},D,a) \approx B(f,D,a)\). The framework proposed in this paper aims to simultaneously address the above four problems, achieving comprehensive bias detection and fairness assessment for AI recruitment systems.
Overall framework architecture
The proposed algorithmic bias detection framework adopts an end-to-end deep learning architecture that integrates three core modules: multi-task adversarial learning, multi-dimensional fairness assessment, and interpretability analysis, as illustrated in Fig. 1. The design philosophy of this framework is to learn fair representations decoupled from sensitive attributes through adversarial training mechanisms, while establishing a comprehensive fairness quantification system and providing interpretable analysis of bias sources. As shown in Fig. 1, the core of the framework is the multi-task adversarial learning architecture. The input layer receives the non-sensitive feature vector X and sensitive attributes S of candidates, which are processed through a feature encoder for representation learning to obtain low-dimensional hidden representations. An attention mechanism is introduced to dynamically adjust the importance weights of different features, enabling the model to adaptively focus on features relevant to hiring decisions but independent of sensitive attributes. The hidden representation is simultaneously fed into two task branches: the prediction task branch learns the prediction function for hiring decisions and outputs the hiring probability of candidates; the adversarial discriminator branch attempts to predict sensitive attributes from the hidden representation. By designing an adversarial loss function, the feature encoder learns representations that effectively support hiring predictions while being difficult for the adversarial discriminator to use for inferring sensitive attributes, thereby achieving fairness in representation. The multi-task loss function integrates prediction loss and adversarial loss, gradient backpropagation learning the entire network, and establishes a feedback loop for recursive model fairness improvement. The fairness evaluation module conducts comprehensive evaluation from three perspectives—group fairness, individual fairness, and causal fairness—based on learned fair representations and prediction outputs. This module integrates nine fairness metrics like demographic parity, equal opportunity, and predictive rate parity, and introduces Pareto frontier analysis methodologies to systematically reveal the trade-off relationships among different fairness metrics, providing quantitative basis for fairness optimization in practical applications. The interpretability analysis module integrates multiple methods like SHAP value analysis, gradient-weighted class activation mapping, and causal mediation analysis to construct a multi-level interpretation framework from feature-level to decision-level. This module not only indicates crucial properties that cause bias but also charts the trajectory of bias propagation within the model precisely identifying bias sources. The entire detection process is divided into five phases: first, preprocessing candidate recruitment data in terms of data cleaning, missing value handling, and normalization; second, feature extraction of candidates with multi-dimensionality like education background, work experience, and skill assessment; third, learning adversarially fair feature representations; fourth, comprehensive system assessment utilizing the multi-dimensionality fairness assessment module; and finally, delivery of overall results in terms of bias detection reports, fairness scores, interpretability analysis, and improvement suggestions. By combining the powerful representation capability of deep learning, the debiasing capability of adversarial training, and multi-dimensional fairness assessment, this framework achieves accurate detection and systematic evaluation of algorithmic bias in AI recruitment systems.
Fig. 1
Overall architecture of the bias detection framework.
Deep learning bias detection model
This section presents the network architecture, loss function design, and training algorithm of the proposed deep learning bias detection model. Through a multi-task adversarial learning mechanism, the model learns fair representations decoupled from sensitive attributes while maintaining hiring prediction accuracy.
Fig. 2
Deep learning bias detection network structure.
As illustrated in Fig. 2, the deep learning bias detection network consists of four core components: feature encoder, attention mechanism, predictor, and adversarial discriminator. The feature encoder employs a multi-layer fully connected neural network to map input high-dimensional feature vectors \({\mathbf{x}} \in {{\mathbb{R}}^n}\) and sensitive attributes \({\mathbf{s}} \in {{\mathbb{R}}^m}\) to a low-dimensional hidden representation space. The first encoding layer is mathematically expressed as
$${{\mathbf{h}}_1}={\text{ReLU}}({{\mathbf{W}}_1}[{\mathbf{x}};{\mathbf{s}}]+{{\mathbf{b}}_1})$$
(7)
where \([{\mathbf{x}};{\mathbf{s}}]\) denotes feature concatenation, \({{\mathbf{W}}_1} \in {{\mathbb{R}}^{{d_1} \times (n+m)}}\) is the weight matrix, \({{\mathbf{b}}_1} \in {{\mathbb{R}}^{{d_1}}}\) is the bias vector, and \({\text{ReLU}}( \cdot )\) is the activation function. The second layer further extracts abstract features, represented as
$${{\mathbf{h}}_2}={\text{ReLU}}({{\mathbf{W}}_2}{{\mathbf{h}}_1}+{{\mathbf{b}}_2})$$
(8)
where \({{\mathbf{W}}_2} \in {{\mathbb{R}}^{{d_2} \times {d_1}}}\) and \({{\mathbf{b}}_2} \in {{\mathbb{R}}^{{d_2}}}\).
To enhance the model’s representation capability and interpretability, a self-attention mechanism is introduced to dynamically adjust the importance of different feature dimensions. The attention weights are computed through the softmax function:
$${\mathbf{\alpha }}={\text{softmax}}({{\mathbf{W}}_a}{{\mathbf{h}}_2}+{{\mathbf{b}}_a})$$
(9)
where \({{\mathbf{W}}_a} \in {{\mathbb{R}}^{{d_2} \times {d_2}}}\), \({\mathbf{\alpha }} \in {{\mathbb{R}}^{{d_2}}}\) and satisfies \(\sum\limits_{{i=1}}^{{{d_2}}} {{\alpha _i}} =1\). The weighted representation layer output is
$${\mathbf{z}}={\mathbf{\alpha }} \odot {{\mathbf{h}}_2}$$
(10)
where \(\odot\) denotes element-wise multiplication, and \({\mathbf{z}} \in {{\mathbb{R}}^{{d_2}}}\) is the learned fair representation vector.
The prediction branch of the network maps the fair representation to hiring decisions, outputting the probability of a candidate being hired:
$$\hat {y}=\sigma ({\mathbf{w}}_{p}^{T}{\mathbf{z}}+{b_p})$$
(11)
where \(\sigma ( \cdot )\) is the sigmoid activation function, \({{\mathbf{w}}_p} \in {{\mathbb{R}}^{{d_2}}}\), and \({b_p} \in {\mathbb{R}}\). The prediction loss employs the binary cross-entropy function:
$${\mathcal{L}_{{\text{pred}}}}= – \frac{1}{N}\sum\limits_{{i=1}}^{N} {\left[ {{y_i}\log {{\hat {y}}_i}+(1 – {y_i})\log (1 – {{\hat {y}}_i})} \right]}$$
(12)
where N is the batch size and \({y_i}\) is the true label.
The adversarial discriminator branch attempts to predict sensitive attributes from the fair representation \({\mathbf{z}}\), with output \(\widehat {{\mathbf{s}}}=\sigma ({{\mathbf{W}}_d}{\mathbf{z}}+{{\mathbf{b}}_d})\), where \({{\mathbf{W}}_d} \in {{\mathbb{R}}^{m \times {d_2}}}\) and \({{\mathbf{b}}_d} \in {{\mathbb{R}}^m}\). The adversarial loss also adopts the cross-entropy form:
$${\mathcal{L}_{{\text{adv}}}}= – \frac{1}{N}\sum\limits_{{i=1}}^{N} {\sum\limits_{{j=1}}^{m} {\left[ {{s_{ij}}\log {{\hat {s}}_{ij}}+(1 – {s_{ij}})\log (1 – {{\hat {s}}_{ij}})} \right]} }$$
(13)
Through adversarial training, the representation learned by the feature encoder must satisfy two conflicting objectives: on one hand, it must retain sufficient information to support accurate hiring predictions; on the other hand, it must obfuscate sensitive attribute information so that the discriminator cannot accurately infer them. To prevent overfitting, an L2 regularization term \({\mathcal{L}}_{{{\text{reg}}}} = \frac{\gamma }{2}\left\| {{\mathbf{\theta }}_{e} } \right\|^{2}\) is introduced, where \({{\mathbf{\theta }}_e}\) represents all parameters of the encoder and \(\gamma\) is the regularization coefficient.
The overall loss function of the model is designed as a multi-objective optimization form:
$${\mathcal{L}_{{\text{total}}}}={\mathcal{L}_{{\text{pred}}}} – \lambda {\mathcal{L}_{{\text{adv}}}}+\beta {\mathcal{L}_{{\text{reg}}}}$$
(14)
where \(\lambda >0\) is the adversarial weight controlling the degree of debiasing, and \(\beta >0\) is the regularization weight. The negative sign before the adversarial loss is a critical design: by minimizing \({\mathcal{L}_{{\text{total}}}}\), the feature encoder minimizes the prediction loss while maximizing the adversarial loss, thereby learning representations that are difficult for the discriminator to identify sensitive attributes from. The discriminator, on the other hand, improves its ability to predict sensitive attributes by minimizing \({\mathcal{L}_{{\text{adv}}}}\), forming an adversarial game.
As shown in Fig. 3, the algorithm training process adopts an alternating optimization strategy. In each training batch, the discriminator parameters are first fixed while updating the encoder and predictor parameters to minimize \({\mathcal{L}_{{\text{total}}}}\); then the encoder parameters are fixed while updating the discriminator parameters to minimize \({\mathcal{L}_{{\text{adv}}}}\). Specifically, the parameter update rules for the encoder and predictor are:
$${{\mathbf{\theta }}_e} \leftarrow {{\mathbf{\theta }}_e} – \eta {\nabla _{{{\mathbf{\theta }}_e}}}{\mathcal{L}_{{\text{total}}}},\quad {{\mathbf{\theta }}_p} \leftarrow {{\mathbf{\theta }}_p} – \eta {\nabla _{{{\mathbf{\theta }}_p}}}{\mathcal{L}_{{\text{total}}}}$$
(15)
The discriminator parameter update is:
$${{\mathbf{\theta }}_d} \leftarrow {{\mathbf{\theta }}_d} – \eta {\nabla _{{{\mathbf{\theta }}_d}}}{\mathcal{L}_{{\text{adv}}}}$$
(16)
where \(\eta\) is the learning rate and \(\nabla\) denotes the gradient operator. Training employs the Adam optimizer with momentum parameters \({\beta _1}=0.9\) and \({\beta _2}=0.999\). To improve training stability, gradient clipping is applied to limit the gradient norm within a threshold of \(\tau =1.0\).
An early stopping mechanism is implemented during training, halting the process when fairness metrics on the validation set fail to improve for \(k=10\) consecutive epochs, thus avoiding overfitting. The final model is selected from the checkpoint with optimal comprehensive performance on the validation set. Through such an adversarial learning architecture, the model can reduce overdependence on sensitive features with satisfactory prediction performance and hence achieve algorithmic fairness. Coupling the attention mechanism improves model interpretability even further, such that quantification and visualization can be conducted regarding the importance of salient features, providing a foundation for subsequent bias source localization.
Fig. 3
Bias detection algorithm training flow.
Multi-dimensional fairness evaluation metrics
Balance evaluation is the core of unfairness identification of algorithms. In this paper, a systematic multi-dimension evaluation measurement system with three dimensions, namely group fairness, individual fairness and causal fairness, consisting of 9 prominent indicators, is established as shown in Table 1. This metric system can comprehensively quantify the fairness performance of AI recruitment systems from different perspectives, providing precise quantitative basis for system optimization. The fairness thresholds in Table 1 are established based on widely accepted standards in the fairness literature and regulatory practice. The threshold DP ≤ 0.1 (10% difference) for demographic parity, equal opportunity, and predictive rate parity follows conventions in algorithmic fairness research, representing a commonly adopted tolerance level for group-level disparities. The disparate impact threshold 0.8 ≤ DI ≤ 1.25 is directly derived from the “80% rule” established by the U.S. Equal Employment Opportunity Commission (EEOC) in the Uniform Guidelines on Employee Selection Procedures,
which stipulates that a selection rate less than 80% of the highest group’s rate may indicate adverse impact. For individual fairness, the consistency threshold Con ≥ 0.9 follows common practice in k-nearest neighbor analysis10. The counterfactual fairness threshold CF ≥ 0.95 is based on causal inference literature requiring high consistency between factual and counterfactual outcomes11. While these thresholds provide general guidelines, organizations should calibrate them according to their specific legal requirements, industry norms, and stakeholder values.
Table 1 Multi-dimensional fairness evaluation metrics definition.
Group fairness metrics evaluate treatment disparities between different groups from a statistical perspective. Demographic parity requires that different sensitive attribute groups have equal probabilities of receiving positive predictions. The deviation measure \({\text{DP}}\) is obtained by calculating the absolute difference between the two group selection rates, and demographic parity is considered satisfied when \({\text{DP}} \leqslant 0.1\). Equal opportunity focuses on truly qualified candidates, requiring that the true positive rate remains consistent across different groups, i.e., \(P(\hat {Y}=1|Y=1,S=0) \approx P(\hat {Y}=1|Y=1,S=1)\). Predictive rate parity approaches from the perspective of precision, requiring that among candidates predicted as qualified, the proportion of truly qualified individuals should be equal across different groups. Disparate impact adopts a ratio format, with the U.S. Equal Employment Opportunity Commission stipulating that discrimination may exist when \({\text{DI}}<0.8\).
Individual fairness metrics focus on fairness between similar individuals, compensating for the inability of group fairness to capture individual differences. Individual fairness requires that candidates with similar features should receive similar prediction results, quantified by calculating the ratio of prediction differences to feature distances. The distance function \(d({x_i},{x_j})\) can adopt Euclidean distance or Mahalanobis distance. The consistency metric evaluates from the perspective of k-nearest neighbors, calculating for each sample the proportion of its k nearest neighbors whose prediction results differ from its own. A higher value of this metric indicates more consistent predictions by the model for similar samples. In practical applications, \(k=5\) or \(k=10\) is typically set, with a requirement of \({\text{Con}} \geqslant 0.9\).
Causal fairness metrics are based on causal inference theory, analyzing the impact of sensitive attributes on prediction results from a causal mechanism perspective. Counterfactual fairness adopts Pearl’s causal model, evaluating through counterfactual reasoning: whether the prediction result would change if a candidate’s sensitive attribute were different. In specific calculations, for each sample, a counterfactual sample is constructed (changing only the sensitive attribute while keeping other features constant), comparing the prediction results of the original sample with the counterfactual sample. Counterfactual fairness is considered satisfied when the probability of consistency between the two is \({\text{CF}} \geqslant 0.95\). Path-specific effect decomposes the direct and indirect effects of sensitive attributes on outcomes, where \(M(s)\) represents the mediator variable value when the sensitive attribute is s. This metric quantifies the intensity of bias propagated through specific causal paths. Total effect measures the overall causal influence of sensitive attribute changes on prediction results, which should ideally approach zero.
To comprehensively evaluate system fairness, this paper adopts a weighted combination approach to construct a comprehensive fairness score. The weights for the three dimensions are set as \({w_g}=0.4\), \({w_i}=0.3\), and \({w_c}=0.3\), respectively, and the comprehensive score is calculated as:
$${\text{Fairness Score}}={w_g} \cdot {F_g}+{w_i} \cdot {F_i}+{w_c} \cdot {F_c}$$
(17)
where \({F_g}\), \({F_i}\), and \({F_c}\) represent the normalized scores for group fairness, individual fairness, and causal fairness, respectively, obtained by transforming the metrics of each dimension to the [0,1] interval and taking the average. The weights (\({w_g}=0.4\), \({w_i}=0.3\), \({w_c}=0.3\)) represent a balanced baseline for research purposes, but should be adjusted in practice according to organizational priorities and legal requirements—for example, jurisdictions emphasizing anti-discrimination compliance may assign higher weight to group fairness metrics. A higher comprehensive score indicates better overall system fairness. Additionally, the Pareto frontier analysis method is introduced to visualize the trade-off relationships between different fairness metrics, identify the optimal solution set in multi-objective optimization, and provide decision support for the fairness-accuracy balance in practical applications.