Context-Aware Query Rewriting for Improving Users’ Search Experience on E -commerce Websites (2023)

Abstract: E-commerce queries are often short and ambiguous. Consequently, query understanding often uses query rewriting to disambiguate user-input queries. While using e-commerce search tools, users tend to enter multiple searches, which we call context, before purchasing. These history searches contain contextual insights about users’ true shopping intents. Therefore, modeling such contextual information is critical to a better query rewriting model. However, existing query rewriting models ignore users’ history behaviors and consider only the instant search query, which is often a short string offering limited information about the true shopping intent. We propose an end-to-end context-aware query rewriting model to bridge this gap, which takes the search context into account. Specifically, our model builds a session graph using the history search queries and their contained words. We then employ a graph attention mechanism that models cross-query relations and computes contextual information of the session. The model subsequently calculates session representations by combining the contextual information with the instant search query using an aggregation network. The session representations are then decoded to generate rewritten queries. Empirically, we demonstrate the superiority of our method to state-of-the-art approaches under various metrics.

## introduction query rewriting is a task where a user inputs a potentially problematic query (e.g., typos or insufficient information), and we rewrite it to a new one that better matches the user's real shopping intent. this task plays an important role in e-commerce query understanding, where without proper rewriting, search engines often return undesired items, rendering the search experience unsatisfactory. one major issue that impedes query rewriting is the ambiguity of queries. for example, figure 1 (left) demonstrates searching for "bumblebee costumes" without considering search context. from the query alone, it is implausible to tell if the user's intent is for costumes of actual bumblebee (i.e., the animal) or the character from the movie franchise. this type of ambiguity is common in ecommerce search, where queries are usually short (only 2-3 terms) and insufficiently informative @xcite . therefore, it is not possible to disambiguate queries using only the instant search. a common solution is to use statistical rules to differentiate the possible choices. specifically, in our example, suppose a total of 100 users entered the "bumblebee costumes" query, and 70 of them eventually purchased the movie character costume. when a new user searches for the same query, the recommended products will consist of 70% movie character costumes and 30% animal costumes. this procedure is problematic because each user has a specific intent, i.e., either the movie character costume or the animal costume, but rarely both, which the aforementioned method fails to address. we propose to explore contextual information from users' history searches to resolve the query ambiguity issue. taking the "bumblebee costumes" example again, in figure 1 (right), suppose a rewriting model recognizes that the user searched for "transformers movie" earlier, then it could infer that the user's purchase intent is the movie character costume, and hence can remove the input ambiguity. there have been existing works that utilize search logs for query rewriting. for example, @xcite use traditional tf-idf-based similarity metrics to capture relational information among the user's history searches. these approaches are too restrictive to handle the increasingly complex corpus nowadays. as such, the rewritten queries significantly differ from the original one in intent. more recently, neural network-based query rewriting algorithms @xcite @xcite are proposed. most of such approaches employ a multi-stage training approach. consequently, they involve complicated hand-crafted features or require excessive human annotations for the intermediate features (sometimes both). to overcome the drawbacks of existing methods, we propose an end-to-end context-aware query rewriting algorithm. our model's backbone is the transformer @xcite . in our contextaware model, the transformer encoder learns representations for individual history queries. the representations are further transformed to carry crossquery relational information using a graph attention mechanism (gat, @xcite . the gat computes contextual information of a session based on a session graph, where its nodes contain the history queries and the tokens contained in the history queries. after obtaining the contextual information from the gat, it is aggregated with the instant search using an aggregation network. the augmented information is subsequently fed into the transformer decoder to generate rewritten queries. our proposed method improves upon existing works from three aspects. first, our model does not involve recursion, unlike conventional recurrent neural network-based approaches @xcite @xcite . this facilitates training deep models containing dozens of layers capable of capturing high-order information. second, our end-to-end sequence-to-sequence learning formulation eliminates the necessity of excessive labeled data. previous approaches @xcite require the judgment of "semantic similarity", and thus crave for human annotations, which are expensive to obtain. in contrast, our method uses search logs as supervision, which does not involve human effort, and are cheap to acquire. third, our method can lever-age powerful pre-trained language models, such as bart @xcite . such models contain rich semantic information and are successful in numerous natural language processing tasks @xcite @xcite . we demonstrate the effectiveness of our method on in-house data from an online shopping platform. our context-aware query rewriting model outperforms various baselines by large margins. notably, comparing with the best baseline method (transformer-based model), our model achieves 11.6% improvement under the mrr (mean reciprocal rank) metric and 20.1% improvement under the hit@16 metric (a hit rate metric). we further verify the effectiveness of our approach by conducting online a/b tests. ## related works one line of work uses statistical methods. for example, @xcite extract probabilistic correlations between the search queries and the product descriptions. other works extract features that are related to the user's current search @xcite , or from relational information among the user's history searches @xcite @xcite @xcite . there are also statistical machine translation-based models @xcite that employ sequence-to-sequence approaches. the aforementioned statistical methods suffer from unreliable extracted features, such that the rewritten queries differ from the original one in intent. another line of work focuses on neural query rewriting models @xcite @xcite . these models adopt recurrent neural networks (rnns, @xcite to learn a vectorized representation for the user's search query, after which knn-based methods are used to find queries that yield similar representations. one major limitation is that the rewritten queries are limited to the previously presented ones. also, these methods often involve complicated and ungrounded feature function designs, e.g., @xcite and @xcite hand-crafted 18 feature functions, or require excessive labeled data @xcite . other works @xcite @xcite use rnns for generative query suggestion, but they inherit the weaknesses of rnns and yield unsatisfactory performance in practice. note that @xcite construct contextaware query embeddings using word2vec @xcite . in their approach, an embedding is learned for each distinct query in the dataset. as such, the quality of the learned embeddings rely heavily on the number of occurrences of each query. this method is not applicable to our case because in our dataset, almost all the queries are distinct. ## problem setup the session data are collected from search logs. first, we collect all the searches from a specific user within a time window, and we call the searches a "session". after the user purchases a product, the session ends, i.e., we do not consider subsequent queries and behaviors after a purchase happens. this is because after a purchase, the user's intent often change. note that different sessions may be collected from different users. each session contains multiple searches from the same user. we call the last query in the session the "target" query, the second to the last query the "source" (or the "instance) query, and the others the "history" queries. the intuition behind this is that because sessions always end with a purchase, the last search (i.e., the target) reflects the user's real intent. when the user enters the second to the last search (i.e., the source), if we can rewrite it to the target query, the user's intent will be fulfilled. below is an example of a search session. from the history queries, the user is interested in car related banners/posters. the source query contains a typo ("doger" is a baseball team) and we should rewrite it to the target query ("dodge posters"). ## method figure 2 illustrates our context-aware query rewriting model. the model contains four parts: a conventional transformer @xcite encoder, a graph attention mechanism @xcite ) that captures the user's purchase intent, an aggregation network that encodes the history searches, and a conventional transformer decoder that generates the rewritten query candidates. ## experiments we conduct experiments on some in-house data. we implement two methods with different model architectures: transformer+aggregation+graph and bart+aggregation+graph. the first one is constructed in the previous section, and the second one employs a fine-tuning approach instead of training-from-scratch. the training details are deferred to appendix b.3. more experimental results are shown in appendix c. ## conclusion and discussion we propose an end-to-end context-aware query rewriting model that can efficiently leverage user's history behavior. our model infers a user's purchase intent by modeling her history searches as a graph, on which a graph attention mechanism is applied to generate informative session representations. the representations are subsequently decoded into rewritten queries. our proposed session graph can be extended to incorporate more information. here, we present a bipartite graph, which contains words and queries. additional components can be added as extra layers. for example, we can add product information such as categories to the session graph, which will create 3-partite session graphs (word, query and product).