Introduction
Trees are the bread and butter of structured data, especially in Natural Language Processing (NLP), where they represent the syntactic structure of sentences. To compare two trees, researchers traditionally use Tree Kernels (TK). However, these traditional algorithms are slow, relying on dynamic programming that scales quadratically ($O(n^2)$) with the number of nodes in the trees.
While optimizations like "Fast Tree Kernels" (FTK) exist, they still struggle to scale to massive datasets because the kernel must be recomputed thousands of times during the training of a classifier (like an SVM). To break this complexity bottleneck, researchers introduced Distributed Tree Kernels (DTK), a method that moves from implicit, high-dimensional feature spaces to explicit, low-dimensional vector representations.
Methods: From Trees to Vectors
The core idea behind DTK is to map a tree $T$ into a fixed-size vector $\tilde{T} \in \mathbb{R}^d$ (where $d$ is typically 8192) such that the dot product of two vectors approximates the original tree kernel value.
Because enumerating all subtrees is computationally impossible, DTK uses a recursive embedding algorithm. Each node is assigned a nearly orthonormal random vector. These vectors are then combined moving up the tree using a "composition function." The paper explores two concrete ways to combine these vectors:
- Shuffled $\gamma$-product ($\boxtimes$): Uses element-wise multiplication combined with specific permutations to ensure non-commutativity (preserving the order of children).
- Shuffled Circular Convolution ($\boxplus$): Based on Holographic Reduced Representations, this uses circular convolution to bind vectors together.
By leveraging the Johnson-Lindenstrauss Lemma, high-dimensional tree structures can be projected into much smaller spaces while preserving relative distances. Generating the tree vector takes $O(n)$ time, and once generated, the kernel computation (the dot product) is $O(d)$—which is constant relative to the tree size.
Key Insights and Results
The authors evaluated DTK on standard NLP benchmarks, including Question Classification (QC) and Recognizing Textual Entailment (RTE).
The $\lambda$ Sweet Spot and Accuracy
Tree kernels use a decay factor ($\lambda$) to down-weight larger subtrees. The authors found that DTK approximates the original kernel best when $\lambda \le 0.4$, achieving a Spearman correlation of over 0.98 with the exact tree kernel. Fortunately, most NLP tasks actually perform better with these lower $\lambda$ values, making the approximation highly practical.
On the Question Classification task, DTK achieved accuracy levels (around 85-90%) that are statistically similar to the original Tree Kernel when operating in this optimal $\lambda$ range.
Constant-Time Speedup
The most significant advantage of DTK is its speed in production environments. Once the vector for a tree is pre-computed, comparing it to others takes the same amount of time regardless of whether the tree has 10 nodes or 1,000 nodes.
As the number of nodes in the trees increases, the computation time for traditional Fast Tree Kernels (FTK) grows exponentially, while DTK remains completely flat. For trees with a combined total of 320 nodes, DTK operates orders of magnitude faster than FTK.
Limitations and Future Work
While powerful, DTK has a few limitations:
- Large Subtree Approximation: DTK struggles to approximate the original kernel when $\lambda$ is close to 1.0. In these cases, the "active forest" (the set of subtrees being considered) becomes too large for the low-dimensional vector to represent accurately.
- The "Ideal" Function: An "ideal" composition function that perfectly satisfies all mathematical properties (like perfect non-associativity and bilinearity) does not exist; the method relies on statistical approximations that work "well enough" in practice.
- Dimensionality Trade-off: While $d=8192$ worked well in these experiments, there is an inherent trade-off between the size of the vector (memory/speed) and the accuracy of the kernel approximation that requires further exploration for different domains.
Summary updated