{'fraction_non_alphanumeric': 0.044268262586377095, 'fraction_numerical': 0.013727788746298125, 'mean_word_length': 4.552757793764988, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning Temporal Point Processes for Efficient Retrieval of Continuous Time Event Sequences

Recent developments in predictive modeling using marked temporal point processes (MTPP) have enabled an accurate characterization of several real-world applications involving continuous-time event sequences (CTESs). However, the retrieval problem of such sequences remains largely unaddressed in literature. To tackle this, we propose NEUROSEQRET which learns to retrieve and rank a relevant set of continuous-time event sequences for a given query sequence, from a large corpus of sequences. More specifically, NEUROSEQRET first applies a trainable unwarping function on the query sequence, which makes it comparable with corpus sequences, especially when a relevant query-corpus pair has individually different attributes. Next, it feeds the unwarped query sequence and the corpus sequence into MTPP guided neural relevance models. We develop two variants of the relevance model which offer a tradeoff between accuracy and efficiency. We also propose an optimization framework to learn binary sequence embeddings from the relevance scores, suitable for the locality-sensitive hashing leading to a significant speedup in returning top-K results for a given query sequence. Our experiments with several datasets show the significant accuracy boost of NEUROSEQRET beyond several baselines, as well as the efficacy of our hashing mechanism.


Introduction
The recent developments in marked temporal point processes (MTPP) has dramatically improved the predictive analytics in several real world applications-from information diffusion in social networks to healthcare-by characterizing them with continuous-time event sequences (CTESs) (Tabibian et al. 2019;Gupta et al. 2021a;Samanta et al. 2017;De et al. 2018;Valera et al. 2014;Rizoiu et al. 2017;Wang et al. 2017;Daley and Vere-Jones 2007;Guo et al. 2018;Du et al. 2015;Tabibian et al. 2019;Kumar et al. 2019;De et al. 2016;Zhang et al. 2021;Du et al. 2016;Farajtabar et al. 2017;Jing and Smola 2017;Saha et al. 2018;Gupta and Bedathur 2021;Likhyani et al. 2020). In this context, given a query sequence, retrieval of relevant CTESs from a corpus of sequences is a challenging problem having a wide variety of search-based applications. For example, in audio or music retrieval, one may like to search sequences having different audio or music signatures; in social network, retrieval of trajectories of information diffusion, relevant to a given trajectory can assist in viral marketing, fake news detection, etc. Despite having a rich literature on searching similar time-series (Blondel et al. 2021;Gogolou et al. 2020;Alaee et al. 2020;Yoon et al. 2019;Cai et al. 2019;Shen et al. 2018;Cuturi and Blondel 2017;Paparrizos and Gravano 2015), the problem of designing retrieval models specifically for CTES has largely been unaddressed in the past. Moreover, as shown in our experiments, the existing search methods for time sequences are largely ineffective for a CTES retrieval task, since the underlying characterization of the sequences vary across these two domains.

Present Work
In this paper, we first introduce NEUROSEQRET, a family of supervised retrieval models for continuous-time event sequences and then develop a trainable locality sensitive hashing (LSH) based method for efficient retrieval over very large datasets. Specifically, our contributions are as follows: Query unwarping. The notion of relevance between two sequences varies across applications. A relevant sequence pair can share very different individual attributes, which can mislead the retrieval model if the sequences are compared asit-is. In other words, an observed sequence may be a warped transformation of a hidden sequence (Xu et al. 2018;Gervini and Gasser 2004). To tackle this problem, NEUROSEQRET first applies a trainable unwarping function on the query sequence before the computation of a relevance score. Such an unwarping function is a monotone transformation, which ensures that the chronological order of events across the observed and the unwarped sequences remains the same (Xu et al. 2018). Neural relevance scoring model. In principle, the relevance score between two sequences depends on their latent similarity. We measure such similarity by comparing the generative distribution between the query-corpus sequence pairs. In detail, we feed the unwarped query sequence and the corpus sequence into a neural MTPP based relevance scoring model, which computes the relevance score using a Fisher kernel (Jaakkola et al. 1999) between the corpus and the unwarped query sequences. Such a kernel offers two key benefits over other distribution similarity measures, e.g., KL divergence or Wasserstein distance: (i) it computes a natural similarity score between query-corpus sequence pairs in terms of the underlying generative distributions; and, (ii) it computes a dot product between the gradients of log-likelihoods of the sequence pairs, which makes it compatible with localitysensitive hashing for certain design choices and facilitates efficient retrieval. In this context, we provide two MTPP models, leading to two variants of NEUROSEQRET, which allows a nice tradeoff between accuracy and efficiency. SELFATTN-NEUROSEQRET: Here, we use transformer Hawkes process (Zuo et al. 2020) which computes the likelihood of corpus sequences independently of the query sequence. Such a design admits precomputable corpus likelihoods, which in turn allows for prior indexing of the corpus sequences before observing the unseen queries. This setup enables us to apply LSH for efficient retrieval. CROSSATTN-NEUROSEQRET: Here, we propose a novel cross attention based neural MTPP model to compute the sequence likelihoods. Such a cross-attention mechanism renders the likelihood of corpus sequence dependent on the query sequence, making it a more powerful retrieval model. While CROSSATTN-NEUROSEQRET is not directly compatible with such a hashing based retrieval, it can be employed in a telescopic manner-where a smaller set of relevant candidate set is first retrieved using LSH applied on top of SELFATTN-NEUROSEQRET, and then reranked using CROSSATTN-NEUROSEQRET.
Having computed the relevance scores, we learn the unwarping function and the MTPP model by minimizing a pairwise ranking loss, based on the ground truth relevance labels.
Scalable retrieval. Next, we use the predictions made by SELFATTN-NEUROSEQRET to develop a novel hashing method that enables efficient sequence retrieval. More specifically, we propose an optimization framework that compresses the learned sequence embeddings into binary hash vectors, while simultaneously limiting the loss due to compression. Then, we use locality-sensitive hashing (Gionis et al. 1999) to bucketize the sequences into hash buckets, so that sequences with similar hash representations share the same bucket. Finally, given a query sequence, we consider computing relevance scores only with the sequences within its bucket. Such a hashing mechanism combined with high-quality sequence embeddings achieves fast sequence retrieval with no significant loss in performance.
Finally, our experiments with real-world datasets from different domains show that both variants of NEUROSE-QRET outperform several baselines including the methods for continuous-time series retrieval. Moreover, we observe that our hashing method applied on SELFATTN-NEUROSEQRET can make a trade-off between the retrieval accuracy and efficiency more effectively than baselines based on random hyperplanes as well as exhaustive enumeration.

Preliminaries
In this section, we first sketch an outline of marked temporal point processes (MTPP) and then setup our problem of retrieving a set of continuous time event sequences relevant to a given query sequence.

Marked Temporal Point Processes: Overview
Continuous time event sequences (CTESs). Marked temporal point processes (MTPP) are stochastic processes which capture the generative mechanism of a sequence of discrete events localized in continuous time. Here, an event e is realized using a tuple (t, x), where t ∈ R + and x ∈ X are the arrival time and the mark of the event e. Then, we use H(t) to denote a continuous time event sequence (CTES) where each event has arrived until and excluding time t, i.e., H(t) := {e i = (t i , x i ) | t i−1 < t i < t}. Moreover we use T (t) and M(t) to denote the sequence of arrival times {t i | e i ∈ H(t)} and the marks {x i | e i ∈ H(t)}. Finally, we denote the counting process N (t) as counts of the number of events happened until and excluding time t, encapsulating the generative mechanism of the arrival times. Generative model for CTES. The underlying MTPP model consists of two components-(i) the dynamics of the arrival times and (ii) the dynamics of the distribution of marks. Most existing works (Du et al. 2016;Zhang et al. 2020;Mei et al. 2019;Mei and Eisner 2017;Shelton et al. 2018;Zuo et al. 2020) model the first component using an intensity function which explicitly models the likelihood of an event in the infinitesimal time window [t, t + dt), i.e., λ(t) = Pr(dN (t) = 1|H(t)). In contrast, we use an intensity free approach following the proposal by Shchur et al. (2020), where we explicitly model the distribution of the arrival time t of the next event e. Specifically, we denote the density ρ of the arrival time and the distribution m of the mark of the next event as follows: (2) As discussed by Shchur et al. (2020), such an intensity free MTPP model enjoys several benefits over the intensity based counterparts, in terms of facilitating efficient training, scalable prediction, computation of expected arrival times, etc. Given a sequence of observed events H(T ) collected during the time interval (0, T ], the likelihood function is given by:

Problem Setup
Next, we setup our problem of retrieving a ranked list of sequence from a corpus of continuous time event sequences (CTESs) which are relevant to a given query CTES. Query and corpus sequences, relevance labels. We operate on a large corpus of sequences < T q }, as well as a query-specific relevance label for the set of corpus sequences. That is, for a given query sequence H q , we have: y(H q , H c ) = +1 if H c is marked as relevant to H q and y(H q , H c ) = −1 otherwise.
We define C q+ = {c ∈ C | y(H q , H c ) = +1}, and, C q− = {c ∈ C | y(H q , H c ) = −1}, with C = C q+ ∪ C q− . Finally, we denote T = max{T q , T c | q ∈ Q, c ∈ C} as the maximum time of the data collection.
Our goal. We aim to design an efficient CTES retrieval system, which would return a list of sequences from a known corpus of sequences, relevant to a given query sequence H q . Therefore, we can view a sequence retrieval task as an instance of ranking problem. Similar to other information retrieval algorithms, a CTES retrieval algorithm first computes the estimated relevance s(H q , H c ) of the corpus sequence H c for a given query sequence H q and then provides a ranking of C in the decreasing order of their scores.

NEUROSEQRET Model
In this section, we describe NEUROSEQRET family of MTPPbased models that we propose for the retrieval of continuous time event sequences (CTES). We begin with an outline of its two key components.

Components of NEUROSEQRET
NEUROSEQRET models the relevance scoring function between query and corpus sequence pairs. However the relevance of a corpus sequence to the query is latent and varies widely across applications. To accurately characterize this relevance measure, NEUROSEQRET works in two steps. First, it unwarps the query sequences to make them compatible for comparing with the corpus sequences. Then, it computes the pairwise relevance score between the query and corpus sequences using neural MTPP models. Unwarping query sequences. Direct comparison between a query and a corpus sequence can provide misleading outcomes, since they also contain their own individual idiosyncratic factors in addition to sharing some common attributes. In fact, a corpus sequence can be highly relevant to the query, despite greatly varying in timescale, initial time, etc. In other words, it may have been generated by applying a warping transformation on a latent sequence (Xu et al. 2018;Gervini and Gasser 2004). Thus, a direct comparison between a relevant sequence pair may give poor relevance score.
To address this challenge, we first apply a trainable unwarping function (Xu et al. 2018) U (·) on the arrival times of a query sequence, which enhances its compatibility for comparing it with the corpus sequences. More specifically, In general, U satisfies two properties (Xu et al. 2018;Gervini and Gasser 2004): unbiasedness, i.e., having a small value of U (t) − t and monotonicity, i.e., d U (t)/dt ≥ 0. These properties ensure that the chronological order of the events across both the warped observed sequence and the unwarped sequence remains same. Such a sequence transformation learns to capture the similarity between two sequences, even if it is not apparent due to different individual factors, as we shall later in our experiments ( Figure 1). Computation of relevance scores. Given a query sequence H q and a corpus sequence H c , we compute the relevance score s(H q , H c ) using two similarity scores, e.g., (i) a model independent sequence similarity score and (ii) a model based sequence similarity score.
-Model independent similarity score: Computation of model independent similarity score between two sequences is widely studied in literature (Xiao et al. 2017;Mueen and Keogh 2016;Su et al. 2020;Abanda et al. 2019;Müller 2007). They are computed using different distance measures between two sequences, e.g., DTW, Wasserstein distance, etc. and therefore, can be immediately derived from data without using the underlying MTPP model. In this work, we compute the model independent similarity score, SIM U (H q , H c ), between H q and H c as follows: where, ∆ t and ∆ x are defined as: Here, H min = min{|H q |, |H c |}, T = max{T q , T c } where the events of H q and H c are gathered until time T q and T c respectively; ∆ t (U (H q ), H c ) is the Wasserstein distance between the unwarped arrival time sequence U (H q ) and the corpus sequence (Xiao et al. 2017) and, ∆ x (H q , H c ) measures the matching error for the marks, wherein the last term penalizes the marks of last |H c | − |H q | events of |H c |.
-Model based similarity score using Fisher kernel: We hypothesize that the relevance score s(H q , H c ) also depends on a latent similarity which may not be immediately evident from the observed query and corpus sequences even after unwarping. Such a similarity can be measured by comparing the generative distributions of the query-corpus sequence pairs. To this end, we first develop an MTPP based generative model p θ (H) parameterized by θ and then compute a similarity score using the Fisher similarity kernel between the unwarped query and corpus sequence pairs (U (H q ), H c ) (Jaakkola et al. 1999). Specifically, we compute the relevance score between the unwarped query sequence U (H q ) and the corpus sequence H c as follows: where θ is the set of trainable parameters; v p θ (·) is given by (Jaakkola et al. 1999 Note that, KL divergence or Wasserstein distance could also serve our purpose of computing the latent similarity between the generative distributions. However, we choose Fisher similarity kernel because of two reasons: (i) it is known to be a natural similarity measure which allows us to use the underlying generative model in a discriminative learning task (Jaakkola et al. 1999;Sewell 2011); and, (ii) unlike KL divergence or other distribution (dis)similarities, it computes the cosine similarity between v p θ (U (H q )) and v p θ (H c ), which makes it compatible with locality sensitive hashing (Charikar 2002).
Finally, we compute the relevance score as where γ is a hyperparameter.

Neural Parameterization of NEUROSEQRET
Here, we first present the neural architecture of the unwarping function and then describe the MTPP models used to compute the model based similarity score in Eq. (5). As we describe later, we use two MTPP models with different levels of modeling sophistication, viz., SELFATTN-NEUROSEQRET and CROSSATTN-NEUROSEQRET. In SELFATTN-NEUROSEQRET, the likelihood of a corpus sequence is computed independently of the query sequence using a self attention based MTPP model, e.g., Transformer Hawkes Process (Zuo et al. 2020). As a result, we can employ a locality sensitive hashing based efficient retrieval based SELFATTN-NEUROSEQRET. In CROSSATTN-NEUROSEQRET, on the other hand, we propose a more expressive and novel cross attention MTPP model, where the likelihood of a corpus sequence is dependent on the query sequence. Thus, our models can effectively tradeoff between accuracy and efficiency. Neural architecture of U (·). As discussed in Section 3.1, the unwarping function U (·) should be unbiased and monotonic. To this end, we model U (·) ≈ U φ (·) using a nonlinear monotone function which is computed using an unconstrained monotone neural network (UMNN) (Wehenkel and Louppe 2019), i.e., where φ is the parameter of the underlying neural network u φ (·), η ∈ N (0, σ) and u φ : R → R + is a non-negative nonlinear function. Since the underlying monotonicity can be achieved only by enforcing non-negativity of the integrand u φ , UMNN admits an unconstrained, highly expressive parameterization of monotonic functions. Therefore, any complex unwarping function U φ (·) can be captured using Eq. (7), by integrating a suitable neural model augmented with ReLU(·) in the final layer. In other words, if u φ is a universal approximator for positive function, then U φ can capture any differentiable unwarping function. We impose an additional regularizer 1 Neural architecture of MTPP model p θ (·). We provide two variants of p θ (·), which leads to two retrieval models, viz., SELFATTN-NEUROSEQRET and CROSSATTN-NEUROSEQRET. SELFATTN-NEUROSEQRET: Here, we use Transformer Hawkes process (Zuo et al. 2020) which applies a self attention mechanism to model the underlying generative process. In this model, the gradient of corpus sequences v θ (H c ) = ∇ θ log p θ (H c ) are computed independently of the query sequence H q . Once we train the retrieval model, v θ (H c ) can be pre-computed and bucketized before observing the test query. Such a model, together with the Fisher kernel based cosine similarity scoring model, allows us to apply locality sensitive hashing for efficient retrieval.
CROSSATTN-NEUROSEQRET: The above self attention based mechanism models a query agnostic likelihood of the corpus sequences. Next, we introduce a cross attention based MTPP model which explicitly takes into account of the underlying query sequence while modeling the likelihood of the corpus sequence. Specifically, we measure the latent relevance score between H q and H c via a query-induced MTPP model built using the cross attention between the generative process of both the sequences. Given a query sequence H q and the first r events of the corpus sequence H c , we parameterize the generative model for (r + 1)-th event, i.e., p(e , where ρ and m are the density and distribution functions for the arrival time and the mark respectively, as described in Eq. (1).
-Input Layer: For each event e where w •,• and b y are trainable parameters.
-Attention layer: The second layer models the interaction between all the query events and the past corpus events, i.e., H q and H c (t r ) using an attention mechanism. Specifically, following the existing attention models (Vaswani et al. 2017;Kang and McAuley 2018;Li et al. 2020) it first adds a trainable position embedding p with ythe output from the previous layer. More specifically, we have the updates: y -Output layer: Given the vectors h (c,q) j provided by the attention mechanism (8), we first apply a feed-forward neural network on them to compute h (c,q) r as follows: where w •,• , w • and b v . Finally, we use these vectors to compute the probability density of the arrival time of the next event e (c) r+1 , i.e., ρ θ (t r+1 ) and the mark distribution m θ (x r+1 ). In particular, we realize ρ θ (t r+1 ) using a log normal distribution of inter-arrival times, i.e., Similarly, we model the mark distribution as, where W •,• are the trainable parameters. Therefore the set of trainable parameters for the underlying MTPP models is

Parameter Estimation
Given the query sequences {H q }, the corpus sequences {H c } along with their relevance labels {y(H q , H c )}, we seek to find θ and φ which ensure that: (10) To this aim, we minimize the following pairwise ranking loss (Joachims 2002) to estimate the parameters θ, φ: where, δ is a tunable margin.

Scalable Retrieval with Hashing
Once we learn the model parameters θ and φ, we can rank the set of corpus sequences H c in the decreasing order of s p θ ,U φ (H q , H c ) for a new query H q and return top−K sequences. Such an approach requires |C| comparisons per each test query, which can take a huge amount of time for many real-life applications where |C| is high. However, for most practical query sequences, the number of relevant sequences is a very small fraction of the entire corpus of sequences. Therefore, the number of comparisons between query-corpus sequence pairs can be reduced without significantly impacting the retrieval quality by selecting a small number of candidate corpus sequences that are more likely to be relevant to a query sequence.

Trainable Hashing for Retrieval
Computation of a trainable hash code. We first apply a trainable nonlinear transformation Λ ψ with parameter ψ on the gradients v c = v p θ (H c ) and then learn the binary hash vectors ζ c = sign (Λ ψ (v c )) by solving the following optimization, where we use tanh (Λ ψ (·)) as a smooth approxi- Here 3 i=1 η i = 1. Moreover, different terms in Eq. (11) allow the hash codes ζ c to have a set of four desired properties: (i) the first term ensures that the numbers of +1 and −1 are evenly distributed in the hash vectors ζ c = tanh (Λ ψ (v c )); (ii) the second term encourages the entries of ζ c become as close to ±1 as possible so that tanh(·) gives an accurate approximation of sign(·) ; (iii) the third term ensures that the entries of the hash codes ζ c contain independent information and therefore they have no redundant entries. Trainable hashing has been used in other domains of information retrieval including graph hashing (Liu et al. 2014;Qin et al. 2020;Roy et al. 2020), document retrieval (Zhang et al. 2010;Salakhutdinov and Hinton 2009;Zamani Dadaneh et al. 2020). However, to the best of our knowledge, such an approach has never been proposed for continuous time sequence retrieval. Outline of our retrieval method. We summarize our retrieval procedure in Algorithm 1. We are given gradient vectors v c = v p θ (H c ) obtained by training SELFATTN-NEUROSEQRET. Next, we train an additional neural network Λ ψ parameterized by ψ (TRAINHASHNET(), line 2), which is used to learn a binary hash vector ζ c for each sequence H c . Then these hash codes are used to arrange corpus sequences in different hash buckets (for-loop in lines 4-7) using the algorithm proposed by Gionis et al. (1999), so that two sequences H c , H c lying in the same hash bucket have very high value of cosine similarity cos(v c , v c ) (bucketization details are in Appendix B). Finally, once a new query H q comes, we first compute v q using the trained SELFATTN-NEUROSEQRET model and then compute the binary hash codes ζ q using the trained hash network Λ ψ (lines 9-10). Next, we assign an appropriate bucket B to it (line 11) and finally compare it with only the corpus sequences in the same bucket, i.e., H c ∈ B (lines 12-15) using our model.
Recall that we must use SELFATTN-NEUROSEQRET to compute gradient vectors for subsequent hash code generation (in lines 9-10). However, at the last stage for final score computation and ranking, we can use any variant of NEUROSEQRET (in line 13), preferably CROSSATTN-NEUROSEQRET, since the corpus sequences have already been indexed by our LSH method.

Experiments
In this section, we provide a comprehensive evaluation of NEUROSEQRET and our hashing method. Appendix D (Gupta et al. 2021b) contains additional experiments. Our implementation and datasets are available at https://github.com/data-iitd/neuroseqret/.

Experimental Setup
Datasets. We evaluate the retrieval performance of NEU-ROSEQRET and other methods across large-scale real-world datasets with up to 60 million events. The statistics of all datasets are given in Appendix (Gupta et al. 2021b). Across all datasets, |H q | = 5K and |H c | = 200K.
(1) Audio: The dataset contains audio files for spoken commands to a smart-light system and the demographics(age, nationality) of the speaker. Here, a query corpus sequence pair is relevant if they are from an audio file with a common speaker.
(2) Sports: The dataset contains actions (e.g.run, pass, shoot) taken while playing different sports. We consider the time of action and action class as time and mark of sequence respectively. Here, a query corpus sequence pair is relevant if they are from a common sport.
(3) Celebrity: In this dataset, we consider the series of frames extracted from youtube videos of multiple celebrities as event sequences where event-time denotes the video-time and the mark is decided upon the coordinates of the frame where the celebrity is located. Here, a query corpus sequence pair is relevant if they are from a video file having a common celebrity.
(4) Electricity: This dataset contains the powerconsumption records of different devices across smart-homes in the UK. We consider the records for each device as a sequence with event mark as the normalized change in the power consumed by the device and the time of recording as event time. Here, a query corpus sequence pair is relevant if they are from a similar appliance.
(5) Health: The dataset contains ECG records for patients suffering from heart-related problems. Since the length of the ECG record for a single patient can be up to 10 million, we generate smaller individual sequences of length 10,000 and consider each such sequence as an independent sequence. The marks and times of events in a sequence are determined using a similar procedure as in Electricity. A query corpus sequence pair is relevant if they are from a common patient.
For Health, Celebrity and Electricity, we lack the true ground-truth labeling of relevance between sequences. Therefore, we adopt a heuristic in which, given a dataset D, from each sequence seq q ∈ D with q ∈ [|D|], we first sample a set of sub-sequences U q = H ⊂ seq q with |U q | ∼ Unif [200,300]. For each such collection U q , we draw exactly one query H q uniformly at random from U q , i.e., H q ∼ U q . Then, we define C = ∪ q∈[|D|] U q \H q , C q+ = U q \H q and C q− = ∪ c =q U c \H c . Baselines. We consider three continuous time-series retrieval models: (i) MASS (Mueen et al. 2017), (ii) UDTW (Rakthanmanon et al. 2012) and (iii) Sharp (Blondel et al. 2021); and, three MTPP models (iv) RMTPP (Du et al. 2016), (v) SAHP (Zhang et al. 2020), and (vi) THP (Zuo et al. 2020). For sequence retrieval with MTPP models, we first train them across all the sequences using maximum likelihood estimation. Then, given a test query H q , this MTPP method ranks the corpus sequences {H c } in decreasing order of their cosine similarity CosSim(emb (q ) , emb (c) ), where emb (•) is the corresponding sequence embedding provided by the underlying MTPP model. In addition, we build supervised ranking models over these approaches, viz., Rank-RMTPP, Rank-SAHP and Rank-THP corresponding to RMTPP, SAHP, and THP. Specifically, Rank-MTPP formulates a ranking loss on the query-corpus pairs based on the cosine similarity scores along with the likelihood function to get the final training objective. Therefore, the vanilla MTPP models are used as unsupervised models and the corresponding Rank-MTPP models work as supervised models. Appendix C (Gupta et al. 2021b) contains the implementation details. Evaluation protocol. We partition the set of queries Q into 50% training, 10% validation and rest as test sets. First, we train a retrieval model using the set of training queries. Then, for each test query q , we use the trained model to obtain a top-K ranked list from the corpus sequences. Next, we compute the average precision (AP) and discounted cumulative gain (DCG) of each top-K list, based on the ground truth. Finally, we compute the mean average precision (MAP) and NDCG@K, by averaging AP and DCG values across all test queries. We set K = 10.

Results on Retrieval Accuracy
Comparison with baselines. First, we compare our model against the baselines in terms of MAP and NDCG. Table 1 summarizes the results, which shows that (i) both CROSSATTN-NEUROSEQRET and SELFATTN-NEUROSEQRET outperform all the baselines by a substantial margin; (ii) CROSSATTN-NEUROSEQRET outperforms SELFATTN-NEUROSEQRET, since the former has a higher expressive power; (iii) the variants of baseline MTPP models trained for sequence retrieval, i.e., Rank-RMTPP, Rank-SAHP, and Rank-THP outperform the vanilla MTPP models; (iv) the performances of vanilla MTPPs and the time series retrieval models (MASS, UDTW and Sharp) are comparable. Ablation study. Next, we compare the retrieval performance across four model variants: (i) our model with only modelindependent score i.e., s p θ ,    (v) our model without unwarping function U φ (·); and (vi) the complete design of our model. In all cases, we used CROSSATTN-NEUROSEQRET. Table 2 shows that the complete design of our model (variant (vi)) achieves the best performance. We further note that removing κ p θ from the score (variant (i)) leads to significantly poor performance. Interestingly, our model without any mark based similarity (variant (iv)) leads to better performance than the model without time similarity (variant (iii))this could be attributed to the larger variance in query-corpus time distribution than the distribution of marks. Finally, we observe that the performance deteriorates if we do not use an unwarping function U φ (·) (variant (v)). Figure 1 illustrates the effect of U φ (·). It shows that U φ (·) is able to learn suitable transformation of the query sequence, which encapsulates the high value of latent similarity with the corpus sequence.

Results on Retrieval Efficiency
We compare our efficient sequence retrieval method given in Algorithm 1 against random hyperplane (RH) method (Appendix B in (Gupta et al. 2021b)) and three variants of our proposed training problem in Eq. (11). (i) Our(η 2 , η 3 ) which sets η 1 = 0 and thus does not enforce even distribution of ±1 in ζ c ; (ii) Our(η 1 , η 3 ) which sets η 2 = 0 and thus tanh does not accurately approximate sign; (iii) Our(η 1 , η 2 ) which sets η 3 = 0 and thus does not enforce ζ c to be compact and free of redundancy. Our(η 1 , η 2 , η 3 ) is the complete design which includes all trainable components. Figure 2 summarizes the results.
Comparison with random hyperplane. Figure 2 shows that our method (Our(η 1 , η 2 , η 3 )) demonstrates better Pareto efficiency than RH. This is because RH generates hash code in a data oblivious manner whereas our method learns the hash code on top of the trained embeddings. Ablation study on different components of Eq. (11). Figure 2 summarizes the results, which shows that (i) the first three variants are outperformed by Our(η 1 , η 2 , η 3 ); (ii) the first term having η 1 = 0, which enforces an even distribution of ±1, is the most crucial component for the loss functionas the removal of this term causes significant deterioration of the performance.

Conclusions
In this paper, we proposed a novel supervised continuous time event sequence retrieval system called NEUROSEQRET using neural MTPP models. To achieve efficient retrieval over very large corpus of sequences, we also propose a trainable hash-coding of corpus sequences which can be used to narrow down the number of sequences to be considered for similarity score computation. Our experiments with real world datasets from a diverse range of domains show that both our retrieval model and hashing methods are more effective than several baselines.