Similarity-Constrained Reweighting for Complex Query Answering on Knowledge Graphs

Daniel Daza, Alberto Bernardi, Luca Costabello, Christophe Gueret, Michael Cochez, Martijn SchutarXiv 2026

Imagine you’re trying to find a new medication for a persistent migraine. You don’t just want any drug; you want something that works like Ibuprofen but treats a condition similar to a cluster headache.

In the world of Knowledge Graphs (KGs)—those massive webs of interconnected facts like "Ibuprofen treats Headache"—this is a "Complex Query." Usually, we use logic to navigate these graphs. But logic is brittle. If the graph is missing a single link, the logic fails. Machine learning helps by predicting those missing links, but until now, adding "fuzzy" preferences (like "similar to Ibuprofen") into the middle of a complex search was a mathematical nightmare.

TL;DR

SCORE (Similarity-COnstrained REweighting) is a lightweight "plug-and-play" layer that lets you add soft constraints—like "I want something similar to X"—to any part of a complex database query. It improves search results without requiring you to retrain your expensive AI models, making knowledge graph searches both more flexible and more accurate.

What Problem Does This Paper Address?

Knowledge Graphs are inherently incomplete. To find answers, researchers use Complex Query Answering (CQA) models that treat entities (like "Migraine" or "Ibuprofen") as vectors of probabilities.

The problem? Standard CQA is built on rigid first-order logic (AND, OR, NOT). If you want to find "drugs that treat diseases like migraine," current systems struggle. Previous attempts could only apply "similarity" filters at the very end of the query (the target). But real-world questions often have constraints in the middle. If your "waypoint" is fuzzy, the whole logical chain usually falls apart because the math for combining "logical truth" with "similarity scores" is tricky to balance.

Methods

The authors introduce SCORE, a method that is surprisingly simple yet mathematically principled.

Instead of building a new, heavy neural network, SCORE acts as a reweighting layer that can be injected into standard CQA operations like Projection (moving from "Headache" to "Drugs") and Intersection (finding things that satisfy two conditions at once).

Figure 2: Existing CQA methods compute fuzzy vectors via projection and intersection operators. We illustrate how we integrate the SCORE update (Equation (9)), by applying it after these operations have been computed by the base CQA model, with ∆s indicating similarity scores.

Here’s the "secret sauce":

  1. Embedding Similarity: It uses pre-trained entity embeddings (think of these as the "coordinates" of an entity in a concept space) to calculate how similar a candidate is to a small set of user-provided examples.
  2. The Logit Shift: Instead of multiplying probabilities (which can cause scores to "vanish" to zero very quickly), SCORE moves the scores into logit space.
  3. Bayesian Intuition: In logit space, adding a similarity score is mathematically equivalent to a Bayesian update. It treats your preference as "new evidence" that shifts the probability.
  4. Sigmoid Mapping: After the shift, it maps the scores back to a 0-to-1 range so the rest of the logical query can continue normally.

Datasets

The researchers put SCORE to the test on three heavy-hitters in the KG world:

  • FB15K-237: A standard benchmark of general world facts.
  • NELL-995: A dataset of facts "learned" from the web.
  • Hetionet: A complex biomedical graph containing genes, compounds, and diseases—perfect for testing those "drug discovery" style queries.

They also used a specialized benchmark where "similarity" was defined by clusters of textual descriptions, ensuring the "soft constraints" actually meant something to a human.

Key Insights and Ideas

  • Constraints Anywhere: The biggest "aha" moment is that constraints on intermediate variables actually help more than constraints on the final answer. By narrowing the search space early, the model propagates better information through the logical chain.
  • Logits > Probabilities: By performing updates in logit space, the authors avoided the "vanishing gradient" style problems that plague fuzzy logic. It keeps the signal alive even through 3 or 4 steps of a query.
  • Interpretability: Because SCORE is a simple additive shift, you can actually look at a result and say, "This drug moved up in the rankings specifically because it is 80% similar to the 'Ibuprofen' example you gave me."

Key Results

SCORE doesn't just work; it's efficient.

  • Ranking Boost: It significantly improved NDCG (a measure of ranking quality) across all datasets. It effectively pushed "preferred" answers to the top without losing the "correct" logical answers.
  • Robustness: It handled "noisy" preferences well. Even if 40% of your example entities were wrong, SCORE still managed to improve the search results compared to the base model.
  • Speed: The computational overhead is minimal. Adding SCORE only adds a few milliseconds to query times, making it viable for real-time applications.
Figure 1: Illustration of three approaches for query answering on knowledge graphs, with vectors indicating entity scores at different steps. Left: a traditional query with purely logical constraints. Middle: incorporating similarity constraints in NQR [10], which supports only the target variable via uncalibrated score adjustments (shown in red and blue). Right: SCORE, which supports similarity constraints on arbitrary variables through normalized similarity scores.

Limitations and Future Work

The authors are upfront about a few hurdles:

  • Garbage In, Garbage Out: SCORE relies on the quality of the underlying entity embeddings. If your embeddings think "Apple" (the fruit) and "Apple" (the tech giant) are the same thing, SCORE will struggle.
  • Manual Examples: Currently, you need to provide a "preference set" of examples. The authors suggest that future versions could use Large Language Models (LLMs) to automatically generate these sets from a natural language prompt like "Find me something like aspirin."

In short, SCORE takes the rigid world of graph logic and gives it a much-needed dose of human-like flexibility, all without breaking the bank on compute power.

Summary updated

Abstract

Machine learning models for Complex Query Answering (CQA) on knowledge graphs estimate the likelihood of answers that are not reachable via direct traversal. Recent work has proposed extending such queries with soft entity constraints, which require the target variable to be similar or dissimilar to specified sets of entities. We study a more general formulation where similarity constraints are specified on an arbitrary variable in a query, and introduce SCORE: a computationally efficient and interpretable method for incorporating similarity constraints on an arbitrary variable of a query. SCORE is based on a lightweight and interpretable score adjustment function that only requires tuning two hyperparameters on a validation set. Our experiments show that SCORE effectively incorporates preferences while maintaining strong query answering performance. It significantly improves ranking quality when constraints apply to the target variable and performs effectively in the more general case involving constraints on intermediate variables, and its performance remains robust when applied to several existing methods for CQA. Our implementation is available at https://github.com/dfdazac/score.
BibTeX
@misc{daza2026similarity,
  author = {Daniel Daza and Alberto Bernardi and Luca Costabello and Christophe Gueret and Michael Cochez and Martijn Schut},
  title = {{Similarity-Constrained Reweighting for Complex Query Answering on Knowledge Graphs}},
  year = {2026},
  eprint = {2611.29596},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.29596},
}
Figure