[Paper Review] Sequential Query Encoding For Complex Query Answering on Knowledge Graphs
This paper proposes Sequential Query Encoding (SQE), a simplified neural approach for complex query answering on knowledge graphs. Instead of parsing queries into computational graphs and recursively executing parameterized operators, SQE linearizes the query into a token sequence and encodes it using a sequence encoder like LSTM or Transformer. SQE achieves state-of-the-art performance on in-distribution queries and comparable generalization to out-of-distribution queries, demonstrating that direct sequence encoding can outperform complex operator-execution pipelines.
Complex Query Answering (CQA) is an important and fundamental task for knowledge graph (KG) reasoning. Query encoding (QE) is proposed as a fast and robust solution to CQA. In the encoding process, most existing QE methods first parse the logical query into an executable computational direct-acyclic graph (DAG), then use neural networks to parameterize the operators, and finally, recursively execute these neuralized operators. However, the parameterization-and-execution paradigm may be potentially over-complicated, as it can be structurally simplified by a single neural network encoder. Meanwhile, sequence encoders, like LSTM and Transformer, proved to be effective for encoding semantic graphs in related tasks. Motivated by this, we propose sequential query encoding (SQE) as an alternative to encode queries for CQA. Instead of parameterizing and executing the computational graph, SQE first uses a search-based algorithm to linearize the computational graph to a sequence of tokens and then uses a sequence encoder to compute its vector representation. Then this vector representation is used as a query embedding to retrieve answers from the embedding space according to similarity scores. Despite its simplicity, SQE demonstrates state-of-the-art neural query encoding performance on FB15k, FB15k-237, and NELL on an extended benchmark including twenty-nine types of in-distribution queries. Further experiment shows that SQE also demonstrates comparable knowledge inference capability on out-of-distribution queries, whose query types are not observed during the training process.
Motivation & Objective
- To address the complexity and potential over-parameterization of existing query encoding (QE) methods that rely on recursive execution of neuralized operators.
- To explore whether a simpler, unified sequence encoder can replace the multi-step operator parameterization and execution pipeline in query encoding.
- To evaluate faithfulness and compositional generalization of query encoding models on both in-distribution and out-of-distribution query types.
- To investigate the impact of positional encoding design on compositional generalization in Transformers for knowledge graph reasoning.
Proposed method
- SQE linearizes the computational graph of a logical query into a sequence of tokens using a search-based algorithm.
- A sequence encoder—such as LSTM or Transformer—is applied to the token sequence to generate a dense vector representation (query embedding).
- The query embedding is used to retrieve answer entities via similarity scoring in the embedding space, bypassing recursive operator execution.
- The method employs relative positional encoding (RPE) in the Transformer to improve performance on out-of-distribution queries.
- The model is trained end-to-end with joint optimization of entity embeddings and neural encoder parameters.
- The approach avoids explicit operator parameterization and execution, replacing it with a single, unified encoding step.

Experimental results
Research questions
- RQ1Can a direct sequence encoding approach outperform the standard operator-parameterization-and-execution pipeline in query encoding for knowledge graphs?
- RQ2How does SQE perform on in-distribution queries compared to existing state-of-the-art query encoding methods?
- RQ3To what extent can SQE generalize to out-of-distribution queries not seen during training?
- RQ4Does the design of positional encoding in Transformers affect compositional generalization in complex query answering?
Key findings
- SQE achieves state-of-the-art performance on in-distribution queries across FB15k, FB15k-237, and NELL, outperforming existing neural query encoding methods.
- SQE demonstrates comparable knowledge inference capability to prior methods on out-of-distribution queries, indicating strong compositional generalization.
- The use of relative positional encoding (RPE) in the Transformer significantly improves performance on out-of-distribution queries, suggesting that standard positional encoding hinders generalization.
- The results show that the complexity of recursive operator execution in existing QE methods may be unnecessarily high, as a single sequence encoder can achieve superior or comparable results.
- SQE’s simplicity—relying on linearization and sequence encoding—proves effective without requiring explicit modeling of set operations or projection functions.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.