SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Changho Shin, Sonia Cromp, Dyah Adila, Frederic Sala
{cshin23, cromp, adila, fsala}@wisc.edu
Weak supervision enables efficient development of training sets by reducing the need for ground truth labels. However, the techniques that make weak supervision attractive—such as integrating any source of signal to estimate unknown labels—also entail the danger that the produced pseudolabels are highly biased. Surprisingly, given everyday use and the potential for increased bias, weak supervision has not been studied from the point of view of fairness. We begin such a study, starting with the observation that even when a fair model can be built from a dataset with access to ground-truth labels, the corresponding dataset labeled via weak supervision can be arbitrarily unfair. To address this, we propose and empirically validate a model for source unfairness in weak supervision, then introduce a simple counterfactual fairness-based technique that can mitigate these biases. Theoretically, we show that it is possible for our approach to simultaneously improve both accuracy and fairness—in contrast to standard fairness approaches that suffer from tradeoffs. Empirically, we show that our technique improves accuracy on weak supervision baselines by as much as  $32\%$  while reducing demographic parity gap by  $82.5\%$ . A simple extension of our method aimed at maximizing performance produces state-of-the-art performance in five out of ten datasets in the WRENCH benchmark.
Weak supervision (WS) is a powerful set of techniques aimed at overcoming the labeled data bottleneck  $\left[\mathrm{RSW}^{+}16, \mathrm{FCS}^{+}20, \mathrm{SLV}^{+}22\right]$ . Instead of manually annotating points, users assemble noisy label estimates obtained from multiple sources, model them by learning source accuracies, and combine them into a high-quality pseudolabel to be used for downstream training. All of this is done without any ground truth labels. Simple, flexible, yet powerful, weak supervision is now a standard component in machine learning workflows in industry, academia, and beyond  $\left[\mathrm{BRL}^{+}19\right]$ . Most excitingly, WS has been used to build models deployed to billions of devices.
Real-life deployment of models, however, raises crucial questions of fairness and bias. Such questions are tackled in the burgeoning field of fair machine learning [DHP+12, HPS16]. However, weak supervision has not been studied from this point of view. This is not a minor oversight. The properties that make weak supervision effective (i.e., omnivorously ingesting any source of signal for labels) are precisely those that make it likely to suffer from harmful biases. This motivates the need to understand and mitigate the potentially disparate outcomes that result from using weak supervision.
The starting point for this work is a simple result. Even when perfectly fair classifiers are possible when trained on ground-truth labels, weak supervision-based techniques can nevertheless produce arbitrarily unfair outcomes. Because of this, simply applying existing techniques for producing fair outcomes to the datasets produced via WS is insufficient—delivering highly suboptimal datasets. Instead, a new approach, specific to weak supervision, must be developed. We introduce a simple technique for improving the fairness properties of weak supervision-based models. Intuitively, a major cause of bias
(b) Transformations
Figure 1: Intuitive illustration for our setting and approach. (a): circles and diamonds are data points from group 0 and 1, respectively. The accuracy of labeling function is colored-coded, with blue being perfect (1.0) and red random (0.5). Note that accuracy degrades as data points get farther from center  $x^{center}$  (star). (b) We can think of group 1 as having been moved far from the center by a transformation  $g$ , producing lower-quality estimates and violating fairness downstream. (c) Our technique uses counterfactual fairness to undo this transformation, obtaining higher quality estimates. and improved fairness.
(c) Recovered labels
in WS is that particular sources are targeted at certain groups, and so produce far more accurate label estimates for these groups—and far more noise for others. We counterfactually ask what outgroup points would most be like if they were part of the 'privileged' group (with respect to each source), enabling us to borrow from the more powerful signal in the sources applied to this group. Thus, the problem is reduced to finding a transformation between groups that satisfies this counterfactual. Most excitingly, while in standard fairness approaches there is a typical tradeoff between fairness and accuracy, with our approach, both the fairness and performance of WS-based techniques can be (sometimes dramatically) improved.
Theoretically, in certain settings, we provide finite-sample rates to recover the counterfactual transformation. Empirically, we propose several ways to craft an efficiently-computed transformation building on optimal transport and some simple variations. We validate our claims on a diverse set of experiments. These include standard real-world fairness datasets, where we observe that our method can improve both fairness and accuracy by as much as  $82.5\%$  and  $32.5\%$ , respectively, versus weak supervision baselines. Our method can also be combined with other fair ML methods developed for fully supervised settings, further improving fairness. Finally, our approach has implications for WS beyond bias: we combined it with slice discovery techniques  $\left[\mathrm{EVS}^{+}22\right]$  to improve latent underperforming groups. This enabled us to improve on state-of-the-art on the weak supervision benchmark WRENCH  $\left[\mathrm{ZYL}^{+}21\right]$ .
The contributions of this work include,
- The first study of fairness in weak supervision,
- A new empirically-validated model for weak supervision that captures labeling function bias,
- A simple counterfactual fairness-based correction to mitigate such bias, compatible with any existing weak supervision pipeline, as well as with downstream fairness techniques,
- Theoretical results showing that (1) even with a fair dataset, a weakly-supervised counterpart can be arbitrarily biased and (2) a finite-sample recovery result for the proposed algorithm,
- Experiments validating our claims, including on weakly-supervised forms of popular fairness evaluation datasets, showing gains in fairness metrics—and often simultaneously improvements in accuracy.
We present some high-level background on weak supervision and fairness in machine learning. Afterward, we provide setup and present the problem statement.
Weak Supervision Weak supervision frameworks build labeled training sets with no access to ground truth labels. Instead, they exploit multiple sources that provide noisy estimates of the label. These sources include heuristic rules, knowledge base lookups, pretrained models, and more [KOS11, MBSJ09, GM14, DZS+17, RBE+18]. Because these sources may have different—and unknown—accuracies and dependencies, their outputs must be modeled in order to produce a combination that can be used as a high-quality pseudolabel.
Concretely, there is a dataset  $\{(x_1,y_1),\dots,(x_n,y_n)\}$  with unobserved true label  $y_{i}\in \{-1, + 1\}$ . We can access the outputs of  $m$  sources (labeling functions)  $\lambda^1,\lambda^2,\ldots ,\lambda^m:\mathcal{X}\to \{-1, + 1\}$ . These outputs are modeled via a generative model called the label model,  $p_{\theta}(\lambda^{1},\dots,\lambda^{m},y)$ . The goal is to estimate the parameters  $\theta$  of this model, without accessing the latent  $y$ , and to produce a pseudolabel estimate  $p_{\hat{\theta}}(y|\lambda^1,\dots,\lambda^m)$ . For more background, see [ZHY+22].
Machine Learning and Fairness Fairness in machine learning is a large and active field that seeks to understand and mitigate biases. We briefly introduce high-level notions that will be useful in the weak supervision setting, such as the notion of fairness metrics. Two popular choices are demographic parity  $\left[\mathrm{DHP}^{+}12\right]$  and equal opportunity [HPS16]. Demographic parity is based on the notion that individuals of different groups should have equal treatment, i.e., if  $A$  is the group attribute,  $P(\hat{Y} = 1|A = 1) = P(\hat{Y} = 1|A = 0)$ . The equal opportunity principle requires that predictive error should be equal across groups, i.e.,  $P(\hat{Y} = 1|Y = 1,A = 1) = P(\hat{Y} = 1|Y = 1,A = 0)$ . A large number of works study, measure, and seek to improve fairness in different machine learning settings based on these metrics. Typically, the assumption is that the underlying dataset differs within groups in such a way that a trained model will violate, for example, the equal opportunity principle. In contrast, in this work, we focus on additional violations of fairness that are induced by weak supervision pipelines—which can create substantial unfairness even when the true dataset is perfectly fair. In the same spirit, [WH22] considers fairness in positive-and-unlabeled (PU) settings, where true labels are available, but only for one class, while other points are unlabeled. Another related line of research is fairness under noisy labels [WLL21, KL22, WZN+23, ZZL+23]. These works consider the noise rate of labels in fair learning, enhancing the robustness of fair learning methods. A crucial difference between such works and ours: in weak supervision, we have multiple sources of noisy labels—and we can exploit these to directly improve dataset fairness.
Counterfactual Fairness Most closely related to the notion of fairness we use in this work is counterfactual fairness. [KLRS17] introduced such a counterfactual fairness notion, which implies that changing the sensitive attribute  $A$ , while keeping other variables causally not dependent on  $A$ , should not affect the outcome. While this notion presumes the causal structure behind the ML task, it is related to our work in the sense that our proposed method tries to remove the causal effect by  $A$  with particular transformations. A more recent line of work has proposed bypassing the need for causal structures and directly tackling counterfactual fairness through optimal transport [GDBFL19, BYF20, SRT+20, SMBN21, BDB22]. The idea is to detect or mitigate unfairness by mapping one group to another group via such techniques. In this paper, we build on these tools to help improve fairness while avoiding the accuracy-fairness tradeoff common to most settings.
3 Mitigating Labeling Function-Induced Unfairness
We are ready to explain our approach to mitigating unfairness in weak supervision sources. First, we provide a flexible model that captures such behavior, along with empirical evidence supporting it. Next, we propose a simple solution to correct unfair source behavior via optimal transport.
Modeling Group Bias in Weak Supervision Weak supervision models the accuracies and correlations in labeling functions. The standard model, used in  $\mathrm{[RHD^{+}19a,FCS^{+}20]}$  and others is  $P(\lambda^1,\dots,\lambda^m,y) = \frac{1}{Z}\exp (\theta_yy + \sum_{j = 1}^m\theta_j\lambda^j y)$ , with  $\theta_{j}\geq 0$ . We leave out the correlations for simplicity; all of our discussion below holds when considering correlations as well. Here,  $Z$  is the normalizing partition function. The  $\theta$  are canonical parameters for the model.  $\theta_{y}$  sets the class balance. The  $\theta_{i}$ 's capture how accurate labeling function (LF)  $i$  is: if  $\theta_{i} = 0$ , the LF produces random guesses. If  $\theta_{i}$  is relatively large, the LF is highly accurate. A weakness of this model is that it ignores the feature vector  $x$ . It implies that LFs are uniformly accurate over the feature space—a highly unrealistic assumption. A more general model was presented in  $\mathrm{[CFA^{+}22]}$ , where there is a model for each feature vector  $x$ , i.e.,
$$
P _ {x} \left(\lambda^ {1}, \dots , \lambda^ {m}, y\right) = \frac {1}{Z} \exp \left(\theta_ {y} y + \sum_ {j = 1} ^ {m} \theta_ {j, x} \lambda^ {j} (x) y\right). \tag {1}
$$
However, as we see only one sample for each  $x$ , it is impossible to recover the parameters  $\theta_{x}$ . Instead, the authors assume a notion of smoothness. This means that the  $\theta_{j,x}$ 's do not vary in small neighborhoods, so that the feature space can be partitioned and a single model learned per part. Thus
model (1) from  $[CFA^{+}22]$  is more general, but still requires a strong smoothness assumption. It also does not encode any notion of bias. Instead, we propose a model that encodes both smoothness and bias.
Concretely, assume that the data are drawn from some distribution on  $\mathcal{Z} \times \mathcal{Y}$ , where  $\mathcal{Z}$  is a latent space. We do not observe samples from  $\mathcal{Z}$ . Instead, there are  $l$  transformations functions  $g_1, \ldots, g_l$ , where  $g_k: \mathcal{Z} \to \mathcal{X}$ . For each point  $z_i$ , there is an assigned group  $k$  and we observe  $x_i = g_k(z_i)$ . Then, our model is the following:
$$
P \left(\lambda^ {1} (z), \dots , \lambda^ {m} (z), y\right) = \frac {1}{Z} \exp \left(\theta_ {y} y + \sum_ {j = 1} ^ {m} \frac {\theta_ {j}}{1 + d \left(x ^ {\text {c e n t e r} _ {j}} , g _ {k} (z)\right)} \lambda^ {j} \left(g _ {k} (z)\right) y\right). \tag {2}
$$
We explain this model as follows. We can think of it as a particular version of (1). However, instead of arbitrary  $\theta_{j,x}$  parameters for each  $x$ , we explicitly model these parameters as two components: a feature-independent accuracy parameter  $\theta_{j}$  and a term that modulates the accuracy based on the distance between feature vector  $x$  and some fixed center  $x^{\mathrm{center}_j}$ . The center represents, for each LF, a most accurate point, where accuracy is maximized at a level set by  $\theta_{j}$ . As the feature vector  $x = g_{k}(z)$  moves away from this center, the denominator  $1 + d(x^{\mathrm{center}_j},g_k(z))$  increases, and the LF votes increasingly poorly. This is an explicit form of smoothness that we validate empirically below.
For simplicity, we assume that there are two groups, indexed by  $0,1$ , that  $\mathcal{X} = \mathcal{Z}$ , and that  $g_0(z) = z$ . In other words, the transformation for group 0 is the identity, while this may not be the case for group 1. Simple extensions of our approach can handle cases where none of these assumptions are met.
Labeling Function Bias The model (2) explains how and when labeling functions might be biased. Suppose that  $g_{k}$  takes points  $z$  far from  $x^{\text{center}_j}$ . Then, the denominator term in (2) grows—and so the penalty for  $\lambda(x)$  to disagree with  $y$  is reduced, making the labeling function less accurate. This is common in practice. For example, consider a situation where a bank uses features that include credit scores for loan review. Suppose that the group variable is the applicant's nationality. Immigrants typically have a shorter period to build credit; this is reflected in a transformed distribution  $g_{1}(z)$ . A labeling function using a credit score threshold may be accurate for non-immigrants, but may end up being highly inaccurate when applied to immigrants.
Figure 2: Average accuracy (y-axis) depending on the distance to the center point (x-axis). The center is obtained by evaluating the accuracy of their neighborhood data points.
We validate this notion empirically. We used the Adult dataset  $\left[\mathrm{K}^{+}96\right]$ , commonly used for fairness studies, with a set of custom-built labeling functions. In Figure 2, we track the accuracies of these LFs as a function of distance from an empirically-discovered center  $x^{\text {center } j}$ . On the left is the high-accuracy group in each labeling function; as expected in our model, as the distance from the center  $\| x - x^{\text {center } j} \|$  is increased, the accuracy decreases. On the right-hand side, we see the lower-accuracy group, whose labeling functions are voting  $x_{i} = g_{1}(z_{i})$ . This transformation has sent these points further away from the center (note the larger distances). As a result, the overall accuracies have also decreased. Note, for example, how LF 5, in purple, varies between 0.9 and 1.0 accuracy in one group and is much worse—between 0.6 and 0.7—in the other.
3.1 Correcting Unfair LFs
Given the model (2), how can we reduce the bias induced by the  $g_{k}$  functions? A simple idea is to reverse the effect of the  $g_{k}$ 's. If we could invert these functions, violations of fairness would be mitigated, since the accuracies of labeling functions would be uniformized over the groups.
Concretely, suppose that  $g_{k}$  is invertible and that  $h_k$  is this inverse. If we knew  $h_k$ , then we could ask the labeling functions to vote on  $h_k(x) = h_k(g_k(x)) = z$ , rather than on  $x = g_k(z)$ , and we could do so for any group, yielding equal-accuracy estimates for all groups. The technical challenge is how to estimate the inverses of the  $g_{k}$ 's, without any parametric form for these functions. To do so, we deploy optimal transport (OT) [PC+19]. OT transports a probability distribution to another probability
Algorithm 1: SOURCE BIAS MITIGATION (SBM)
1: Parameters: Features  $X_0, X_1$  and LF outputs  $\Lambda_0 = [\lambda_0^1, \dots, \lambda_0^m]$ ,  $\Lambda_1 = [\lambda_1^1, \dots, \lambda_1^m]$  for groups 0, 1, transport threshold  $\varepsilon$ 
2: Returns: Modified weak labels  $\Lambda = [\lambda^1, \dots, \lambda^m]$ 
3: Estimate accuracy of  $\lambda^j$  in each group,  $\hat{a}_0^j = \hat{\mathbb{E}}[\lambda_j Y | A = 0], \hat{a}_1^j = \hat{\mathbb{E}}[\lambda_j Y | A = 1]$  from  $\Lambda_0, \Lambda_1$  with Algorithm 2
4: for  $j \in \{1, 2, \dots, m\}$  do
5: if  $\hat{a}_1^j \geq \hat{a}_0^j + \varepsilon$  then update  $\lambda_0^j$  by transporting  $X_0$  to  $X_1$  (Algorithm 3)
6: else if  $\hat{a}_0^j \geq \hat{a}_1^j + \varepsilon$  then update  $\lambda_1^j$  by transporting  $X_1$  to  $X_0$  (Algorithm 3)
7: end for
8: return  $\Lambda = [\lambda^1, \dots, \lambda^m]$
distribution by finding a minimal cost coupling. We use OT to recover the reverse map  $h_k: \mathcal{X} \to \mathcal{Z}$  by  $\hat{h}_k = \operatorname{arginf}_{T_\sharp \nu = \omega} \left\{ \int_{x \in \mathcal{X}} c(x, T(x)) d\nu(x) \right\}$ , where  $c$  is a cost function,  $\nu$  is a probability measure in  $\mathcal{X}$  and  $\omega$  is a probability measure in  $\mathcal{Z}$ .
Our proposed approach, building on the use of OT, is called source bias mitigation (SBM). It seeks to reverse the group transformation  $g_{k}$  via OT. The core routine is described in Algorithm 1. The first step of the algorithm is to estimate the accuracies of each group so that we can identify which group is privileged, i.e., which of the transformations  $g_{0}, g_{1}$  is the identity map. To do this, we use Algorithm 2 [FCS+20] by applying it to each group separately.
After identifying the high-accuracy group, we transport data points from the low-accuracy group to it. Since not every transported point perfectly matches an existing high-accuracy group point, we find a nearest neighbor and borrow its label. We do this only when there is a sufficient inter-group accuracy gap, since the error in transport might otherwise offset the benefit. In practice, if the transformation is sufficiently weak, it is possible to skip optimal transport and simply use nearest neighbors. Doing this turned out to be effective in some experiments (Section 5.1). Finally, after running SBM, modified weak labels are used in a standard weak supervision pipeline, which is described in Appendix C.
We provide two types of theoretical results. First, we show that labeling function bias can be arbitrarily bad—resulting in substantial unfairness—regardless of whether the underlying dataset is fair. Next, we show that in certain settings, we can consistently recover the fair labeling function performance when using Algorithm 1, and provide a finite-sample error guarantee. Finally, we comment on extensions. All proofs are located in Appendix D.
Setting and Assumptions We assume that the distributions  $P_0(x)$  and  $P_{1}(x^{\prime})$  are subgaussian with means  $\mu_0$  and  $\mu_{1}$  and positive-definite covariance matrices  $\Sigma_0$  and  $\Sigma_{1}$ , respectively. Note that by assumption,  $P_0(x) = P(z)$  and  $P_{1}(x^{\prime})$  is the pushforward of  $P_0(x)$  under  $g_{1}$ . Let  $\mathbf{r}(\Sigma)$  denote the effective rank of  $\Sigma$  [Ver18]. We observe  $n_0$  and  $n_1$  i.i.d. samples from groups 0 and 1, respectively. We use Euclidean distance as the distance  $d(x,y) = \| x - y\|$  in model (2). For the unobserved ground truth labels,  $y_{i}$  is drawn from some distribution  $P(y|z)$ . Finally, the labeling functions voting on our points are drawn via the model (2).
4.1 Labeling Functions can be Arbitrarily Unfair
We show that, as a result of the transformation  $g_{1}$ , the predictions of labeling functions can be arbitrarily unfair even if the dataset is fair. The idea is simple: the average group 0 accuracy,  $\mathbb{E}_{z\in \mathcal{Z}}[P(\lambda (I(z)) = y)]$ , is independent of  $g_{1}$ , so it suffices to show that  $\mathbb{E}_{x^{\prime}\in g_1(\mathcal{Z})}[P(\lambda (x^{\prime}) = y)]$  can deteriorate when  $g_{1}$  moves data points far from the center  $x^{center_0}$ . As such, we consider the change in  $\mathbb{E}_{x^{\prime}\in g_1(\mathcal{Z})}[P(\lambda (x^{\prime}) = y)]$  as the group 1 points are transformed increasingly far from  $x^{center_0}$  in expectation.
Theorem 4.1. Let  $g_1^{(k)}$  be an arbitrary sequence of functions such that  $\lim_{k\to \infty}\mathbb{E}_{x'\in g_1^{(k)}(\mathcal{Z})}[\| x' - x^{center_0}\| ]\to \infty$ . Suppose our assumptions above are met; in particular, that the label  $y$  is independent of the observed features  $x = I(z)$  or  $x^{\prime} = g_{1}^{(k)}(z),\forall k$ , conditioned
Table 1: Tabular dataset results
Adult	Bank Marketing
Acc (↑)	F1 (↑)	ΔDP (↓)	ΔEO (↓)	Acc (↑)	F1 (↑)	ΔDP (↓)	ΔEO (↓)
FS	0.824	0.564	0.216	0.331	0.912	0.518	0.128	0.117
WS (Baseline)	0.717	0.587	0.475	0.325	0.674	0.258	0.543	0.450
SBM (w/o OT)	0.720	0.592	0.439	0.273	0.876	0.550	0.106	0.064
SBM (OT-L)	0.560	0.472	0.893	0.980	0.892	0.304	0.095	0.124
SBM (OT-S)	0.723	0.590	0.429	0.261	0.847	0.515	0.122	0.080
SBM (w/o OT) + LIFT	0.704	0.366	0.032	0.192	0.698	0.255	0.088	0.137
SBM (OT-L) + LIFT	0.700	0.520	0.015	0.138	0.892	0.305	0.104	0.121
SBM (OT-S) + LIFT	0.782	0.448	0.000	0.178	0.698	0.080	0.109	0.072
on the latent features  $z$ . Then,
$$
\lim  _ {k \rightarrow \infty} \mathbb {E} _ {x ^ {\prime} \in g _ {1} ^ {(k)} (\mathcal {Z})} [ P (\lambda (x ^ {\prime}) = y) ] = \frac {1}{2},
$$
which corresponds to random guessing.
It is easy to construct such a sequence of functions  $g_1^{(k)}$ , for instance, by letting  $g_1^{(k)}(z) = z + ku$ , where  $u$  is a  $d$ -dimensional vector of ones. When the distribution of group 1 points lies far from  $x^{\mathrm{center}_0}$  while the distribution of group 0 points lies near to  $x^{\mathrm{center}_0}$ , the accuracy parity of  $\lambda$  suffers. With adequately large expected  $d(x^{\mathrm{center}_0}, g_1^{(k)}(z))$ , the performance of  $\lambda$  on group 1 points approaches random guessing.
4.2 Finite-Sample Bound for Mitigating Unfairness
Next, we provide a result bounding the difference in LF accuracy between group 0 points,  $\mathbb{E}_{x\in \mathcal{Z}}[P(\lambda (x) = y)]$ , and group 1 points transformed using our method,  $\mathbb{E}_{x^{\prime}\in \mathcal{X}}[P(\lambda (\hat{h} (x^{\prime})) = y)]$ . A tighter bound on this difference corresponds to better accuracy intra-group parity.
Theorem 4.2. Set  $\tau$  to be  $\max \bigl (\mathbf{r}(\Sigma_0) / n_0,\mathbf{r}(\Sigma_1) / n_1,t / \min (n_0,n_1),t^2 /\max (n_0,n_1)^2\bigr)$ , and let  $C$  be a constant. Under the assumptions described above, when using Algorithm 1, for any  $t > 0$ , we have that with probability  $1 - e^{-t} - 1 / n_{1}$
$$
| \mathbb {E} _ {x \in \mathcal {Z}} [ P (\lambda (x) = y) ] - \mathbb {E} _ {x ^ {\prime} \in \mathcal {X}} [ P (\lambda (\hat {h} (x ^ {\prime})) = y) ] | \leq 4 \theta_ {0} C \sqrt {\tau \mathbf {r} (\Sigma_ {1})},
$$