SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Zijie Geng $^{1}$ , Xijun Li $^{1,2}$ , Jie Wang $^{1,3*}$ , Xiao Li $^{1}$ , Yongdong Zhang $^{1}$ , Feng Wu $^{1}$
<sup>1</sup>University of Science and Technology of China 2Noah's Ark Lab, Huawei
$^{3}$ Institute of Artificial Intelligence, Hefei Comprehensive National Science Center
{ustcgzj,lixijun,xiao_li}@mail.ustc.edu.cn
{jiewangx,zhyd73,fengwu}@ustc.edu.cn
In the past few years, there has been an explosive surge in the use of machine learning (ML) techniques to address combinatorial optimization (CO) problems, especially mixed-integer linear programs (MILPs). Despite the achievements, the limited availability of real-world instances often leads to sub-optimal decisions and biased solver assessments, which motivates a suite of synthetic MILP instance generation techniques. However, existing methods either rely heavily on expert-designed formulations or struggle to capture the rich features of real-world instances. To tackle this problem, we propose G2MILP, the first deep generative framework for MILP instances. Specifically, G2MILP represents MILP instances as bipartite graphs, and applies a masked variational autoencoder to iteratively corrupt and replace parts of the original graphs to generate new ones. The appealing feature of G2MILP is that it can learn to generate novel and realistic MILP instances without prior expert-designed formulations, while preserving the structures and computational hardness of real-world datasets, simultaneously. Thus the generated instances can facilitate downstream tasks for enhancing MILP solvers under limited data availability. We design a suite of benchmarks to evaluate the quality of the generated MILP instances. Experiments demonstrate that our method can produce instances that closely resemble real-world datasets in terms of both structures and computational hardness. The deliverables are released at https://miralab-ustc.github.io/L20-G2MILP.
Mixed-integer linear programming (MILP)—a powerful and versatile modeling technique for many real-world problems—lies at the core of combinatorial optimization (CO) research and is widely adopted in various industrial optimization scenarios, such as scheduling [1], planning [2], and portfolio [3]. While MILPs are  $\mathcal{NP}$ -hard problems [4], machine learning (ML) techniques have recently emerged as a powerful approach for either solving them directly or assisting the solving process [5, 6]. Notable successes include [7] for node selection, [8] for branching decision, and [9] for cut selection, etc.
Despite the achievements, the limited availability of real-world instances, due to labor-intensive data collection and proprietary issues, remains a critical challenge to the research community [5, 10, 11]. Developing practical MILP solvers usually requires as many instances as possible to identify issues through white-box testing [12]. Moreover, machine learning methods for improving MILP solvers often suffer from sub-optimal decisions and biased assessments under limited data availability, thus
compromising their generalization to unseen problems [13]. These challenges motivate a suite of synthetic MILP instance generation techniques, which fall into two categories. Some methods rely heavily on expert-designed formulations for specific problems, such as Traveling Salesman Problems (TSPs) [14] or Set Covering problems [15]. However, these methods cannot cover real-world applications where domain-specific expertise or access to the combinatorial structures, due to proprietary issues, is limited. Other methods construct general MILP instances by sampling from an encoding space that controls a few specific statistics [16]. However, these methods often struggle to capture the rich features and the underlying combinatorial structures, resulting in an unsatisfactory alignment with real-world instances.
Developing a deep learning (DL)-based MILP instance generator is a promising approach to address this challenge. Such a generator can actively learn from real-world instances and generate new ones without expert-designed formulations. The generated instances can simulate realistic scenarios, cover more cases, significantly enrich the datasets, and thereby enhance the development of MILP solvers at a relatively low cost. Moreover, this approach has promising technical prospects for understanding the problem space, searching for challenging cases, and learning representations, which we will discuss further in Section 5. While similar techniques have been widely studied for Boolean satisfiability (SAT) problems [17], the development of DL-based MILP instance generators remains a complete blank due to higher technical difficulties, i.e., it involves not only the intrinsic combinatorial structure preservation but also high-precision numerical prediction. This paper aims to lay the foundation for the development of such generators and further empower MILP solver development under limited data availability.
In this paper, we propose G2MILP, which is the first deep generative framework for MILP instances. We represent MILP instances as weighted bipartite graphs, where variables and constraints are vertices, and non-zero coefficients are edges. With this representation, we can use graph neural networks (GNNs) to effectively capture essential features of MILP instances [8, 18]. Using this representation, we recast the original task as a graph generation problem. However, generating such complex graphs from scratch can be computationally expensive and may destroy the intrinsic combinatorial structures of the problems [19]. To address this issue, we propose a masked variational autoencoder (VAE) paradigm inspired by masked language models (MLM) [20, 21] and VAE theories [22-24]. The proposed paradigm iteratively corrupts and replaces parts of the original graphs using sampled latent vectors. This approach allows for controlling the degree to which we change the original instances, thus balancing the novelty and the preservation of structures and hardness of the generated instances. To implement the complicated generation steps, we design a decoder consisting of four modules that work cooperatively to determine multiple components of new instances, involving both structure and numerical prediction tasks simultaneously.
We then design a suite of benchmarks to evaluate the quality of generated MILP instances. First, we measure the structural distributional similarity between the generated samples and the input training instances using multiple structural statistics. Second, we solve the instances using the advanced solver Gurobi [12], and we report the solving time and the numbers of branching nodes of the instances, which directly indicate their computational hardness [19, 25]. Our experiments demonstrate that G2MILP is the very first method capable of generating instances that closely resemble the training sets in terms of both structures and computational hardness. Furthermore, we show that G2MILP is able to adjust the trade-off between the novelty and the preservation of structures and hardness of the generated instances. Third, we conduct a downstream task, the optimal value prediction task, to demonstrate the potential of generated instances in enhancing MILP solvers. The results show that using the generated instances to enrich the training sets reduces the prediction error by over  $20\%$  on several datasets. The deliverables are released at https://miralab-ustc.github.io/L20-G2MILP.
Machine Learning for MILP Machine learning (ML) techniques, due to its capability of capturing rich features from data, has shown impressive potential in addressing combinatorial optimization (CO) problems [26-28], especially MILP problems [5]. Some works apply ML models to directly predict the solutions for MILPs [29-31]. Others attempt to incorporate ML models into heuristic components in modern solvers [7, 9, 32, 33]. Gasse et al. [8] proposed to represent MILP instances as bipartite graphs, and use graph neural networks (GNNs) to capture features for branching decisions. Our
proposed generative framework can produce novel instances to enrich the datasets, which promises to enhance the existing ML methods that require large amounts of i.i.d. training data.
MILP Instance Generation Many previous works have made efforts to generate synthetic MILP instances for developing and testing solvers. Existing methods fall into two categories. The first category focuses on using mathematical formulations to generate instances for specific combinatorial optimization problems such as TSP [14], set covering [15], and mixed-integer knapsack [34]. The second category aims to generate general MILP instances. Bowly [16] proposed a framework to generate feasible and bounded MILP instances by sampling from an encoding space that controls a few specific statistics, e.g., density, node degrees, and coefficient mean. However, the aforementioned methods either rely heavily on expert-designed formulations or struggle to capture the rich features of real-world instances. G2MILP tackles these two issues simultaneously by employing deep learning techniques to actively generate instances that resemble real-world problems, and it provides a versatile solution to the data limitation challenge. In [35], we further extend G2MILP to learn to generate challenging MILP instance.
Deep Graph Generation A plethora of literature has investigated deep learning models for graph generation [36], including auto-regressive methods [37], variational autoencoders (VAEs) [23], and generative diffusion models [38]. These models have been widely used in various fields [39] such as molecule design [21, 40, 41] and social network generation [42, 43]. G2SAT [17], the first deep learning method for SAT instance generation, has received much research attention [19, 44]. Nevertheless, it is non-trivial to adopt G2SAT to MILP instance generation (see Appendix C.1), as G2SAT does not consider the high-precision numerical prediction, which is one of the fundamental challenges in MILP instance generation. In this paper, we propose G2MILP—the first deep generative framework designed for general MILP instances—and we hope to open up a new research direction for the research community.
In this section, we present our G2MILP framework. First, in Section 3.1, we describe the approach to representing MILP instances as bipartite graphs. Then, in Section 3.2, we derive the masked variational autoencoder (VAE) generative paradigm. In Section 3.3, we provide details on the implementation of the model framework. Finally, in Section 3.4, we explain the training and inference processes. The model overview is in Figure 1. More implementation details can be found in Appendix A. The code is released at https://github.com/MIRALab-USTC/L20-G2MILP.
3.1 Data Representation
A mixed-linear programming (MILP) problem takes the form of:
$$
\min  _ {\boldsymbol {x} \in \mathbb {R} ^ {n}} \boldsymbol {c} ^ {\top} \boldsymbol {x}, \quad \text {s . t .} \boldsymbol {A} \boldsymbol {x} \leq \boldsymbol {b}, \boldsymbol {l} \leq \boldsymbol {x} \leq \boldsymbol {u}, x _ {j} \in \mathbb {Z}, \forall j \in \mathcal {I}, \tag {1}
$$
where  $\pmb{c} \in \mathbb{R}^n$ ,  $\pmb{A} \in \mathbb{R}^{m \times n}$ ,  $\pmb{b} \in \mathbb{R}^m$ ,  $\pmb{l} \in (\mathbb{R} \cup \{-\infty\})^n$ ,  $\pmb{u} \in (\mathbb{R} \cup \{+\infty\})^n$ , and the index set  $\mathcal{I} \subset \{1, 2, \dots, n\}$  includes those indices  $j$  where  $x_j$  is constrained to be an integer.
To represent each MILP instance, we construct a weighted bipartite graph  $\mathcal{G} = (\mathcal{V} \cup \mathcal{W}, \mathcal{E})$  as follows [18, 29].
- The constraint vertex set  $\mathcal{V} = \{v_{1},\dots ,v_{m}\}$ , where each  $v_{i}$  corresponds to the  $i^{\mathrm{th}}$  constraint in Equation 1. The vertex feature  $\pmb{v}_{i}$  of  $v_{i}$  is described by the bias term, i.e.,  $\pmb{v}_i = (b_i)$ .
- The variable vertex set  $\mathcal{W} = \{w_1, \dots, w_n\}$ , where each  $w_j$  corresponds to the  $j^{\text{th}}$  variable in Equation 1. The vertex feature  $w_j$  of  $w_j$  is a 9-dimensional vector that contains information of the objective coefficient  $c_j$ , the variable type, and the bounds  $l_j, u_j$ .
- The edge set  $\mathcal{E} = \{e_{ij}\}$ , where an edge  $e_{ij}$  connects a constraint vertex  $v_i \in \mathcal{V}$  and a variable vertex  $w_j \in \mathcal{W}$ . The edge feature  $e_{ij}$  is described by the coefficient, i.e.,  $e_{ij} = (a_{ij})$ , and there is no edge between  $v_i$  and  $w_j$  if  $a_{ij} = 0$ .
As described above, each MILP instance is represented as a weighted bipartite graph, equipped with a tuple of feature matrices  $(V, W, E)$ , where  $V, W, E$  denote stacks of vertex features  $\mathbf{v}_i$ ,  $\mathbf{w}_j$  and
Figure 1: Overview of G2MILP. (a) Masking Process  $\tilde{p}(\tilde{\mathcal{G}}|\mathcal{G})$ . Given a MILP instance, which is represented as a bipartite graph  $\mathcal{G}$ , we randomly label a constraint vertex  $\tilde{v}$  as [mask] to obtain the masked graph  $\tilde{\mathcal{G}}$ . (b) Encoder  $q_{\phi}(\mathbf{Z}|\mathcal{G})$ . The encoder is  $\mathrm{GNN}_{\phi}$  followed by two networks,  $\mu_{\phi}$  and  $\Sigma_{\phi}$ , for resampling. During training, we use the encoder to obtain the latent vectors  $\boldsymbol{z}_{v_i}$  and  $\boldsymbol{z}_{w_j}$  for all vertices. (c) Decoder  $p_{\theta}(\mathcal{G}|\tilde{\mathcal{G}},\mathbf{Z})$ . We use  $\mathrm{GNN}_{\phi}$  to obtain the node features  $\boldsymbol{h}_{\tilde{v}}$  and  $\boldsymbol{h}_{w_j}$ . Then four modules work cooperatively to reconstruct the original graph  $\mathcal{G}$  based on the node features and the latent vectors. They sequentially determine ① the bias terms, ② the degrees, ③ the logits, and ④ the weights. During inference, the model is decoder-only, and we draw the latent vectors from a standard Gaussian distribution to introduce randomness. We repeat the above mask-and-generate process several times so as to produce new instances.
edge features  $e_{ij}$ , respectively. Such a representation contains all information of the original MILP instance [18]. We use the off-the-shelf observation function provided by Ecole [45] to build the bipartite graphs from MILP instances. We then apply a graph neural network (GNN) to obtain the node representations  $h_{v_i}^{\mathcal{G}}$  and  $h_{w_j}^{\mathcal{G}}$ , also denoted as  $h_{v_i}$  and  $h_{w_j}$  for simplicity. More details on the data representation can be found in Appendix A.1.
3.2 Masked VAE Paradigm
We then introduce our proposed masked VAE paradigm. For the ease of understanding, we provide an intuitive explanation here, and delay the mathematical derivation to Appendix A.2.
Given a graph  $\mathcal{G}$  drawn from a dataset  $\mathcal{D}$ , we corrupt it through a masking process, denoted by  $\tilde{\mathcal{G}} \sim \tilde{p}(\tilde{\mathcal{G}}|\mathcal{G})$ . We aim to build a parameterized generator  $p_{\theta}(\hat{\mathcal{G}}|\tilde{\mathcal{G}})$  that can generate new instances  $\hat{\mathcal{G}}$  from the corrupted graph  $\tilde{\mathcal{G}}$ . We train the generator by maximizing the log-likelihood  $\log p_{\theta}(\mathcal{G}|\tilde{\mathcal{G}}) = \log p_{\theta}(\hat{\mathcal{G}} = \mathcal{G}|\tilde{\mathcal{G}})$  of reconstructing  $\mathcal{G}$  given  $\tilde{\mathcal{G}}$ . Therefore, the optimization objective is:
$$
\underset {\boldsymbol {\theta}} {\arg \max } \mathbb {E} _ {\mathcal {G} \sim \mathcal {D}} \mathbb {E} _ {\tilde {\mathcal {G}} \sim \tilde {p} (\tilde {\mathcal {G}} | \mathcal {G})} \log p _ {\boldsymbol {\theta}} (\mathcal {G} | \tilde {\mathcal {G}}). \tag {2}
$$
To model the randomness in the generation process and produce diverse instances, we follow the standard VAE framework [22, 23] to introduce a latent variable  $\mathbf{Z} = (z_{v_1},\dots ,z_{v_m},z_{w_1},\dots ,z_{w_n})$  which contains the latent vectors for all vertices. During training, the latent vectors are sampled from a posterior distribution given by a parameterized encoder  $q_{\phi}$ , while during inference, they are independently sampled from a prior distribution such as a standard Gaussian distribution. The decoder  $p_\theta$  in the masked VAE framework generates new instances from the masked graph  $\tilde{\mathcal{G}}$  together with the sampled latent variable  $\mathbf{Z}$ .
The evidence lower bound (ELBO), also known as the variational lower bound, is a lower bound estimator of the log-likelihood, and is what we actually optimize during training, because it is more tractable. We can derive the ELBO as:
$$
\log p _ {\boldsymbol {\theta}} (\mathcal {G} | \tilde {\mathcal {G}}) \geq \mathbb {E} _ {\mathbf {Z} \sim q _ {\phi} (\mathbf {Z} | \mathcal {G})} \left[ \log p _ {\boldsymbol {\theta}} (\mathcal {G} | \tilde {\mathcal {G}}, \mathbf {Z}) \right] - D _ {\mathrm {K L}} \left[ q _ {\phi} (\mathbf {Z} | \mathcal {G}) \| p _ {\boldsymbol {\theta}} (\mathbf {Z}) \right], \tag {3}
$$
where  $p_{\theta}(\mathbf{Z})$  is the prior distribution of  $\mathbf{Z}$  and is usually taken as the standard Gaussian  $\mathcal{N}(\mathbf{0},\mathbf{I})$ , and  $D_{\mathrm{KL}}[\cdot \| \cdot ]$  denotes the KL divergence. Therefore, we formulate the loss function as:
$$
\mathcal {L} = \mathbb {E} _ {\mathcal {G} \sim \mathcal {D}} \mathbb {E} _ {\tilde {\mathcal {G}} \sim \tilde {p} (\tilde {\mathcal {G}} | \mathcal {G})} \left[ \underbrace {\mathbb {E} _ {\mathbf {Z} \sim q _ {\phi} (\mathbf {Z} | \mathcal {G})} \left[ - \log p _ {\boldsymbol {\theta}} (\mathcal {G} | \tilde {\mathcal {G}} , \mathbf {Z}) \right]} _ {\mathcal {L} _ {\text {r e c}}} + \beta \cdot \underbrace {D _ {\mathrm {K L}} \left[ q _ {\phi} (\mathbf {Z} | \mathcal {G}) \| \mathcal {N} (\mathbf {0} , \boldsymbol {I}) \right]} _ {\mathcal {L} _ {\text {p r i o r}}} \right]. \tag {4}
$$
In the formula: (1) the first term  $\mathcal{L}_{\mathrm{rec}}$  is the reconstruction loss, which urges the decoder to rebuild the input data according to the masked data and the latent variables. (2) The second term  $\mathcal{L}_{\mathrm{prior}}$  is used to regularize the posterior distribution in the latent space to approach a standard Gaussian distribution, so that we can sample  $\mathbf{Z}$  from the distribution when inference. (3)  $\beta$  is a hyperparameter to control the weight of regularization, which is critical in training a VAE model [46].
3.3 Model Implementation
To implement Equation 4, we need to instantiate the masking process  $\tilde{p} (\tilde{\mathcal{G}} |\mathcal{G})$ , the encoder  $q_{\phi}(\mathbf{Z}|\mathcal{G})$  and the decoder  $p_{\theta}(\mathcal{G}|\tilde{\mathcal{G}},\mathbf{Z})$ , respectively.
Masking Process For simplicity, we uniformly sample a constraint vertex  $\tilde{v} \sim \mathcal{U}(\mathcal{V})$  and mask it and its adjacent edges, while keeping the variable vertices unchanged. Specifically, we label the vertex  $\tilde{v}$  with a special [mask] token, and add virtual edges that link  $\tilde{v}$  with each variable vertex. The vertex  $\tilde{v}$  and the virtual edges are assigned special embeddings to distinguish them from the others. We further discuss on the masking scheme in Appendix C.2.
Encoder The encoder  $q_{\phi}(\mathbf{Z}|\mathcal{G})$  is implemented as:
$$
q _ {\phi} (\mathbf {Z} | \mathcal {G}) = \prod_ {u \in \mathcal {V} \cup \mathcal {W}} q _ {\phi} \left(\boldsymbol {z} _ {u} | \mathcal {G}\right), \quad q _ {\phi} \left(\boldsymbol {z} _ {u} | \mathcal {G}\right) = \mathcal {N} \left(\boldsymbol {\mu} _ {\phi} \left(\boldsymbol {h} _ {u} ^ {\mathcal {G}}\right), \exp \boldsymbol {\Sigma} _ {\phi} \left(\boldsymbol {h} _ {u} ^ {\mathcal {G}}\right)\right), \tag {5}
$$
where  $h_u^G$  is the node representation of  $u$  obtained by a GNN  $\phi$ ,  $\mathcal{N}$  denotes the Gaussian distribution, and  $\pmb{\mu}$  and  $\pmb{\Sigma}$  output the mean and the log variance, respectively.
Decoder The decode  $p_{\theta}$  aims to reconstruct  $\mathcal{G}$  during training. We apply a  $\mathrm{GNN}_{\theta}$  to obtain the node representations  $h_u^{\tilde{\mathcal{G}}}$ , denoted as  $h_u$  for simplicity. To rebuild the masked constraint vertex  $\tilde{v}$ , the decoder sequentially determines: ① the bias  $b_{\tilde{v}}$  (i.e., the right-hand side of the constraint), ② the degree  $d_{\tilde{v}}$  of  $\tilde{v}$  (i.e., the number of variables involved in the constraint), ③ the logits  $\delta_{\tilde{v},u}$  for all variable vertices  $u$  to indicate whether they are connected with  $\tilde{v}$  (i.e., whether the variables are in the constraint), and ④ the weights  $e_{\tilde{v},u}$  of the edges (i.e., the coefficients of the variables in the constraint). The decoder is then formulated as:
$$
p _ {\boldsymbol {\theta}} (\mathcal {G} | \tilde {\mathcal {G}}, \mathbf {Z}) = p _ {\boldsymbol {\theta}} \left(b _ {\tilde {v}} | \tilde {\mathcal {G}}, \mathbf {Z}\right) \cdot p _ {\boldsymbol {\theta}} \left(d _ {\tilde {v}} | \tilde {\mathcal {G}}, \mathbf {Z}\right) \cdot \prod_ {u \in \mathcal {W}} p _ {\boldsymbol {\theta}} \left(\delta_ {\tilde {v}, u} | \tilde {\mathcal {G}}, \mathbf {Z}, d _ {\tilde {v}}\right) \cdot \prod_ {u \in \mathcal {W}: \delta_ {\tilde {v}, u} = 1} p _ {\boldsymbol {\theta}} \left(e _ {\tilde {v}, u} | \tilde {\mathcal {G}}, \mathbf {Z}\right). \tag {6}
$$
Therefore, we implement the decoder as four cooperative modules: ① Bias Predictor, ② Degree Predictor, ③ Logits Predictor, and ④ Weights Predictor.
① Bias Predictor For effective prediction, we incorporate the prior of simple statistics of the dataset—the minimum  $\underline{b}$  and the maximum  $\overline{b}$  of the bias terms that occur in the dataset—into the predictor. Specifically, we normalize the bias  $b_{\tilde{v}}$  to  $[0,1]$  via  $b_{\tilde{v}}^{*} = (b_{\tilde{v}} - \underline{b}) / (\overline{b} -\underline{b})$ . To predict  $b_{\tilde{v}}^{*}$ , we use one MLP that takes the node representation  $\pmb{h}_{\tilde{v}}$  and the latent vector  $\pmb{z}_{\tilde{v}}$  of  $\tilde{v}$  as inputs:
$$
\hat {b} _ {\tilde {v}} ^ {*} = \sigma \left(\operatorname {M L P} _ {\theta} ^ {\text {b i a s}} \left([ h _ {\tilde {v}}, z _ {\tilde {v}} ]\right)\right), \tag {7}
$$
where  $\sigma (\cdot)$  is the sigmoid function used to restrict the outputs. We use the mean squared error (MSE) loss to train the predictor. At inference time, we apply the inverse transformation to obtain the predicted bias values:  $\hat{b}_{\tilde{v}} = \underline{b} +(\overline{b} -\underline{b})\cdot \hat{b}_{\tilde{v}}^{*}$
1 Notation-wise, we use  $\hat{x}$  to denote the predicted variable in  $\hat{\mathcal{G}}$  that corresponds to  $x$  in  $\mathcal{G}$ .
$②$  Degree Predictor We find that the constraint degrees are crucial to the graph structures and significantly affect the combinatorial properties. Therefore, we use the Degree Predictor to determine coarse-grained degree structure, and then use the Logits Predictor to determine the fine-grained connection details. Similarly to Bias Predictor, we normalize the degree  $d_{\tilde{v}}$  to  $d_{\tilde{v}}^{*} = (d_{\tilde{v}} - \underline{d}) / (\overline{d} -\underline{d})$  where  $\underline{d}$  and  $\overline{d}$  are the minimum and maximum degrees in the dataset, respectively. We use one MLP to predict  $d_{\tilde{v}}^{*}$ :
$$
\hat {d} _ {\tilde {v}} ^ {*} = \sigma \left(\mathrm {M L P} _ {\theta} ^ {\deg} ([ h _ {\tilde {v}}, z _ {\tilde {v}} ])\right). \tag {8}
$$
We use MSE loss for training, and round the predicted degree to the nearest integer  $\hat{d}_{\bar{v}}$  for inference.
③ Logits Predictor To predict the logits  $\delta_{\tilde{v},u}$  indicating whether a variable vertex  $u \in \mathcal{W}$  is connected with  $\tilde{v}$ , we use one MLP that takes the representation  $h_u$  and the latent vector  $z_u$  of  $u$  as inputs:
$$
\hat {\delta} _ {\bar {v}, u} ^ {\prime} = \sigma \left(\mathrm {M L P} _ {\theta} ^ {\log_ {0} (\left[ h _ {u}, z _ {u} \right])}\right). \tag {9}
$$
We use binary cross-entropy (BCE) loss to train the logistical regression module. As positive samples (i.e., variables connected with a constraint) are often scarce, we use one negative sample for each positive sample during training. The loss function is: