Incorporating Deep Learning Design in Database Queries
Yuval Lev Lubarsky, Dean Light, Boaz Berger, Shunit Agmon, Benny Kimelfeld · 2026
Read Incorporating Deep Learning Design in Database Queries by Yuval Lev Lubarsky, Dean Light, Boaz Berger, Shunit Agmon, Benny Kimelfeld (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-24207.txt.
Introduction
Lubarsky and four co-authors bring deep-learning design inside database queries instead of shuttling data outside. Conventional pipelines translate relational data into graphs and run graph neural networks elsewhere, paying overhead for the round trip, yet those networks operate on tuple embeddings shaped by joins. The authors attach provenance to each tuple as a learnable vector embedding, then lift queries to act jointly on data and embeddings. Their RelaNN, built on PyTorch and cuDF, implements graph convolutional, heterogeneous transformer, hypergraph, and homomorphism networks with short programs.
Catalog record
| CREATOR | Yuval Lev Lubarsky, Dean Light, Boaz Berger, Shunit Agmon, Benny Kimelfeld |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 52524 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2605.24207
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Incorporating Deep Learning Design in Database Queries Yuval Lev Lubarsky, Dean Light, Boaz Berger, Shunit Agmon, Benny Kimelfeld Abstract . Deep learning over relational databases is conventionally realized by translating data into graph representations and applying graph-based neural networks within external frameworks . This round-trip between the database and external machine learning (ML) systems introduces non-trivial engineering overhead. In effect, these graph neural networks operate on tuple embeddings and manipulate them in ways that capture the interactions induced by relational joins. Given this natural correspondence, there is no fundamental reason why specifying a neural network over relational data should be substantially harder than querying it. We propose an approach that naturally integrates deep learning with database queries. The key idea is to associate each tuple with provenance, represented as a vector embedding with learnable parameters. Queries are lifted to operate jointly on data and embeddings, mapping input relations with embedded tuples to output relations with embedded tuples. This approach provides a declarative foundation for relational deep learning, facilitating integration with database systems, optimization, and wide adoption. We describe RelaNN, a proof-of-concept implementation of this approach built on top of PyTorch and cuDF. We illustrate the utility of RelaNN by implementing various graph-learning models, including graph convolutional networks, heterogeneous graph transformers, hypergraph neural networks and deep homomorphism networks. The simplicity of the programs and their competitive runtime performance demonstrate a concrete path toward making the implementation of state-of-the-art neural networks over databases as simple as writing a query. 1. Introduction Integrating databases and machine learning (ML) is a central challenge in data science. Both paradigms are fundamental to data-driven workflows: databases provide powerful abstractions for modeling, querying, and managing data, while ML enables the extraction of predictive models from it. However, they traditionally rely on different modeling primitives and implementation strategies, making their integration nontrivial. As a result, bridging the gap between databases and ML has been a major challenge in database foundations over the past decades ( 1 ; 40 ) , and has motivated dedicated workshops at leading database conferences. Previous efforts to bridge this gap range from adding black-box ML functionalities to the database ( 22 ; 29 ) , through integrating ML building blocks into DBMS kernels ( 26 ; 31 ) , to creating unified languages for both operation types ( 32 ; 44 ; 45 ; 30 ; 25 ) . Advances in deep neural networks, particularly neural networks over graphs ( 43 ; 52 ; 37 ) , have fundamentally advanced relational deep learning by enabling prediction models to operate directly over structured data, avoiding ad-hoc feature engineering. Building on graph learning infrastructure, the common approach to applying deep learning over relational databases is to translate the data into a graph representation: records become nodes and foreign-key relationships become edges. A model (e.g., a GNN) is designed and trained over the resulting graph outside of the database context ( 13 ; 5 ; 48 ; 33 ; 7 ; 10 ) . To capture schema information of the database, architectures like GNNs and graph transformers have been extended to heterogeneous settings, where nodes and edges are associated with different types ( 54 ; 50 ) . Hence, designing a neural network over a relational database amounts to developing a predictive model over the induced graph using imperative ML graph libraries such as PyTorch Geometric ( 15 ) , DGL ( 49 ) , or Scikit-network ( 3 ) , which act as abstractions over PyTorch, providing the graph operations that are cumbersome to write in raw tensor code. The role of the database query language is reduced to exporting the database into a tensor representation of a graph, and reintegrating the predictions back into the database for further processing. We argue that this round-trip is unnecessary, and that it arises from an artificial separation of abstractions that forces developers to work across disparate paradigms. Instead, relational query languages are inherently well-suited for designing neural networks over relational databases, given an appropriate extension of the relational model. From this perspective, applying graph-learning architectures to a database amounts to manipulating tuple embeddings , where each tuple is associated with a (parametric) numeric vector, and the resulting computations reflect interactions between tuples through relational operations. In particular, similarly to the abstraction of database provenance as semirings ( 20 ; 19 ) , joins should determine not only how tuples are combined, but also how their embeddings are composed, while projections (grouping) should determine how embeddings are aggregated. By extending the relational model with these embedding semantics, we can express deep-learning architectures directly over the database, without resorting to intermediate graph representations. This allows developers to seamlessly design neural models using familiar, declarative query-language constructs such as SQL and Datalog. As an example, the following program represents query-key-value attention as used by heterogeneous graph transformers ( 23 ) , over a dataset of patients and treatments. Score ( p , t ; q * k ) :- Treat ( p , t ), Queries ( p ; q ), Keys ( t ; k ) . Attention ( p ; sum ( a * v )) :- Score ( p , t ; a ), Values ( t ; v ) . Each relation is written as R(\vec{x};z) , pairing ordinary content attributes \vec{x} with a tuple embedding z . The first rule derives Score by joining the three relations on their shared variables p and t : Treat links each patient p to the treatment t it received and carries no embedding. Queries and Keys attach a query vector q to each patient and a key vector k to each treatment. The join brings q and k together on every linked pair (p,t) , and the head records their product q*k as that pair’s embedding. The second rule joins Score with the treatment values Values on the shared attribute t , weighting each value v by its score a . Its head, Attention , keeps only the patient p and drops t . This projection groups the treatments by patient and applies sum , aggregating the weighted values a*v to a single embedding per patient. The program maintains an assignment of values to its parameters, and training adjusts them by minimizing a loss function. Our approach adopts the idea of representing every database fact in two domains—the logical domain having the traditional database context, and the numerical domain that associates a meaning in the Euclidean space and allows for numerical reasoning, as studied in prior work on tuple embedding ( 48 ; 5 ; 4 ; 33 ; 36 ; 11 ) . This is contrasted with existing in-database ML frameworks that typically bridge the two domains by integrating tensor data types and linear algebra operators into the query engine ( 32 ; 44 ; 45 ; 30 ; 26 ; 31 ) , as also endorsed by the recent Tensor Logic ( 12 ) that unifies neural and symbolic AI by treating relations as sparse Boolean tensors, interpreting joins as tensor products and projections as sums over dropped dimensions. These frameworks require the user to explicitly define and maintain the connection between the logical and the