Some question-answering agents work by walking a knowledge graph, a network of facts stored as (entity, relation, entity) triples, hop by hop until they stop at an answer. They are trained with reinforcement learning, but they receive a reward only at the very end, and only if the stopping entity is a recorded answer. That signal is sparse and also wrong in a specific way: a correct answer that happens to be missing from the incomplete graph earns zero. The standard remedies are hand-built. One is a frozen embedding model that scores the final entity. Another is a fixed clustering that defines intermediate milestones. Neither tells the agent, mid-walk, whether it is still on a road that leads anywhere.
We propose to learn that mid-walk signal directly, without hand-built milestones. A small graph-attention network looks only at an entity's local neighborhood, using edge types, and is trained to predict one quantity: whether some answer to the current query lies within the remaining number of hops. Training labels come for free from breadth-first search on the training graph. The network's output is then used as a potential for potential-based reward shaping. This is a standard construction that adds dense step-by-step feedback while provably leaving the optimal policy unchanged. In two sentences: we turn "can I still reach an answer from here in k hops?" into a supervised graph-attention problem with free labels, and feed it to the walking agent as dense, policy-safe shaping. The aim is to test whether structure-aware, horizon-aware shaping beats the embedding-similarity shaping that the field currently relies on.
Core Claim
Existing shaping for knowledge-graph walkers scores the wrong thing. Multi-Hop Knowledge Graph Reasoning with Reward Shaping gives a soft terminal reward from a pre-trained ConvE or ComplEx model. That model answers "is this entity plausibly an answer?" It does not answer "is an answer reachable from this entity in the hops I have left?", and it is used only at the halt. The authors explicitly leave learnable, jointly optimized shaping open. Enhancing Multi-Hop Knowledge Graph Reasoning through Reward Shaping Techniques swaps in a T5 prompt-based shaper transferred from a dense subgraph, but it is still a terminal, frozen plausibility score. Learning to Walk with Dual Agents for Knowledge Graph Reasoning adds intermediate milestone rewards via K-means clusters over TransE. Those clusters are fixed before training, and the authors report that misclustering misleads the agent unrecoverably.
Our claim is that a horizon-conditioned reachability potential gives a dense, policy-invariant signal that these plausibility scores cannot. The potential is computed by sparse, neighbor-masked, relation-aware attention and supervised by breadth-first-search labels. The claimed benefit should grow with path length and with graph branching.
Research Program
State and potential. An agent state is $s_t = (e_t, q, r, k_t)$. Here $e_t$ is the current entity, $(q, r)$ is the query (source entity and relation), and $k_t$ is the number of hops remaining. The potential network outputs $\Phi(s_t) \in [0,1]$, an estimate of whether an answer to $(q, r)$ lies within $k_t$ hops of $e_t$. The agent's per-step reward becomes
$$r'_t = r_t + \gamma\,\Phi(s_{t+1}) - \Phi(s_t),$$
where $r_t$ is the original sparse reward and $\gamma$ the discount. This is exactly the potential-based form used by Reward Propagation Using Graph Convolutional Networks, which supplies the invariance argument we reuse.
Training the potential. For each training query we remove the direct query edge, as standard evaluation protocols do, to avoid leakage. We then run breadth-first search from every entity in a bounded neighborhood to the set of known answers $A(q,r)$, and train with
$$\mathcal{L} = -\sum_{(e,q,r,k)} \Big[ y \log \Phi + (1-y)\log(1-\Phi) \Big], \quad y = \mathbb{1}\big[d(e, A(q,r)) \le k\big],$$
where $d$ is directed hop distance on the training graph. No human writes a milestone. Because breadth-first search runs only on training facts, the labels never use test answers. At test time the network must generalize from relation patterns, since the answer set is unknown.
Architecture: methodological constraint. What Structural Inductive Bias Helps Transformers Reason Over Knowledge Graphs? builds a relation-aware sparse-attention model (RASA) and ablates its components on supervised question answering. It finds two things. Masking attention to graph neighbors accounts for nearly all multi-hop gains, for example +72.5 points on 3-hop MetaQA. Learned relation biases without masking fall below a vanilla transformer, at 2.1% versus 2.7% on Complex WebQuestions.
We take this as a design constraint rather than a curiosity. The potential network is a RASA-style encoder over the $k$-hop subgraph of $e_t$, with:
- attention masked to graph neighbors;
- edge-type biases and relation-conditioned query scaling layered on top of the mask;
- conditioning on embeddings of $r$ and $q$ and on $k$.
We implement the mask over sparse edge lists rather than dense adjacency, to avoid the roughly 6x slowdown RASA reports.
Joint refinement. This addresses Lin et al.'s open problem. After pre-training on breadth-first-search labels, we periodically refit $\Phi$ on the agent's own rollouts, every $N$ episodes. The refit targets are the observed terminal outcomes of states the agent actually visits. The schedule is modeled on how Adaptive Reward Design for Reinforcement Learning re-estimates distances on an automaton from empirical success. Because the shaping is potential-based, a miscalibrated $\Phi$ can slow learning but cannot change which policy is optimal.
False negatives: separating two jobs. Potential-based shaping, by construction, preserves the sparse optimum. That optimum still penalizes correct but unrecorded answers, so the shaping alone does not fix false negatives. We therefore treat the two jobs as separate components and ablate them independently:
- Dense credit assignment comes from the potential.
- False-negative softening comes from using $\Phi(e, q, r, 0)$, "is $e$ itself an answer?", as a terminal soft reward in the style of Lin et al. This replaces their ConvE scorer.
This makes explicit a conflation that prior work leaves implicit.
Baselines
Do-nothing reference. This is the sparse-reward walker, MINERVA, with the same LSTM policy, action space, and rollout budget as every other arm. It anchors how much any shaping helps.
Strongest existing method. This is Lin et al.'s ConvE-shaped walker with action dropout. On FB15k-237 that paper reports MRR 40.7, against 29.3 for MINERVA. We reproduce it with their released hyperparameters and give it the same tuning budget as our method: a fixed number of trials over the learning rate, action-dropout rate, and shaping scale. Beating it means a statistically reliable MRR gain over our reproduction across five seeds. We also report whether our method clears 40.7 itself.
On WN18RR, CURL is the comparison, reporting Hits@1 of 42.9. On UMLS, Li et al. report MRR 0.930 for their prompt-learning shaper. Their protocol uses a rich/sparse split, so we compare only under that split. For Lin et al. on WN18RR, NELL-995, UMLS, and Kinship, there is no reported result found on Lacuna, and we will rerun those settings ourselves.
Isolating the key ingredient. The ablations that matter most are the following:
- ConvE-as-potential. We plug the ConvE answer probability into the same potential-based shaping formula. This separates "dense shaping" from "reachability with graph structure".
- Isotropic graph convolution. We use the same breadth-first-search labels with an isotropic graph-convolution potential, following Reward Propagation Using Graph Convolutional Networks. This tests whether edge types matter.
- Mask removed. We remove the neighbor mask while keeping relation parameters. RASA predicts this collapses.
- Horizon removed. We drop $k$ from the conditioning.
Supervised ceiling. As an upper reference, not a target, we include a supervised RASA ranker trained directly on answers. RASA reports 92.6% on 3-hop MetaQA. This tells us how much accuracy the path-producing agent gives up.
Why not just…?
Why not just use ConvE scores as a per-step potential? This is the cheapest version of the idea and a real threat. ConvE scores an entity's plausibility as the answer. It is blind to whether answers are reachable within the remaining hops. An entity two hops from every answer may score near zero, so the potential is flat exactly where guidance is needed. The ConvE-as-potential ablation settles this. If it matches our method on long paths, the attention encoder is unnecessary, and we would report that shaping placement, not architecture, is the contribution.
Why not just train an actor-critic value function? A critic is a learned "how good is this state" estimate, and using $\Phi = V$ is close to our construction. However, a critic learns only from the agent's own sparse returns, so it inherits the sparsity it is supposed to cure. Our potential is supervised by breadth-first-search labels across all training queries from the start. We run an advantage actor-critic with an identical encoder and compare learning curves. The prediction is that the gap is largest early in training and on long-horizon queries. If the gap is absent, the free labels are not adding information.
Why not just answer the query with a supervised relation-aware model and skip reinforcement learning? On accuracy alone this may win; RASA's 92.6% on 3-hop MetaQA is high. The walker's value is an explicit, checkable reasoning path. Our claim is restricted to making path-finding agents train better, and we report the supervised ceiling so the cost of paths is visible.
Why not just use an isotropic graph network on the transition graph? Learning Goal-Conditioned Policies Offline with Self-Supervised Reward Shaping builds reachability-graph rewards for continuous control. It found directed graphs beat undirected ones by 11% on RoboYoga. Knowledge graphs are directed and typed, and an isotropic Laplacian discards both. The isotropic ablation tests whether this matters for knowledge graphs specifically.
Proposed Experiments
Benchmarks and metrics. We run on FB15k-237, WN18RR, NELL-995, UMLS, and Kinship using standard splits, reporting MRR and Hits@1/3/10. We add 3-hop MetaQA as a long-horizon stress test. For each arm we also report sample efficiency (MRR versus rollouts) and shaping overhead (wall-clock per rollout).
Long-path check. We stratify test queries by the shortest path length to the answer. The prediction is that our gain over Lin et al. grows with path length and is near zero on short paths. This is consistent with Lin et al.'s observation that NELL-995, dominated by one-to-one relations, benefits little.
Masking check. The mask-removed potential should underperform even the isotropic one. That would confirm RASA's supervised finding carries over to reward models.
Generalization check. We use RASA's zero-shot relation holdout protocol. RASA reports that masking-based attention degrades by 7.2 points while R-GCN degrades by 29.2. We test whether shaping quality degrades similarly, measured by agent MRR on held-out relations.
False-negative check. We delete 20% of test-relevant training facts and measure two things: how often the agent halts at a deleted-but-true entity, and how this changes with and without the soft terminal reward $\Phi(\cdot,0)$.
What falsifies the proposal. If the ConvE-as-potential or actor-critic arm matches the full method on long-path queries, the proposal is falsified.
References
- Multi-Hop Knowledge Graph Reasoning with Reward Shaping
- Enhancing Multi-Hop Knowledge Graph Reasoning through Reward Shaping Techniques
- Learning to Walk with Dual Agents for Knowledge Graph Reasoning
- Reward Propagation Using Graph Convolutional Networks
- What Structural Inductive Bias Helps Transformers Reason Over Knowledge Graphs?
- Adaptive Reward Design for Reinforcement Learning
- Learning Goal-Conditioned Policies Offline with Self-Supervised Reward Shaping