<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Combining RNN with Transformer for Modeling Multi-Leg Trips</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Tokyo</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Japan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Recommender Systems</institution>
          ,
          <addr-line>Recurrent Neural Network, Transformer, Sequence-Aware Recommendation</addr-line>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <fpage>50</fpage>
      <lpage>52</lpage>
      <abstract>
        <p>Recommending destinations of trips based on user behavior is an important task for travel agencies such as Booking.com. The Booking.com Challenge - WebTour 2021 ACM WSDM workshop is aimed at building models for this task; the goal is to predict the final destination of multi-destination trips, based on a large dataset of over a million-trip reservations at Booking.com with date, destination, etc. In this paper, I present my approach where I leverage recent advances in language modeling techniques including Transformer. The approach, which used only a sequence of the visited cities for input, showed a top-4 accuracy of 0.4720 on the final result leaderboard. Full code is available here: https://github.com/sakatani/BookingcomChallenge2021.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>CCS CONCEPTS</title>
      <p>• Information systems → Recommender systems; • Computing
methodologies → Neural networks.</p>
    </sec>
    <sec id="sec-2">
      <title>INTRODUCTION</title>
      <p>
        Booking.com is the world’s largest online travel agency, which
is being used by millions of users to find accommodations.
Recommending destinations based on user behavior is an important
task for travel agencies such as Booking.com [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ][
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Within the
domain of accommodation, where people experience much time
and pay much money for it, the accuracy of recommenders is highly
important.
      </p>
      <p>
        Booking.com Challenge [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] was aimed at building a
recommender system that could perform the task of estimating the final
destination city of multi-destination trips based on the visited cities
(i.e. cities where the user stayed before the final destination) and as
well as additional contextual information such as reservation date.
The challenge was based on over a million anonymized real-world
reservations made on Booking.com in recent years. Thus, there
were tens of thousands of possible final destination cities. The
training data with complete itineraries and the test data with hidden
ifnal destinations were released for the development of models.
The evaluation dataset was not partitioned into public and private
leaderboards; two submissions of predictions for a single evaluation
dataset were allowed, one for the intermediate leaderboard and one
for the final leaderboard, and the final results were used for the
evaluation.
      </p>
      <p>
        Every record in the data was a user’s reservation and contained
information such as city of stay, country of stay, reservation ID,
user ID, reservation date, check-in date, check-out date, afiliation
channel, and country where the reservation was made. That
information other than the city of stay was expected to play an important
role in the performance of inference, as shown in a previous study
[
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Due to time constraints, however, my approach did not make
use of this kind of contextual information. The approach, which
focused on integrating several recent natural language processing
techniques for modeling sentences and used only a sequence of the
visited cities for input, showed a top-4 accuracy of 0.4720 in the
ifnal leaderboard results.
In this challenge, as the evaluation data consisted of travel
reservations of four or more legs only, the provided training data was
grouped by reservation ID and then only the records for four or
more legs were extracted. In addition to the extracted training data,
the evaluation data was also used for building models; the
evaluation data was grouped by reservation IDs in the same way for the
training data, and the records with four or more legs before the final
destination were extracted. Finally, the collected data was randomly
split into 15% for the local evaluation, 15% for the validation during
training, and 70% for the training.
2.2
      </p>
    </sec>
    <sec id="sec-3">
      <title>Models</title>
      <p>The model used in my approach is illustrated in Figure 1, where the
positional encoding of a Transformer is replaced with a single-layer
LSTM.</p>
      <p>
        For modeling multi-destination trips, an RNN-based model has
been proposed [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] that predicts the next destination of a sequence
of destinations in a similar way that RNN-based language
models predict the next word in a sentence. Recently, representative
models in the field of natural language processing have been
dominated by Transformer[
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]-based models, as seen in the examples of
Google BERT [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] and OpenAI GPT-3 [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Hence, the Transformer
architecture was adopted as the basis for my approach.
      </p>
      <p>Although Transformer-based models have achieved a number
of state-of-the-arts techniques in the field of natural language
processing, they have one computational cost weakness against
conventional RNN models when considering its use in the generative
task for destination recommendation. As the Transformer does not
preserve the hidden state unlike RNNs but uses positional encoding
to represent the sequential nature of tokens, it is expected to be
computationally more expensive than RNNs because it needs to
recompute the entire history in the context window at each time
step.</p>
      <p>
        To address this problem, a model called LSTM + Transformer, in
which the positional encoding of Transformer is replaced with a
single-layer LSTM, has been proposed in a previous study [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
Transformer with positional encoding needs to recompute all the tokens
in a context window at each timestep as the window slides, while the
LSTM + Transformer model only needs to compute for a new token
at each timestep since the LSTM keeps the hidden state. The study
reported that this model achieved 86% of the computational cost of
a Transformer-based model in the sentence generation task with
the WikiText-103 dataset [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Although this LSTM-Transformer
combined model is similar to the Cascaded Encoder model [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], it
uses RNNs for decoding as well as for encoding.
3
      </p>
    </sec>
    <sec id="sec-4">
      <title>EXPERIMENTS</title>
      <p>All the experiments were conducted on Google Colaboratory and it
was made sure that Intel(R) Xeon(R) CPU @ 2.30GHz, 250GB RAM,
and NVIDIA Tesla T4 GPUs were allocated.</p>
      <p>
        The LSTM-Transformer combined model consisted of one LSTM
layer and five Transformer layers, with 512 dimensions of the LSTM
hidden layer and Transformer, 1024 dimensions of the feedforward
Transformer layers, and eight attention heads. The batch size was
Sakatani, Y.
set to 16. The Adam optimizer was used during training. The
learning rate was linearly warmed up to 7 × 10−4 with 4000 iterations,
and then decayed in proportion to the inverse square root of the
iteration number according to the formula in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>
        In addition to the LSTM-Transformer combined model, a model
consisting of six layers of Transformers and a model consisted of
LSTM or GRU were also prepared for comparison. The six-layer
Transformer model was identical to the LSTM-Transformer model,
except that a Transformer layer was assigned instead of the LSTM
layer. The LSTM and GRU models have two layers and 512 hidden
units. The GRU model was based on the previous study on the
RNN-based multi-destination trip model [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], but the model details,
including hyperparameters, were unable to be reproduced exactly
due to the lack of suficient information.
      </p>
      <p>The models were evaluated using perplexity, which was based
on the negative log-likelihood loss, and top-4 accuracy on the local
evaluation data according to the rules of the challenge. Figure 2
shows the perplexity during training on the training and validation
datasets. The perplexity of each model on the training dataset
decreased steadily with the number of iterations. On the validation
dataset, both the perplexity of Transformer and LSTM-Transformer
combined model decreased steadily until at least 350,000 iterations,
while that of the GRU and LSTM model decreased shakingly and
then increased after 50,000 iterations.</p>
      <p>The perplexity and top-4 accuracy on the local evaluation dataset
were then evaluated using the checkpoint with the minimum
perplexity on the validation dataset (Table 2). The LSTM-Transformer
combined model showed the lowest perplexity and highest top-4
accuracy. The Transformer model performed as well as the
LSTMTransformer combined model. These results indicate that the
replacement of the positional encoding of Transformer with the LSTM
layer does not adversely afect the accuracy for this type of task,
but rather it can have a positive efect on performance. The LSTM
and GRU models showed smaller perplexities than the
Transformerbased models during training on both the training and validation
datasets, whereas they showed worse perplexities and top-4
accuracy on the evaluation data than the Transformer-based models. A
possible explanation for this is that the RNN-based models might
have been overfitting to the training or validation dataset.</p>
      <p>Finally, the local evaluation dataset was split into 18% for
validation and 82% for training, then the LSTM-Transformer model
was re-trained with the datasets. The predictions submitted to the
ifnal result leaderboard were generated by the retrained model and
showed 0.4720 for the top-4 accuracy score.</p>
      <p>
        While this is irrelevant for the evaluation of the challenge, the
time required for each model to generate tokens for 10000 steps
was measured three times on both GPU and CPU (Table 2). The
processing time of the LSTM-Transformer combined model was
reduced to 59% of that of the Transformer model on the CPU and
90% on the GPU. These results indicate that replacing positional
encoding of Transformer with LSTM reduces the computational cost.
The processing time on GPU, however, was not reduced as much as
on CPU. The LSTM-Transformer model may have some processing
bottlenecks on GPU, as pointed out in a previous study[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
Combining RNN with Transformer for Modeling Multi-Leg Trips
dation dataset. A). Training perplexity. B) Validation
perplexity.
5.69
5.80
      </p>
      <p>Perplexity</p>
      <p>Top-4 accuracy
4</p>
    </sec>
    <sec id="sec-5">
      <title>CONCLUSION</title>
      <p>In this paper, I describe my approach to the Booking.com Challenge
WebTour 2021 ACM WSDM workshop. The approach showed the
LSTM substitution of positional encoding can have a positive efect
on both the prediction and computational performance.</p>
      <p>
        Because of time constraints, the approach did not make use of
any information other than the visited destinations for building
the models. Although the LSTM-Transformer model used only
sequences of the visited cities for input, it achieved the 13th score
on the final result leaderboard. A previous study has shown that
the prediction performance of RNN models can be improved by
combining contextual information such as users’ home country
with a sequence of visited destinations [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Thus, it is expected
that the model used in this paper would improve in the
prediction performance by considering such contextual information. A
further study of how to combine the contextual information with
visited destinations for Transformer-based models including the
LSTM-Transformer combined model should be conducted.
      </p>
      <p>The efect of replacing the positional encoding with LSTM on the
computational cost was briefly investigated, but not fully explored
in this study. It is expected that the LSTM-Transformer model
reduces the computational cost especially when multiple destinations
are predicted as the model has the advantage that the expansion of
the context window does not afect the computational cost for the
input. Another future work involves an investigation on how
replacing positional encoding with LSTM afects the computational cost
of Transformer-based models in generative tasks for destination
recommendation.
steps.</p>
      <sec id="sec-5-1">
        <title>LSTM-Transformer Transformer Model GRU</title>
      </sec>
      <sec id="sec-5-2">
        <title>LSTM</title>
        <p>192.5 (2.0)
324.5 (3.8)</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Lucas</given-names>
            <surname>Bernardi</surname>
          </string-name>
          , Themistoklis Mavridis, and
          <string-name>
            <given-names>Pablo</given-names>
            <surname>Estevez</surname>
          </string-name>
          .
          <year>2019</year>
          .
          <article-title>150 successful machine learning models: 6 lessons learned at booking. com</article-title>
          .
          <source>In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery &amp; Data Mining</source>
          .
          <fpage>1743</fpage>
          -
          <lpage>1751</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Tom</surname>
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Brown</surname>
            , Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jefrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler,
            <given-names>Mateusz</given-names>
          </string-name>
          <string-name>
            <surname>Litwin</surname>
          </string-name>
          , Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner,
          <string-name>
            <surname>Sam</surname>
            <given-names>McCandlish</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Alec</given-names>
            <surname>Radford</surname>
          </string-name>
          , Ilya Sutskever, and
          <string-name>
            <given-names>Dario</given-names>
            <surname>Amodei</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>Language Models are Few-Shot Learners</article-title>
          . arXiv:
          <year>2005</year>
          .
          <article-title>14165 [cs</article-title>
          .CL]
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Mia</given-names>
            <surname>Xu</surname>
          </string-name>
          <string-name>
            <given-names>Chen</given-names>
            , Orhan Firat, Ankur Bapna, Melvin Johnson, Wolfgang Macherey, George Foster, Llion Jones, Niki Parmar, Mike Schuster, Zhifeng Chen,
            <surname>Yonghui Wu</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Macduf</given-names>
            <surname>Hughes</surname>
          </string-name>
          .
          <year>2018</year>
          .
          <article-title>The Best of Both Worlds: Combining Recent Advances in Neural Machine Translation</article-title>
          . arXiv:
          <year>1804</year>
          .
          <article-title>09849 [cs</article-title>
          .CL]
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Jacob</given-names>
            <surname>Devlin</surname>
          </string-name>
          ,
          <string-name>
            <surname>Ming-Wei</surname>
            <given-names>Chang</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Kenton</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>and Kristina</given-names>
            <surname>Toutanova</surname>
          </string-name>
          .
          <year>2019</year>
          .
          <article-title>BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</article-title>
          . arXiv:
          <year>1810</year>
          .
          <article-title>04805 [cs</article-title>
          .CL]
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Dmitri</given-names>
            <surname>Goldenberg</surname>
          </string-name>
          , Kostia Kofman, Pavel Levin, Sarai Mizrachi, Maayan Kafry, and
          <string-name>
            <given-names>Guy</given-names>
            <surname>Nadav</surname>
          </string-name>
          .
          <year>2021</year>
          .
          <article-title>Booking.com WSDM WebTour 2021 Challenge</article-title>
          . In https://www.
          <source>ACM WSDM Workshop on Web Tourism (WSDM WebTour'21)</source>
          . bookingchallenge.com/
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Julia</given-names>
            <surname>Kiseleva</surname>
          </string-name>
          , Melanie JI Mueller, Lucas Bernardi, Chad Davis, Ivan Kovacek, Mats Stafseng Einarsen, Jaap Kamps, Alexander Tuzhilin, and
          <string-name>
            <given-names>Djoerd</given-names>
            <surname>Hiemstra</surname>
          </string-name>
          .
          <year>2015</year>
          .
          <article-title>Where to go on your next trip? Optimizing travel destinations based on user preferences</article-title>
          .
          <source>In Proceedings of the 38th International ACM SIGIR Conference on Research and Development in Information Retrieval</source>
          .
          <fpage>1097</fpage>
          -
          <lpage>1100</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Stephen</given-names>
            <surname>Merity</surname>
          </string-name>
          , Caiming Xiong, James Bradbury, and Richard Socher.
          <year>2016</year>
          .
          <article-title>Pointer Sentinel Mixture Models</article-title>
          . arXiv:
          <volume>1609</volume>
          .07843 [cs.CL]
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Sarai</given-names>
            <surname>Mizrachi</surname>
          </string-name>
          and
          <string-name>
            <given-names>Pavel</given-names>
            <surname>Levin</surname>
          </string-name>
          .
          <year>2019</year>
          .
          <article-title>Combining Context Features in SequenceAware Recommender Systems</article-title>
          . In
          <string-name>
            <surname>RecSys (Late-Breaking</surname>
            <given-names>Results</given-names>
          </string-name>
          ).
          <fpage>11</fpage>
          -
          <lpage>15</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>Akihiro</given-names>
            <surname>Tanikawa</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>[Deep Learning Study] Text Generation with LSTM + Transformer Model (Japanese)</article-title>
          . https://note.com/diatonic_codes/ n/nab29c78bbf2e
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Ashish</surname>
            <given-names>Vaswani</given-names>
          </string-name>
          , Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones,
          <string-name>
            <given-names>Aidan N.</given-names>
            <surname>Gomez</surname>
          </string-name>
          , Lukasz Kaiser, and
          <string-name>
            <given-names>Illia</given-names>
            <surname>Polosukhin</surname>
          </string-name>
          .
          <year>2017</year>
          .
          <article-title>Attention Is All You Need</article-title>
          . arXiv:
          <volume>1706</volume>
          .03762 [cs.CL]
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>