Understanding Inter-Session Intentions via Complex Logical Reasoning

Jiaxin Bai, Chen Luo, Zheng Li, Qingyu Yin, Yangqiu Song

Abstract

This paper introduces Logical Session Complex Query Answering (LS-CQA), a novel framework designed to model intricate user intentions that span multiple shopping sessions and involve complex logical constraints. To address the limitations of traditional recommendation systems, the authors developed the Logical Session Graph Transformer (LSGT). By treating sessions as ordered hyperedges and employing a Transformer architecture to reason across linearized logical tokens, LSGT outperforms existing models on major e-commerce benchmarks. The model demonstrates significant improvements in handling negations and exhibits strong zero-shot generalization to unseen query structures.

Introduction: The Challenge of Inter-Session Intent

Traditional recommendation systems excel at predicting the "next item" based on a single, isolated session. However, real-world shopping behavior is rarely so linear. A user might search for "Nike OR Adidas" shoes over several days, or purchase a mattress in one session and subsequently search for a matching bed frame while explicitly wanting to exclude further mattress results.

Existing methods typically struggle with these inter-session intentions because they often collapse a user's entire history into a single summary vector, which loses the fine-grained relationships between specific items and sessions. Furthermore, these systems are not designed to handle formal logical queries (e.g., "Find a wooden item desired in Session A but NOT desired in Session B"). The authors bridge this gap by framing session-based recommendation as a complex logical reasoning task on a hypergraph.

Examples of complex logical queries and their interpretations in the LS-CQA framework.

Methodology: The Logical Session Graph Transformer (LSGT)

The core innovation of this work is the Logical Session Graph Transformer (LSGT), which moves beyond standard graph-based approaches to capture the holistic context of user behavior.

1. Hypergraph Representation

Instead of a standard item-to-item graph, the model treats each shopping session as an "ordered hyperedge" connecting various items. This representation preserves the sequence of clicks while allowing the model to interpret the session as a single, unified unit of intent.

2. Tokenization and Linearization

Unlike previous logical reasoning models that rely on specialized geometric embeddings (such as box or rotation embeddings), LSGT linearizes the entire problem space. Items, sessions, and logical operators—including Intersection (AND), Union (OR), and Negation (NOT)—are all converted into discrete tokens. This approach allows the model to leverage the symbolic reasoning capabilities of modern architectures.

3. Transformer-Based Reasoning

These tokens are fed into a standard Transformer encoder, enabling "any-to-any" attention. This means an item in an early session can directly interact with a logical operator or an item in a much later session during the encoding process. The authors provide theoretical grounding for this approach, proving that LSGT is more expressive than standard Message-Passing Neural Networks (like GCNs) and satisfies the Relational Weisfeiler-Lehman (RWL) test for graph isomorphism.

The Logical Session Graph Transformer (LSGT) architecture, illustrating the linearization of items, sessions, and logical structures into tokens for a Transformer encoder.

Experimental Evaluation

The authors evaluated LSGT on three major e-commerce benchmarks: Amazon (multi-locale shopping), Diginetica (transactional data), and Dressipi (fashion-specific attributes). For each dataset, 14 different logical query structures were constructed to test everything from simple item prediction to complex multi-hop reasoning with negations.

Key Results

  • State-of-the-Art Performance: LSGT achieved SOTA results across all three datasets.
  • Superior Negation Handling: The model showed a significant lead in queries involving the "NOT" operator, improving Mean Reciprocal Rank (MRR) by up to 2.93 points on the Amazon dataset compared to the best baselines.
  • Zero-Shot Generalization: When tested on "out-of-distribution" query structures never seen during training, LSGT outperformed baselines by 1.28 to 3.22 MRR points. This suggests the model truly learns the logic of the operators rather than merely memorizing patterns.
  • Ablation Insights: Removing "Logic Structure" tokens resulted in a massive performance drop, confirming that explicit logical reasoning is the primary driver of the model's success.

Conclusion and Future Work

LSGT demonstrates that treating session-based recommendation as a logical reasoning task on hypergraphs allows for a much more nuanced understanding of user intent. While currently focused on e-commerce, this framework could potentially be applied to social networks or academic citation graphs. Future research may involve incorporating richer data sources, such as natural language descriptions or images, and improving the scalability of the attention mechanism for extremely long user histories.

Summary updated

BibTeX
@inproceedings{bai2023understanding,
  author = {Jiaxin Bai and Chen Luo and Zheng Li and Qingyu Yin and Yangqiu Song},
  title = {{Understanding Inter-Session Intentions via Complex Logical Reasoning}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2023},
}
Figure