Wang 2020 - DCNv2
DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems
This paper proposes a neural network architecture called Deep and Cross Networks for effectively learning feature crosses compared to a standard feedforward MLP.
Background
Effective feature crossing is essential in many ML tasks, especially for search and recommendation. For example, a country feature crossed with language is more informative than either alone. Manually searching for good feature crosses is a combinatorial exercise which is intensive.
Deep neural networks in the form of MLPs are generally viewed as universal function approximators in the limiting case. But in the finite depth, they are often incapable of fully modelling feature crosses effectively (say using a simulated dataset).
Traditionally, Factorization Machines seek to overcome the feature combination issue by embedding a sparse feature with large dimensionality into a small dense vector. Feature crosses between features is then performed using a dot product between features. However, we are limited in expressiveness to order-2 crosses and the number of feature crosses can still be large with a large number of features (after densification). The other limitation of FMs is that we require the embedding dimension of each feature be the same, which is limiting if our features have different cardinality needs.
Traditional approach is to mix implicit crossing (i.e. fitting a DNN to the features) with explicit crossing (say with the FM approach, or by multiplying raw features together etc.). The implicit network and explicit network are usually in parallel and the output is added together to form the final prediction.
DCNv1
The same authors proposed DCNv1 in 2017, and it is useful to see how it evolved. The method is as follows:
- Let represent a concatenated feature vector at layer 0. That is, we lay out each dense or sparse feature sideways and concatenate them into a long feature vector. Let .
- We have a cross and deep layer in parallel
- The deep side is simply a standard MLP, i.e.
- The cross side is where the magic happens:
- Note that are learnable parameters
- is a matrix of rank
1
. At layer1
, it comprises all the pairwise crosses, e.g. - Hence the transformation at each cross layer is rank
1
.
- As we increase the number of cross layers, we will get feature crosses of increasing polynomial degree. We end up with a -dimensional feature vector which comprises complex weighted polynomial feature crosses of polynomial degrees .
- At the final layer, we have . The two features are concatenated together to form a vector , which can then be fitted to a classifier head for final predictions.
DCNv2
The criticism of DCNv1 is that the transformation at each cross layer is rank 1
and hence not expressive enough. DCNv2 tries to make the cross layer more expressive while still making it parameter-efficient.
The cross layer formulation of DCNv2 is:
Where .
To see how it compares to DCNv1, we can let be a rank 1
matrix and . Furthermore, we set . Then we have:
Note that in line 2, we use the fact that is a scalar and move it out to the left. In line 3 since we can remove it.
Similarly for DCNv1, we can pull out the scalar:
We thus see that DCNv2 ends up in exactly the same form as DCNv1 (with just a missing term).
This reformulation helps us see that DCNv1 is DCNv2 when is rank 1
. Hence when we allow to be higher rank, we get more expressiveness than DCNv1.
Stack vs Parallel
In addition to the parallel structure proposed in DCNv1, where a deep MLP runs parallel to the cross network and the final vector is concatenated together, DCNv2 proposes an alternative stacked architecture. In this formulation, we run through the cross layers first to get . Then, this is fed into a deep MLP. The paper says that which architecture performs better depends on the task.
Loss
Finally, the loss is computed as standard binary cross entropy wrt the binary labels:
Modifications
Using ranking models in production settings usually has strict latency requirements, hence it is important to reduce cost while maintaining accuracy. The paper thus proposes 3 modifications to make the model more efficient.
Modification 1: Low Rank Approximation
In practice, the weight matrix is usually effectively low rank, so it is well motivated to approximate it with smaller matrices , where both . So we have:
For the experimental setting in the paper, was the low rank threshold after which they reported diminishing returns for increasing rank.
Modification 2: Mixture of Experts
Instead of just having one expert weight for each cross layer, they propose having multiple experts and then combining the expert outputs together using a gating mechanism. This is analogous to multi-headed attention with multiple heads. The idea is that each expert can learn effective feature crosses in a certain subspace. The input-dependent gating mechanism can then select the appropriate experts for a given input.
We have:
Where:
- is the gating function which represents the input-dependent weight of expert . It can be a learned softmax function.
- is the expert . It is simply the earlier equation but with separate weights for each expert .
Modification 3: Pre Activation Functions
With the low rank approximation, we effectively project the features to a low dimension and project it back up. Instead of immediately projecting back from dimension to , we can apply non-linear transformations. This allows the function to learn a richer set of representations.
Here, represents any non-linear activation function (like Relu) and is a learned weight. In the paper, the sigmoid function was chosen.
In practice, the tensorflow implementation seems to incorporate (i) low rank approximation and (ii) pre activation function, but does not do the mixture of experts.