SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Mengyue Yang $^{1}$ , Zhen Fang $^{2}$ , Yonggang Zhang $^{3*}$ , Yali Du $^{4}$ , Furui Liu $^{5}$ , Jean-Francois Ton $^{6}$ , Jianhong Wang $^{7}$ , Jun Wang $^{1*}$ $^{1}$ University College London,  $^{2}$ University of Technology Sydney  
 $^{3}$ Hong Kong Baptist University,  $^{4}$ King's College London  
 $^{5}$ Zhejiang Lab,  $^{6}$ ByteDance Research,  $^{7}$ University of Manchester  
mengyue.yang.20@ucl.ac.uk, zhen.fang@uts.edu.au, csygzhang@comp.hkbu.edu.hk, yali.du@kcl.ac.uk  
liufurui@zhejianglab.com, jeanfrancois@bytedance.com  
jianhong.wang@manchester.ac.uk, jun.wang@cs.ucl.ac.uk
Out-of-distribution (OOD) generalization is indispensable for learning models in the wild, where testing distribution typically unknown and different from the training. Recent methods derived from causality have shown great potential in achieving OOD generalization. However, existing methods mainly focus on the invariance property of causes, while largely overlooking the property of sufficiency and necessity conditions. Namely, a necessary but insufficient cause (feature) is invariant to distribution shift, yet it may not have required accuracy. By contrast, a sufficient yet unnecessary cause (feature) tends to fit specific data well but may have a risk of adapting to a new domain. To capture the information of sufficient and necessary causes, we employ a classical concept, the probability of sufficiency and necessary causes (PNS), which indicates the probability of whether one is the necessary and sufficient cause. To associate PNS with OOD generalization, we propose PNS risk and formulate an algorithm to learn representation with a high PNS value. We theoretically analyze and prove the generalizability of the PNS risk. Experiments on both synthetic and real-world benchmarks demonstrate the effectiveness of the proposed method. The detailed implementation can be found at the GitHub repository: https://github.com/ymy4323460/CaSN.
The traditional supervised learning methods heavily depend on the in-distribution (ID) assumption, where the training data and test data are sampled from the same data distribution (Shen et al., 2021; Peters et al., 2016). However, the ID assumption may not be satisfied in some practical scenarios like distribution shift (Zhang et al., 2013; Sagawa et al., 2019), which leads to the failure of these traditional supervised learning methods. To relax the ID assumption, researchers have recently started to study a different learning setting called out-of-distribution (OOD) generalization. OOD generalization aims to train a model using the ID data such that the model generalizes well in the unseen test data that share the same semantics with ID data (Li et al., 2018b; Ahuja et al., 2021).
Recent works have proposed to solve the OOD generalization problem through the lens of causality (Peters et al., 2016; Pfister et al., 2019; Rothenhausler et al., 2018; Heinze-Deml et al., 2018; Gamella
*Corresponding Author: csygzhang@comp.hkbu.edu.hk; jun.wang@cs.ucl.ac.uk
(a) Example of 'sufficient' (SF), 'necessary' (NC) and 'sufficient and necessary' (SN) causes
(b) Causal graph
Figure 1: (a) Examples for causal sufficiency and necessity in the cat classification. (b) The causal graph for OOD generalization problem. The arrows denote the causal generative direction and the dashed line connects the spurious correlated variables. Notations are formally defined in Section 2.1. & Heinze-Deml, 2020; Oberst et al., 2021; Chen et al., 2022a). These works focus on learning invariant representation, aiming to capture the cause of the labels. By learning this representation, one can bridge the gap between the ID training data and unknown OOD test data, and thus mitigate the negative impacts on the distribution shift between ID and OOD distributions. Among these works, invariant risk minimization (IRM) (Arjovsky et al., 2019) is the most representative method, targeting to identify invariant representation and classifier using a bi-level optimization algorithm. Following works, many efforts have been devoted to further extending the original invariant learning framework (Chen et al., 2022b; Ahuja et al., 2020a; Lu et al., 2021; Liu et al., 2021b; Lin et al., 2022).
Noticeably, the aforementioned invariant learning methods mainly focus on learning the invariant causal representation, which may contain non-essential information that is not necessary nor sufficient information (Pearl, 2009). In image classification tasks, necessity describes the label is not true if the features disappear, and sufficiency describes the presence of a feature helps us determine the correctness of the label. If the feature extractor only learns a representation that is invariant but fails to satisfy the sufficiency or necessity, the model's generalisation ability may deteriorate. As an illustrative example (see Figure 1(a)), suppose that the training data only contains images of cats with feet and that we are interested in learning a model for a cat prediction task. If the model captures the invariant information (feature) "cat feet", then the learned model is likely to make a mistake in the OOD data containing cats without "cat feet" features. The example "cat feet" demonstrates the representation contains sufficient but unnecessary causal information because using "cat feet" can predict the label "cat" but a cat image might not contain "cat feet". Analogously, there are also representations that are necessary but not sufficient (the feature "pointy ear" in Figure 1(a)). In Section 2.2, we present more examples to enhance the understanding of sufficiency and necessity.
This paper proposes achieving OOD generalization using essential causal information, which builds upon the probability of necessity and sufficiency (PNS) (Pearl, 2009). In this paper, we introduce the PNS risk. A low PNS risk implies that the representation contains both the necessary and sufficient causal information from the observation data with a high level of confidence. We provide some theoretical analysis that establishes the approximation of the risk on unseen test domains by the risk on source data. Based on these theoretical results, we discuss PNS risk in the context of a semantic separable representation space and propose an algorithm for learning the representation which contains the information of both sufficient and necessary causes from training data (ID data) under different causal assumptions in Figure 1(b). The main contributions of this paper are as follows:
Firstly, we propose a new learning risk—PNS risk—to estimate the sufficiency and necessity of information contained in the learned representation. Secondly, we theoretically analyze the PNS risk under OOD problem and bound the gap between PNS risk on the test domain distribution and the risk on source data. Lastly, we propose an algorithm that captures sufficient and necessary causal representation with low PNS risk on test domains. Experiments on synthetic and real-world benchmarks are conducted to show the effectiveness of the algorithm over state-of-the-art methods.
2.1 Learning Setups
Domains. Let  $\mathbf{X} \in \mathcal{X} \subset \mathbb{R}^D$  be the observable feature variable and  $Y \in \mathcal{Y}$  be the label. In this paper, we mainly focus on binary classification task $^2$ , i.e., the label space  $\mathcal{Y} = \{0,1\}$ .  $S$  is a joint
2We extend the binary classification to multi-classification in experiments.
distribution  $P_{s}(\mathbf{X},Y)$  defined over  $\mathcal{X}\times \mathcal{Y}$  in source domain. Equivalently, the unseen test domain is  $\mathcal{T}\coloneqq P_t(\mathbf{X},Y)$ . We also set  $\mathcal{T}_{\mathbf{X}}\coloneqq P_t(\mathbf{X})$  to be the marginal distribution over variable  $\mathbf{X}$  on test domain. Similarly,  $S_{\mathbf{X}}\coloneqq P_s(\mathbf{X})$  is the marginal distributions on source domain over  $\mathbf{X}$ .
Assumption and model. We conclude the causal graph in OOD generalization in Figure 1(b), inspired by the content (invariant) features and style (variant) features partition (Zhang et al., 2022). There are the invariant feature  $\mathbf{C} \in \mathbb{R}^d$  and domain specific variable (i.e. domain indicator)  $V \in \{1, \dots, n\}$ . A common assumption of OOD generalization is that there exists latent causal variable  $\mathbf{C} \in \mathbb{R}^d$  that maintains the invariance property across domains (see Figure 1(b)), i.e.,  $P_s(Y|\mathbf{C} = \mathbf{c}) = P_t(Y|\mathbf{C} = \mathbf{c})$  (Arjovsky et al., 2019). Built upon this assumption, we define an invariant predictor by using a simple linear classifier  $\mathbf{w}: \mathbb{R}^d \to \mathcal{V}$  on the causal features to get label  $y = \mathrm{sign}(\mathbf{w}^\top \mathbf{c})$ . Since the causal variable  $\mathbf{C}$  cannot be directly observed, we infer  $\mathbf{C}$  from the observational data  $\mathbf{x} \sim \mathbf{X}$ . Then, the invariant predictor with the invariant representation inference model is defined as below.
$$
y = \operatorname {s i g n} [ \mathbb {E} _ {\mathbf {c} \sim P _ {t} (\mathbf {C} | \mathbf {X} = \mathbf {x})} \mathbf {w} ^ {\top} \mathbf {c} ]. \tag {1}
$$
2.2 Probability of Sufficient and Necessary Cause
Existing invariant learning strategies (Rojas-Carulla et al., 2018; Pfister et al., 2019; Arjovsky et al., 2019) only consider the invariant property. However, the invariant representation can be further divided into three parts, each containing the different sufficient and necessary causal information.
(i) Sufficient but unnecessary causes  $A$ : The cause  $A$  leads to the effect  $B$ , but when observing the effect  $B$ , it is hard to confirm  $A$  is the actual cause (See example in Figure 1(a)). (ii) Necessary but insufficient causes  $A$ : Knowing effect  $B$  we confirm the cause is  $A$ , but cause  $A$  might not lead to effect  $B$ . "pointy ear" in cat prediction is selected as a typical example. Because when the ear shape is not pointy, we can confirm it is not a cat. However, a fox has a similar ear shape to a cat. Thus "pointy ear" is not a stable feature to predict cats. (iii) Necessary and sufficient causes  $A$ : Knowing the effect  $B$  confirms the cause  $A$ , while observing  $A$  leads to  $B$ . In the cat and fox classification task, "short mouth" could be a necessary and sufficient cause. It is because the feature "short mouth" allows us to distinguish a cat from a fox, and when know there is a cat, "short mouth" must exist.
In order to learn invariant representations  $\mathbf{C}$  contains both sufficient and necessary causal information, we refer to the concept of Probability of Sufficient and Necessary (PNS) (Chapter 9 in (Pearl, 2009), which is formally defined as below.
Definition 2.1 (Probability of Necessary and Sufficient (PNS) (Pearl, 2009)). Let the specific implementations of causal variable  $\mathbf{C}$  as  $\mathbf{c}$  and  $\bar{\mathbf{c}}$ , where  $\bar{\mathbf{c}} \neq \mathbf{c}$ . The probability that  $\mathbf{C}$  is the necessary and sufficiency cause of  $Y$  on test domain  $\mathcal{T}$  is
$$
\begin{array}{l} \operatorname {P N S} (\mathbf {c}, \overline {{\mathbf {c}}}) := \underbrace {P _ {t} (Y _ {d o (\mathbf {C} = \mathbf {c})} = y \mid \mathbf {C} = \overline {{\mathbf {c}} , Y \neq y)} _ {\text {s u f f i c i e n c y}} P _ {t} (\mathbf {C} = \overline {{\mathbf {c}} , Y \neq y)} \\ + \underbrace {P _ {t} \left(Y _ {d o (\mathbf {C} = \overline {{\mathbf {c}}})} \neq y \mid \mathbf {C} = \mathbf {c} , Y = y\right)} _ {\text {n e c e s s i t y}} P _ {t} (\mathbf {C} = \mathbf {c}, Y = y). \tag {2} \\ \end{array}
$$
In the above definition, the notion  $P(Y_{do(\mathbf{C} = \overline{\mathbf{c}})} \neq y | \mathbf{C} = \mathbf{c}, Y = y)$  means that we study the probability of  $Y \neq y$  when we force the manipulable variable  $\mathbf{C}$  to be a fixed value  $do(\mathbf{C} = \overline{\mathbf{c}})$  (do-operator) given a certain factual observation  $Y = y$  and  $\mathbf{C} = \mathbf{c}$ . The first and second terms in PNS correspond to the probabilities of sufficiency and necessity, respectively. Variable  $\mathbf{C}$  has a high probability to be the sufficient and necessary cause of  $Y$  when the PNS value is large. Computing the counterfactual probability is a challenging problem since collecting the counterfactual data is difficult, or even impossible in real-world systems. Fortunately, PNS defined on counterfactual distribution can be directly estimated by the data under proper conditions, i.e., Exogeneity and Monotonicity.
Definition 2.2 (Exogeneity (Pearl, 2009)). Variable  $\mathbf{C}$  is exogenous relative to variable  $Y$  w.r.t. source and test domains  $\mathcal{S}$  and  $\mathcal{T}$ , if the intervention probability is identified by conditional probability  $P_{s}(Y_{do}(\mathbf{C} = \mathbf{c}) = y) = P_{s}(Y = y|\mathbf{C} = \mathbf{c})$  and  $P_{t}(Y_{do}(\mathbf{C} = \mathbf{c}) = y) = P_{t}(Y = y|\mathbf{C} = \mathbf{c})$ .
Definition 2.3 (Monotonicity  $^3$  (Pearl, 2009)).  $Y$  is monotonic relative to  $X$  if and only if either  $P(Y_{do(\mathbf{C} = \mathbf{c})} = y, Y_{do(\mathbf{C} = \overline{\mathbf{c}})} \neq y) = 0$  or  $P(Y_{do(\mathbf{C} = \mathbf{c})} \neq y, Y_{do(\mathbf{C} = \overline{\mathbf{c}})} = y) = 0$
3We rewrite logic expression  $Y_{do(\mathbf{C} = \overline{\mathbf{c}})} = \bar{y}\wedge Y_{do(\mathbf{C} = \mathbf{c})} = y$  is false or  $Y_{do(\mathbf{C} = \overline{\mathbf{c}})} = y\wedge Y_{do(\mathbf{C} = \mathbf{c})} = \bar{y}$  is false in original Monotonicity by the probabilistic formulation.
The definition of Exogeineity describes the gap between the intervention and conditional distributions vanishes when  $\mathbf{C}$  is exogenous relative to  $Y$  and the definition of Monotonicity demonstrates the monotonic effective on  $Y$  of causal variable  $\mathbf{C}$ . Based on Definitions 2.2 and 2.3, the identifiability of PNS in Definition 2.1 is described as the following lemma.
Lemma 2.4 (Pearl (2009)). If  $\mathbf{C}$  is exogenous relative to  $Y$ , and  $Y$  is monotonic relative to  $\mathbf{C}$ , then
$$
P N S (\mathbf {c}, \bar {\mathbf {c}}) = \underbrace {P _ {t} (Y = y | \mathbf {C} = \mathbf {c})} _ {\text {s u f f i c i e n c y}} - \underbrace {P _ {t} (Y = y | \mathbf {C} = \bar {\mathbf {c}})} _ {\text {n e c e s s i t y}}. \tag {3}
$$
According to Lemma 2.4, the computation of PNS is feasible through the observation data under Exogeneity and Monotonicity. This allows us to quantify PNS when counterfactual data is unavailable. The proof of Lemma 2.4 is provided by Pearl (2009). Wang & Jordan (2021) further extend the proof by incorporating probabilistic computation, as opposed to the logical calculation used in Pearl (2009).
3 PNS Risk Modeling
This section presents the PNS-based risk for invariant learning in OOD problem. The risk on test domains is a PNS-value evaluator, which is bounded by the tractable risk on the training domain.
3.1 PNS Risk
In this section, we introduce the PNS risk, which is a PNS-value estimator. The risk estimates the PNS value of the representation distribution  $P_{t}(\mathbf{C}|\mathbf{X} = \mathbf{x})$  inferred from  $\mathbf{X}$  on an unseen test domain  $\mathcal{T}$ . The risk increases when the representation contains less necessary and sufficient information, which can be caused by data distribution shifts. The PNS risk is based on the definition of  $\mathrm{PNS}(\mathbf{c},\bar{\mathbf{c}})$ . As  $\bar{\mathbf{c}}$  represents the intervention value, it is not necessary for it to be a sample from the same distribution as the causal variable  $\mathbf{C}$ . Thus, we define an auxiliary variable  $\bar{\mathbf{C}}\in \mathbb{R}^d$  (same as the range of  $\mathbf{C}$ ) and sample  $\bar{\mathbf{c}}$  from its distribution  $P_{t}(\bar{\mathbf{C}} |\mathbf{X} = \mathbf{x})$ . In the learning method, we use the notations  $P_{t}^{\phi}(\mathbf{C}|\mathbf{X} = \mathbf{x})$  and  $P_{t}^{\xi}(\bar{\mathbf{C}} |\mathbf{X} = \mathbf{x})$  to present the estimated distributions, which are parameterized by  $\phi$  and  $\xi$ , separately. Let  $\operatorname {I}(A)$  be an indicator function, where  $\operatorname {I}(A) = 1$  if  $A$  is true; otherwise,  $\operatorname {I}(A) = 0$ . PNS risk based on Definition 2.1 and Lemma 2.4 is formally defined as Eq. (4) below.
$$
\begin{array}{l} R _ {t} (\mathbf {w}, \phi , \xi) := \mathbb {E} _ {(\mathbf {x}, y) \sim \mathcal {T}} \left[ \mathbb {E} _ {\mathbf {c} \sim P _ {t} (\mathbf {C} | \mathbf {X} = \mathbf {x})} \mathrm {I} [ \operatorname {s i g n} (\mathbf {w} ^ {\top} \mathbf {c}) \neq y ] \right. \tag {4} \\ + \mathbb {E} _ {\bar {\mathbf {c}} \sim P _ {t} (\bar {\mathbf {C}} | \mathbf {X} = \mathbf {x})} \left[ \operatorname {s i g n} \left(\mathbf {w} ^ {\top} \bar {\mathbf {c}}\right) = y \right]. \\ \end{array}
$$
As the identifiability result in Lemma 2.4 is based on the Exogeneity 2.2 and Monotonicity 2.3, we modify the original risk equation, Eq. (4), to ensure compliance with these conditions. Below, we provide Monotonicity measurement and discuss the satisfaction of Exogeneity in Section 4.3.
Satisfaction of monotonicity. We naturally introduce the measurement of Monotonicity into PNS risk by deriving an upper bound of Eq. (4), which is given below.
Proposition 3.1. Given a test domain  $\mathcal{T}$ , we define the sufficient and necessary risks as:
$$
SF_{t}(\mathbf{w},\phi):= \underbrace{\mathbb{E}_{(\mathbf{x},y)\sim\mathcal{T}}\mathbb{E}_{\mathbf{c}\sim P_{t}^{\phi}(\mathbf{C}|\mathbf{X} = \mathbf{x})}\mathrm{I}[\mathrm{sign}(\mathbf{w}^{\top}\mathbf{c})\neq y]}_{\text{sufficiency term}},
$$
$$
NC_{t}(\mathbf{w},\xi):= \underbrace{\mathbb{E}_{(\mathbf{x},y)\sim\mathcal{T}}\mathbb{E}_{\overline{\mathbf{c}}\sim P_{t}^{\xi}(\bar{\mathbf{C}}|\mathbf{X} = \mathbf{x})}\mathrm{I}[\mathrm{sign}(\mathbf{w}^{\top}\overline{\mathbf{c}}) = y]}_{\text{$necessity term$}},
$$
and let the Monotonicity measurement be
$$
M _ {t} ^ {\mathbf {w}} (\phi , \xi) := \mathbb {E} _ {(\mathbf {x}, y) \sim \mathcal {T}} \mathbb {E} _ {\mathbf {c} \sim P _ {t} ^ {\phi} (\mathbf {C} | \mathbf {X} = \mathbf {x})} \mathbb {E} _ {\bar {\mathbf {c}} \sim P _ {t} ^ {\xi} (\bar {\mathbf {C}} | \mathbf {X} = \mathbf {x})} \mathrm {I} [ \mathrm {s i g n} (\mathbf {w} ^ {\top} \mathbf {c}) = \mathrm {s i g n} (\mathbf {w} ^ {\top} \bar {\mathbf {c}}) ],
$$
$$
R _ {t} (\mathbf {w}, \phi , \xi) = M _ {t} ^ {\mathbf {w}} (\phi , \xi) + 2 S F _ {t} (\mathbf {w}, \phi) N C _ {t} (\mathbf {w}, \xi) \leq M _ {t} ^ {\mathbf {w}} (\phi , \xi) + 2 S F _ {t} (\mathbf {w}, \phi). \tag {5}
$$
The upper bound for PNS risk in Eq. (5) consists of two terms: (i) the evaluator of sufficiency  $SF_{t}(\mathbf{w},\phi)$  and (ii) the Monotonicity measurement  $M_t^{\mathbf{w}}(\phi ,\xi)$ . In the upper bound, the necessary term  $\mathrm{NC}_t(\mathbf{w},\xi)$  is considered to be absorbed into measurement of Monotonicity  $M_t^{\mathbf{w}}(\phi ,\xi)$ . The minimization process of Eq. (4) on its upper bound (5) considers the satisfaction of Monotonicity.
3.2 OOD Generalization with PNS risk
In OOD generalization tasks, only source data collected from  $S$  is provided, while the test domain  $\mathcal{T}$  is unavailable during the optimization process. As a result, it is not possible to directly evaluate the risk on the test domain, i.e.  $R_{t}(\mathbf{w},\phi ,\xi)$ . To estimate  $R_{t}(\mathbf{w},\phi ,\xi)$ , we have a two-step process: (i) Firstly, since the test-domain distribution  $\mathcal{T}$  is not available during the training process, We aim to establish a connection between the risk on the test domain  $R_{t}(\mathbf{w},\phi ,\xi)$  and the risk on the source domain  $R_{s}(\mathbf{w},\phi ,\xi)$  in Theorem 3.2. (ii) Furthermore, in practical scenarios where only a finite number of samples are available, we demonstrate the bound of the gap between the expected risk on the domain distribution and the empirical risk on the source domain data in Theorem 3.3.
Connecting the PNS risks, i.e.,  $R_{t}(\mathbf{w}, \phi, \xi)$  and  $R_{s}(\mathbf{w}, \phi, \xi)$ . We introduce divergence measurement  $\beta$  divergence (Ganin et al., 2016) and weigh the  $R_{s}(\mathbf{w}, \phi, \xi)$  term by variational approximation.  $\beta$  divergence measures the distance between domain  $\mathcal{T}$  and  $S$ , which is formally defined below.
$$
\beta_ {k} (\mathcal {T} \| \mathcal {S}) = \left[ \underset {(\mathbf {x}, y) \sim \mathcal {S}} {\mathbb {E}} \left(\frac {\mathcal {T} (\mathbf {x} , y)}{\mathcal {S} (\mathbf {x} , y)}\right) ^ {k} \right] ^ {\frac {1}{k}}. \tag {6}
$$
Based on  $\beta_{k}(\mathcal{T}\| \mathcal{S})$ , we connect the risks on the source and test domains by Theorem 3.2.
Theorem 3.2. The risk on the test domain is bounded by the risk on the source domain, i.e.,
$$
R _ {t} (\mathbf {w}, \phi , \xi) \leq \lim  _ {k \rightarrow + \infty} \beta_ {k} (\mathcal {T} \| \mathcal {S}) ([ M _ {s} ^ {\mathbf {w}} (\phi , \xi) ] ^ {1 - \frac {1}{k}} + 2 [ S F _ {s} (\mathbf {w}, \phi) ] ^ {1 - \frac {1}{k}}) + \eta_ {t \backslash s} (\mathbf {X}, Y),
$$
$$
\eta_ {t \backslash s} (\mathbf {X}, Y) := P _ {t} (\mathbf {X} \times Y \notin \operatorname {s u p p} (\mathcal {S})) \cdot \sup  R _ {t \backslash s} (\mathbf {w}, \phi , \xi).
$$
Here  $\operatorname{supp}(\mathcal{S})$  is the support set of source domain distribution  $P_{s}(\mathbf{X})$ ,
$$
\begin{array}{l} R _ {t \backslash s} (\mathbf {w}, \phi , \xi) := \mathbb {E} _ {(\mathbf {x}, y) \sim P _ {t} (\mathbf {X} \times Y \notin \operatorname {s u p p} (S))} \left[ \mathbb {E} _ {\mathbf {c} \sim P _ {t} (\mathbf {C} | \mathbf {X} = \mathbf {x})} I [ \operatorname {s i g n} (\mathbf {w} ^ {\top} \mathbf {c}) \neq y ] \right. \\ + \mathbb {E} _ {\bar {\mathbf {c}} \sim P _ {t} (\bar {\mathbf {C}} | \mathbf {X} = \mathbf {x})} \left[ \mathrm {I} \left[ \operatorname {s i g n} \left(\mathbf {w} ^ {\top} \bar {\mathbf {c}}\right) = y \right] \right]. \\ \end{array}
$$
In Theorem 3.2,  $\eta_{t\setminus s}(\mathbf{X},Y)$  describes the expectation of worst risk for unknown area i.e. the data sample  $(\mathbf{x},y)$  does not include in the source domain support set  $\mathrm{supp}(S)$ . Theorem 3.2 connects the source-domain risk and the test-domain risk. In the ideal case, where  $\mathbf{C}$  is the invariant representation, i.e.  $P_{s}(Y|\mathbf{C} = \mathbf{c}) = P_{t}(Y|\mathbf{C} = \mathbf{c})$ , the bound is reformed as below.
$$
R _ {t} (\mathbf {w}, \phi , \xi) \leq \lim  _ {k \rightarrow + \infty} \beta_ {k} \left(\mathcal {T} _ {\mathbf {X}} \| \mathcal {S} _ {\mathbf {X}}\right)\left([ M _ {s} ^ {\mathbf {w}} (\phi , T) ] ^ {1 - \frac {1}{k}} + 2 \left[ S F _ {s} (\mathbf {w}, \phi) \right] ^ {1 - \frac {1}{k}}\right) + \eta_ {t \backslash s} (\mathbf {X}, Y). \tag {7}
$$
When the observations  $\mathbf{X}$  in  $\mathcal{S}$  and  $\mathcal{T}$  share the same support set, the term  $\eta_{t\setminus s}(\mathbf{X},Y)$  approaches to 0. In domain generalization tasks, the term  $\beta_{k}(\mathcal{T}_{\mathbf{X}}|\mathcal{S}_{\mathbf{X}})$  is treated as a hyperparameter, as the test domain  $\mathcal{T}_{\mathbf{X}}$  is not available during training. However, in domain adaptation tasks where  $\mathcal{T}_{\mathbf{X}}$  is provided,  $\beta_{k}(\mathcal{T}_{\mathbf{X}}|\mathcal{S}_{\mathbf{X}})$  and the test-domain Monotonicity measurement  $M_t^{\mathbf{w}}(\phi ,\xi)$  can be directly estimated. Further details of the discussion on domain adaptation are provided in Appendix A.3.
Connecting empirical risk to the expected risk. In most real-world scenarios where distribution  $S$  is not directly provided, we consider the relationship of expected risk on source domain distribution and empirical risk on source domain data  $S^n := \{(\mathbf{x}_i, y_i)\}_{i=1}^n$ . We also define the empirical risks w.r.t.  $\widehat{SF}_s(\mathbf{w}, \phi), \widehat{M}_s^{\mathbf{w}}(\phi, \xi)$  as follows:
$$
\widehat {S F} _ {s} (\mathbf {w}, \phi) := \mathbb {E} _ {\mathcal {S} ^ {n}} \mathbb {E} _ {\mathbf {c} \sim \hat {P} _ {s} ^ {\phi} (\mathbf {C} | \mathbf {X} = \mathbf {x})} \mathrm {I} [ \operatorname {s i g n} (\mathbf {w} ^ {\top} \mathbf {c}) \neq y ],
$$