Decoding: State Of The Art Recommender System | by Kb Pachauri | Towards Data Science

“Temporal-Contextual Recommendation in Real-Time” was announced as the best paper in the applied data science track, recently in SIGKDD-2020 which was held virtually between 23–27 Aug 2020. In this blog, I will walk through the key component of the HRNN-meta recommender model which achieves a state of the art performance on various datasets and also a comparison of HRNN and HRNN-meta model on skytrax-reviews-dataset for personalized airline recommendation.
HRNN-meta combines below major ideas effectively and efficiently for a black-bok recommender system that can adapt to diverse use-cases
Hierarchical Recurrent Neural Network (HRNN) for inter and intra sessions dynamics.Field Factorization Machines (FFM) for rich contextual features from meta.Feedback Encoding to apprehend implicit negatives.Efficient training technique using Sampling.
Hierarchical Recurrent Neural Network (HRNN) for inter and intra sessions dynamics.
Field Factorization Machines (FFM) for rich contextual features from meta.
Feedback Encoding to apprehend implicit negatives.
Efficient training technique using Sampling.
The recommender system has evolved from matrix factorization to focus on two important sources 1) Temporal order of event 2) User/Item Meta. The temporal order of the event is modeled using sequence networks such as LSTM or GRU or vanilla RNN. These networks predict the probability of the next item that the user may interact with based on user history but may find it challenging to model long user sessions due to vanishing gradients.
To model long sessions, sessions are partitioned into short sessions by considering periods of inactivity or using any other event.
Hierarchical networks are proposed to model these long user sessions by using two sequence networks to learn user and session representations as shown in the below 2 images. During the first session, the user state is randomly initialized, and at the end of the session, SessionRNN initialized user representation as shown in the first image, which in turn initialized the state for the next session in SessionRNN as shown in 2nd image and also can be used throughout the 2nd session as shown in 3rd image.
For more details about HRNN, kindly take a look at an excellent video from Alexandros Karatzoglou.
“HRNN is extended to include user and item features such as location, item price, etc by stacking contextual information on top of respective user/item latent vectors through field aware multi-layer perception, an extension we call HRNN-meta.”[1]
In Factorization Machines, every feature has only one latent vector to learn the latent effect while in Field-aware Factorization Machines each feature has several latent vectors, and depending upon the field of other features, one of them is used to do the inner product.
For example, consider three features ESPN, Vogue, and NBC, belong to the field Publisher, and the other three features Nike, Gucci, and Adidas, belong to the field Advertiser.
FM → wESPN · wNike + wESPN · wMale + wNike · wMale.
FFM → wESPN,A · wNike,P + wESPN,G · wMale,P + wNike,G · wMale,A
This raw data is first converted to libffm format than transformed to one-hot encoded before feeding to the network.
The data format of LIBFFM is:
<label> <field1>:<feature1>:<value1> <field2>:<feature2>:<value2> ...
To convert raw data to FFM format, we build 2 dictionaries one for field and one for features
#Field DictionaryDictField[Publisher]  -> 0DictField[Advertiser] -> 1DictField[Gender] -> 2#Feature DictionaryDictFeature[Publisher-ESPN]  -> 0DictFeature[Publisher-Vogue]  -> 1DictFeature[Publisher-NBC]  -> 2DictFeature[Advertiser-Nike] -> 3DictFeature[Advertiser-Gucci] -> 4DictFeature[Advertiser-Adidas] -> 5DictFeature[Gender-Female] -> 6DictFeature[Gender-Male] -> 7#Tranforming above example to FFM Format1 0:0:1 1:3:1 2:7:1 (since all features are cateogorical, the values are all ones)
Along with user features, feedback events (e.g. ratings, purchases, costs, view duration, etc.) of the previous item are concatenate as an input context to predict the next item as shown in below HRNN-meta cell. This provides a better response to implicit negatives like refresh without any click, content open but no video view, etc.
Calculating softmax to find out the probability of the next item over large vocabulary is computationally challenging and various sampling strategies are proposed in the literature for efficient training with softmax for eg: Noise Contrastive Estimation, Importance sampling, Negative Sampling, etc. There are 2 approaches
Softmax Approximation
Sampling-based
All the sampling-based approaches approximate softmax with some other loss which is efficient to compute and is mostly useful at training time.
For more details on sampling strategies kindly take a look at the excellent blog from Sebastian Ruder. HRNN relies on Negative Sampling which is an approximation of Noise Contrastive Estimation and transforms softmax to logistic loss. Negative items are sampled by raising the item frequencies to 0.75-th power.
HRNN-meta is currently available in Amazon Personalize and the below diagram shows how it works.
We did a quick check on the comparing HRNN-meta w.r.t HRNN using Amazon Personalize on skytrax-reviews-dataset which has ~41.4K airline reviews, for personalized airline recommendation based on user history and review. To train a model HRNN and HRNN-meta model using Amazon Personalize, after creating an environment, we follow the personalize sample for a contextual recommendation, and the offline metric results using HRNN-meta vs HRNN were very impressive as shown in the below chart.
~80% improvement in coverage,
~17% in mean reciprocal rank and ndcg,
~14% improvement in precision.
If you find this interesting and want to train HRNN-meta, please follow getting started amazon personalize samples which will walk you through from environment creation to training recommender model on custom datasets.
HRNN-meta provides an efficient/effective recommender solution by effectively combining session-based recommendations with field aware factorization to provide contextualized recommendations. Also provides various methods like item trend decomposition to improve on cold-start item recommendation. It will be interesting to explore other recent methods like BERT4Rec and also see the potentials of replacing GRUs with transformers.
Thanks for reading the article, I hope you found this to be helpful. If you did, please share it on your favorite social media so other folks can find it, too. Also, let us know in the comment section if something is not clear or incorrect.