DrugDBEmbed : Semantic Queries on Relational Database using Supervised Column Encodings

Bortik Bandyopadhyay, Pranav Maneriker, Vedang Patel, Saumya Yashmohini Sahai, Ping Zhang, Srinivasan ParthasarathyarXiv 2020

Abstract

Relational databases excel at syntactic matching but struggle with semantic queries that require understanding underlying relationships between entities. DrugDBEmbed addresses this by introducing a supervised approach to generate semantic embeddings for database columns. By training a Bidirectional Long Short-Term Memory (Bi-LSTM) model on known Drug-Drug Interactions (DDI), the system creates task-specific column encodings. These encodings enable complex semantic operations, such as analogy queries (A : B :: C : ?), directly within SQL environments. Evaluated on the DrugBank database, the model achieves high accuracy in DDI prediction and demonstrates the effectiveness of supervised learning in capturing biological relationships compared to unsupervised baselines.

Introduction

Traditional relational databases are optimized for "syntactic" matching, such as retrieving records based on exact string matches. However, they are inherently limited when handling "semantic" queries—for instance, identifying drugs that interact with a specific compound in the same manner as another known pair.

Previous attempts to bridge this gap often involved "textifying" database rows and applying unsupervised models like word2vec. These methods suffer from two primary drawbacks: they are task-agnostic, failing to leverage domain-specific gold-standard labels, and they often rely on simple vector averaging for multi-token columns, which loses structural and sequential meaning. DrugDBEmbed overcomes these limitations by employing a supervised pipeline that preserves sequence information and optimizes for specific predictive tasks.

Methodology

The core of DrugDBEmbed is a supervised pipeline centered on a Bidirectional Long Short-Term Memory (Bi-LSTM) network. Unlike unsupervised methods that merely observe word distributions, this model is trained on the specific task of predicting Drug-Drug Interaction (DDI) types.

Architecture of the supervised Bi-LSTM pipeline for DDI prediction and column encoding generation.

As shown in Figure 1, the model processes text attributes of drug pairs through an embedding layer and an LSTM encoder. To capture the relationship between two drugs, the system uses a "pair encoding" formula: $|e_i - e_j| \oplus (e_i \odot e_j)$, which combines both the difference and the element-wise product of the embeddings. Once trained, the hidden states of the Bi-LSTM are extracted as fixed-length d-dimensional vectors, serving as "column encodings." These encodings are stored back into the relational database, allowing users to perform "Analogy SQL" queries using the 3COSMUL formula to find biological analogies.

Experimental Setup

The researchers utilized the DrugBank database, encompassing 1,705 unique drugs and 191,728 DDI pairs. The supervision was guided by 86 distinct interaction types. The model's performance was evaluated across six text-based columns: ATC codes, Categories, Description, Merged Class, Protein Binding, and Target Action.

Dataset statistics and partitioning for different drug held-off percentages (1%, 2%, and 3%).

To ensure robustness, the study employed various "held-off" scenarios (1%, 2%, and 3%) to test the model's ability to generalize to unseen drugs. Figure 3 details the distribution of unique drugs and drug pairs across training, validation, and testing sets for these partitions.

Results and Analysis

The Bi-LSTM model demonstrated significant improvements over traditional baselines like K-Nearest Neighbors (KNN) and Random Forest. For structured text columns such as "Categories" and "ATC Codes," the model achieved accuracies and Weighted F1 scores exceeding 96%. This high performance suggests that the Bi-LSTM effectively captures the hierarchical and ontological structures inherent in medical data.

In analogy evaluation (e.g., "Drug A is to Drug B as Drug C is to ?"), the system showed high Precision@1. This indicates that the top result returned by the SQL query was frequently the correct biological match. While precision tended to decrease as the number of candidates (K) increased, the results confirm that supervised embeddings create much more meaningful clusters in the vector space than unsupervised alternatives.

Conclusion and Future Work

DrugDBEmbed illustrates that supervision is a powerful force multiplier for database embeddings. By training on medical outcomes rather than general word usage, the system generates encodings that are far more useful for discovery tasks.

However, several challenges remain. The current model is static; adding new drugs or interactions may necessitate expensive re-training. Furthermore, the current implementation focuses on single columns. Future research could explore "multi-view" learning to synthesize information from multiple attributes—such as chemical structures and clinical descriptions—into a single, unified drug embedding. Finally, incorporating human expert validation will be crucial for assessing the practical utility of the "near-miss" results in analogy queries.

Summary updated

Abstract

Traditional relational databases contain a lot of latent semantic information that have largely remained untapped due to the difficulty involved in automatically extracting such information. Recent works have proposed unsupervised machine learning approaches to extract such hidden information by textifying the database columns and then projecting the text tokens onto a fixed dimensional semantic vector space. However, in certain databases, task-specific class labels may be available, which unsupervised approaches are unable to lever in a principled manner. Also, when embeddings are generated at individual token level, then column encoding of multi-token text column has to be computed by taking the average of the vectors of the tokens present in that column for any given row. Such averaging approach may not produce the best semantic vector representation of the multi-token text column, as observed while encoding paragraphs or documents in natural language processing domain. With these shortcomings in mind, we propose a supervised machine learning approach using a Bi-LSTM based sequence encoder to directly generate column encodings for multi-token text columns of the DrugBank database, which contains gold standard drug-drug interaction (DDI) labels. Our text data driven encoding approach achieves very high Accuracy on the supervised DDI prediction task for some columns and we use those supervised column encodings to simulate and evaluate the Analogy SQL queries on relational data to demonstrate the efficacy of our technique.
BibTeX
@misc{bandyopadhyay2020drugdbembed,
  author = {Bortik Bandyopadhyay and Pranav Maneriker and Vedang Patel and Saumya Yashmohini Sahai and Ping Zhang and Srinivasan Parthasarathy},
  title = {{DrugDBEmbed : Semantic Queries on Relational Database using Supervised Column Encodings}},
  year = {2020},
  eprint = {2007.02384},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.02384},
}
Figure