Decoding a Neural Retriever’s Latent Space for Query Suggestion (2022)

Abstract: Neural retrieval models have superseded classic bag-of-words methods such as BM25 as the retrieval framework of choice. However, neural systems lack the interpretability of bag-of-words models; it is not trivial to connect a query change to a change in the latent space that ultimately determines the retrieval results. To shed light on this embedding space, we learn a “query decoder” that, given a latent representation of a neural search engine, generates the corresponding query. We show that it is possible to decode a meaningful query from its latent representation and, when moving in the right direction in latent space, to decode a query that retrieves the relevant paragraph. In particular, the query decoder can be useful to understand “what should have been asked” to retrieve a particular paragraph from the collection. We employ the query decoder to generate a large synthetic dataset of query reformulations for MSMarco, leading to improved retrieval performance. On this data, we train a pseudo-relevance feedback (PRF) T5 model for the application of query suggestion that outperforms both query reformulation and PRF information retrieval baselines.

## introduction neural encoder models @xcite @xcite have improved document retrieval in various settings. they have become an essential building block for applications in open-domain question answering @xcite @xcite , open-domain conversational agents @xcite , and, recently, language modeling @xcite . neural encoders embed documents and queries in a shared (or joint) latent space, so that paragraphs can be ranked and retrieved based on their vector similarity with a given query. this constitutes a conceptually powerful approach to discovering semantic similarities between queries and documents that is often found to be more nuanced than simple term frequency statistics typical of classic sparse representations. however, such encoders may come with shortcomings in practice. first, they are prone to domain overfitting, failing to consistently outperform bag-of-words approaches on out-of-domain queries @xcite . second, they are notoriously hard to interpret as similarity is no longer controlled by word overlap, but rather by semantic similarities that lack explainability. third, they may be non-robust as small changes in the query can lead to inexplicably different retrieval results. in bag-of-words models, it can be straightforward to modify a query to retrieve a given document: e.g., following insights from relevance feedback @xcite , by increasing the weight of terms contained in the target document @xcite . this approach is not trivially applicable to neural retrieval models as it is unclear how an added term might change the latent code of a query. in this paper, we look into the missing link connecting latent codes back to actual queries. we thus propose to train a "query decoder", which maps embeddings in the shared query-document space to query strings, inverting the fixed encoder of the neural retriever (cf. figure 1a ). as we will show, such a decoder lets us find queries that are optimized to retrieve a given target document. it deciphers what information is in the latent code of a document and how to phrase a query to retrieve it. we use this model to explore the latent space of a state-of-the-art neural retrieval model, gtr @xcite . in particular, we leverage the structure of the latent space by traversing from the embedding of a specific query to its human-labeled gold paragraph and use our query decoder to generate reformulation examples from intermediate points along the path as shown in figure 1b . we find that using this approach, we can generate a large query encoder (fixed) query decoder query query embedding (a) original query gold paragraph p1 p0 query decoder p3 p2 re trie ved do cum ent s latent space reformulation 1 reformulation 2 reformulation 3 query space (b) who is the chess champion of the world? who was the chess champion of the 90s? who is the reigning world chess champion? who had the highest fide ranking ever? xiong et al. (2021) propose approximate nearest neighbor negative contrastive learning (ance) to learn a dense retrieval system. on top of this dense retriever, li et al. (2022) consider a pseudorelevance feedback method. other than our approach, this method does not provide the user with rephrased queries. applications of neural retrievers neural retrieval models have been at the core of recent improvements among a range of different nlp tasks. lewis et al. (2020b) augment a language generation model, bart (lewis et al., 2020a), with a dpr neural retriever and evaluate on multiple knowledge-intensive nlp tasks; most notably, they improve over previous models on multiple open-domain qa benchmarks using an abstractive method. izacard and grave (2021) propose the fusion-in-decoder method to aggregate a large set of documents from the neural retriever and provide them to the model during answer generation. their focus is on open-domain qa where they significantly outperform previous models when considering a large set of documents during decoding. shuster et al. (2021) use neural retrieval models to improve conversational agents in knowledgegrounded dialogue. they show that the issue of hallucination -i.e., generating factual incorrect knowledge statements -can be significantly re-duced when using a neural-retriever-in-the-loop architecture. separating the retrieval-augmented knowledge generation and the conversational response generation can further improve the issue of hallucination in knowledge-grounded dialogue and helps fuse modular qa and dialogue models @xcite . recently, retrieval query generation approaches have been proposed to improve open-domain dialogue @xcite and language modeling @xcite . query generation query optimization is a longstanding problem in ir @xcite . recent work has investigated query refinement with reinforcement learning for open domain and conversational question answering @xcite @xcite . the methods presented in this paper are a natural complement to the work of @xcite , who propose a heuristic approach to generate multistep query refinements, used to train sequential query generation models for the task of learning to search. their method is also inspired by relevance feedback, but they seek to reach the gold document purely in language space, by brute force exploration. for this purpose, they use specialized search operators to condition the retrieval results as desired. @xcite show that, when paired with a hybrid sparse/dense retrieval environment, the search agents trained on this kind of synthetic data combine effective corpus exploration, competitive performance and interpretability. web-gpt @xcite presents an endto-end search modeling approach based on human demonstrations, in a similar spirit our work could be seen as way of involving humans-in-loop by proposing better queries. fixed-vector decoders probabilistic decoders mapping from a fixed size vector space to natural language have also been explored in auto based on the gtr-base neural retrieval model. the f1 score is the f1 word overlap between the original query, of msmarco or nq, and the output of the query decoder model when provided with the gtr encoding of the query. the cosine similarity is measured between the re-encoding of the generated query and the encoding of the original query. the figure above depicts the metrics visually with a toy example for clarity. recently, rnn-based decoders have been replaced by transformer-based language models @xcite , for example by @xcite , park and lee (2021) and @xcite . ## query decoder training we train a t5 @xcite , decoder-only model, to (re-)generate a query from its embedding obtained in a neural retrieval model. as training data, we use a subset of 3 million queries of the paq dataset @xcite . we use the gtr-base @xcite , sharedencoder model, to generate the embeddings and use the queries as the targets. the objective of the query decoder learning is to invert the mapping of the fixed gtr encoder model, as visually depicted in figure 1a . more training details of the query decoder are provided in appendix a.2.1. ## query suggestion model dataset generation we generate a dataset of query reformulations using the latent space traversal decoding as described in the previous section. in particular, for the 532,761 queries of the msmarco-train dataset, we leverage gtr's learned latent space structure and move towards the embedding of their gold paragraph. at @xmath0, we use our query decoder to generate reformulations. for more than 80% of the queries, we find at least one optimal reformulation that retrieves the gold paragraph at the top position. in figure 4 , we show histograms of ndcg and the inner product to the gold paragraph for the original query versus the best-found reformulation. the metrics show that the latent space traversal helps us discover good original query average yearly return on stock market [0.00] decodings during traversal what is the average annual return on stock market [0.00] average return on a stock market year [0.00] what is the average annual return on stock market [0.00] what is the average return on stock in a year [0.00] what is the average return in a stock market [0.00] what is the average annual return in stock ( s&p ) [0.36] what is the average return on the stock market ( s&p ) [0.36] what is the average return on the s&p stock exchange at a time [1.00] what is the average return in s&p stock at a time [0.36] what is the average annual return of the s&p stock exchange ( best ) [1.00] ## conclusion dual encoders have reset the standard in ir. however, language-based inverted index architectures still hold their ground, especially in out-of-domain evaluations @xcite . to help further our understanding of the connections, and potential, between the two, we propose a method that relies on a query decoder to map back to language space the latent codes generated by the encoder. the interplay between latent and language representations, in combination with a simple goaldirected mechanism for traversing the shared querydocument space, allows us to generate a large synthetic dataset of query reformulations on which we train a pseudo-relevance feedback query suggestion model that characteristically tries to predict the location of the target document. our contribution is twofold: (i) we develop a generic way to generate training data for directional query refinement by traversing the latent space between queries and relevant documents, and (ii) we build a powerful reformulation model that we evaluate on a novel benchmark inspired by the query suggestion task. suggestions are typically wellformed, diverse and more likely to lead to the right document than competing methods.