Personalized Transformer for Explainable Recommendation (2021)

Abstract: Personalization of natural language generation plays a vital role in a large spectrum of tasks, such as explainable recommendation, review summarization and dialog systems. In these tasks, user and item IDs are important identifiers for personalization. Transformer, which is demonstrated with strong language modeling capability, however, is not personalized and fails to make use of the user and item IDs since the ID tokens are not even in the same semantic space as the words. To address this problem, we present a PErsonalized Transformer for Explainable Recommendation (PETER), on which we design a simple and effective learning objective that utilizes the IDs to predict the words in the target explanation, so as to endow the IDs with linguistic meanings and to achieve personalized Transformer. Besides generating explanations, PETER can also make recommendations, which makes it a unified model for the whole recommendation-explanation pipeline. Extensive experiments show that our small unpretrained model outperforms fine-tuned BERT on the generation task, in terms of both effectiveness and efficiency, which highlights the importance and the nice utility of our design.

## introduction recent years have witnessed the successful application of natural language generation. many of the applications in fact require certain degree of personalization, such as explainable recommendation @xcite @xcite ), review generation @xcite , review summarization @xcite , and conversational systems @xcite . in these tasks, user and item ids that distinguish one user/item from the others are crucial to personalization. for example, in recommender systems, different users may care about different item features (e.g., style vs. quality), and different items may have different characteristics (e.g., fashionable vs. comfortable). the goal of explainable recommendation @xcite ) is to provide an explanation to a user for a recommended item, so as to justify how the recommendation might match his/her interests. that is, given a pair of user id and item id, the system needs to generate an explanation, such as "the style of the jacket is fashionable" (see the last column of transformer @xcite , whose strong language modeling ability has been demonstrated on a variety of tasks @xcite @xcite , however, is relatively under-explored for personalized natural language generation. since ids and words are in very different semantic spaces, it would be problematic to directly put them together for attention learning, because by doing so, the ids are treated as words, but the ids appear far less frequently than the words. for example, a paragraph of review (and thus hundreds of words) on e-commerce platform only corresponds to a single pair of user id and item id. as such, the ids may be regarded as out-of-vocabulary tokens, to which the model is insensitive. as shown in fig. 1(a) , when generating an explanation for a user-item pair, standard transformer relies heavily on the @xmath0. this would result in identical explanations over different useritem pairs (see usr score in to address this problem, we bridge ids and words by designing an elegant task called context prediction, which maps ids onto words to be generated by the explanation task. this in some way resembles one's drafting-polishing process, where by predicting some words the context prediction user] [item] <@xmath1.0 0.2 0.4 0.6 0.8 1.0 (a) standard transformer model, where the user and the item have no contribution to each generation step. [user] [item] <@xmath2.0 0.2 0.4 0.6 0.8 1.0 (b) our peter model, where the user and item ids play significant roles in the generation steps. figure 1: attention visualization of two models when generating an explanation for the same user-item pair (see the first two columns). they are both from the last attention layer, so the target sequences are offset by one position for better illustration. the larger the attention weights, the lighter the cells. in addition, peter is flexible to incorporate item features that can help to guide its generation. this can be very useful when, for instance, a user proactively asks the system to explain certain feature(s) of a recommendation @xcite , e.g., price. then, we would expect the model to generate a targeted explanation, such as "great jacket, especially for the price". peter is a small unpretrained transformer with only 2 layers, yet it outperforms a fine-tuned bert @xcite on most metrics by a large margin, and takes less time to train, as shown in our experiments. this manifests the superiority of our model. in summary, our key contributions are: transformer @xcite was first brought to machine translation with the architecture of encoder-decoder. later works @xcite show that it remains effective, even when the encoder or the decoder is removed, reducing nearly half of the parameters. under the paradigm of pre-training plus finetuning, transformer's effectiveness has been confirmed on a wide range of tasks, including both natural language understanding and generation @xcite @xcite . particularly, it is able to perform novel tasks, e.g., arithmetic, after scaling up both the model and the training data @xcite . however, it may not be friendly to researchers who do not possess large amounts of computing resources. instead, our work explores small unpretrained models, as they are computationally cheaper and more flexible when being adapted to new applications, e.g., personalized generation. personalized generation usually involves the ids of users and items. previous approaches typically adopt multi-layer perceptron (mlp) to encode the ids into a context vector, from which rnn can decode a word sequence. this strategy can be found in many applications, such as review generation @xcite , tip generation @xcite and explanation generation @xcite . however, it does not fit transformer that relies entirely on self-attention. probably because a proper solution to deal with heterogeneous inputs (i.e., ids and words) is yet to be found, previous works with transformer for personalized generation replace ids with text segments, such as persona attributes @xcite , movie titles @xcite and item features @xcite , which are in the same semantic space as the word sequence to be generated. in comparison, our solution is to design an effective task that can give the ids linguistic transformer with 𝐿 layers transformer with 𝐿 layers linear layer ƹ 𝑟 𝑢,𝑖 ƹ 𝑒 1 ƹ 𝑒 2 < ෞ 𝑒𝑜𝑠> 𝑢 𝑖 <𝑏𝑜𝑠> ƹ 𝑒 2 ƹ 𝑒 1 𝑓 2 𝑓 1 𝐬 𝐿,1 𝐬 𝐿,2 𝐬 𝐿,5 𝐬 𝐿,6 𝐬 𝐿,7 𝐬 𝐿,3 𝐬 𝐿,4 user item features (opt.) explanation rating prediction context prediction explanation generation mlp ǁ 𝑒 1 ǁ 𝑒 2 < ෦ 𝑒𝑜𝑠> meanings, thus connecting ids with words. ## problem formulation the goal of our explanation task is to generate a natural language sentence êu,i for a pair of user u and item i to justify why i is recommended to u. meanwhile, our model peter can also make recommendations by estimating a rating ru,i that predicts u's preference towards i. at the testing stage, only user u and item i are used as inputs for producing both explanation and recommendation. when item features f u,i are available, our model is flexible to incorporate them by simply concatenating them at the beginning of the explanation. in this case, the features are also needed in the testing stage. in the following, we will discuss both cases. ## methodology in this section, we present the details of our model peter. first, we show how to encode different types of tokens in a sequence. then, we briefly review transformer and introduce our revised attention masking matrix. at last, we formulate the three tasks, i.e., explanation generation, context prediction and recommendation, and integrate them into a multi-task learning framework. ## conclusion we propose a simple and effective solution to address the personalized generation problem of transformer, unleashing its language modeling power to generate explanations for recommender systems. extensive experiments show that the solution is both effective and efficient. it opens up a new way of exploiting transformer by designing good tasks instead of scaling up model size. there are various applications of personalized generation for which transformer is still less explored. our next step is to adopt our solution for personalized question answering systems and personalized conversational agents. we also plan to incorporate item images into the model, so as to generate visual explanations for recommendations, since "a picture is worth a thousand words". another meaningful extension is to adapt the model to cross-lingual explanation generation, because international platforms, e.g., amazon, may serve users who speak different languages.