In this work, we aim to study when learned models are better hash functions, particular for hash-maps. We use lightweight piece-wise linear models to replace the hash functions as they have small inference times and are sufficiently general to capture complex distributions. We analyze the learned models in terms of: the model inference time and the number of collisions. Surprisingly, we found that learned models are not much slower to compute than hash functions if optimized correctly. However, it turns out that learned models can only reduce the number of collisions (i.e., the number of times different keys have the same hash value) if the model is able to over-fit to the data; otherwise, it can not be better than an ordinary hash function. Hence, how much better a learned model is in avoiding collisions highly depends on the data and the ability of the model to over-fit. To evaluate the effectiveness of learned models, we used them as hash functions in the bucket chaining and Cuckoo hash tables. For bucket chaining hash table, we found that learned models can achieve 30% smaller sizes and 10% lower probe latency. For Cuckoo hash tables, in some datasets, learned models can increase the ratio of keys stored in their primary locations by around 10%. In summary, we found that learned models can indeed outperform hash functions but only for certain data distributions and with a limited margin.
翻译:在这项工作中, 我们的目标是在学习到的模型是更好的散列函数时, 特别是对于大麻- maps 来说, 我们的目标是在学习到的模型是更好的散列函数, 特别是对于大麻- maps 。 我们使用轻量的计件线性模型来取代散列函数, 因为它们的推论时间小, 并且足够笼统, 足以捕捉复杂的分布。 我们从以下角度分析学到的模型: 模型的推论时间和碰撞次数。 令人惊讶的是, 我们发现, 学习到的模型在最优化的情况下, 计算得比散列函数要慢得多。 然而, 事实证明, 学习到的模型只能减少碰撞次数( 也就是说, 不同键的次数与散列值相同) 。 对于桶链化表格来说, 我们发现, 学习到的模型能够比数据多得更多; 否则, 它不会比普通的散列函数更好。 因此, 如何更好地避免碰撞, 在很大程度上取决于数据和模型的能力。 为了评估所学到的模型的有效性, 我们使用这些模型在桶链和 Cuckoo h h h h how 表格中, 我们发现一些 缩缩缩缩缩的模型可以在 10 。