Git Product home page Git Product logo

behavior-sequence-transformer-pytorch's Introduction

Behavior-Sequence-Transformer-Pytorch

Open In Colab

This is a pytorch implementation for the BST model from Alibaba https://arxiv.org/pdf/1905.06874.pdf

This model is a novel recommender architecture based on seq2seq models. We translate user behaviour into sequences and predict a rating for each target item (movie).

Dataset

For this implementation we used Movielens 1M Dataset that contains timestamps per each rating, making it perfect to test in the sequence recommendation model.

Running

You can run it in colab here. If you prefer to run locally the model architecture is contained on pytorch-best.ipynb while data processing is on the prepare_data.ipynb notebook and should be run first.

Results

Training on all-1 user ratings and leaving the latest rating for test we obtain the following results

Dataset MAE RMSE
Train 0.72 0.84
Test 0.74 0.93

Here is a screenshot of training logs we we see overfitting from epoch 12-15.

References

  • Original paper 1
  • Keras implementation 2
  • Tensorflow implementation 3

behavior-sequence-transformer-pytorch's People

Contributors

jiwidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

behavior-sequence-transformer-pytorch's Issues

[sequence question] How should I run this code if I set the sequence_length to 4?

Thanks for sharing this code, and I have a question with it.

When I run this code on Colab with the original setup,it would run perfectly. But when I change the sequence_length = 4 and step_size = 2 (just like the description in With sequence_length of 4 and step_size of 2, we end up with 498,623 sequences.), the code has an error with
Sizes of tensors must match except in dimension 2. Expected size 4 but got size 8 for tensor number 1 in the list.
in line transfomer_features = torch.cat((transfomer_features, positional_embedding), dim=2)
What should I do to get it to work properly?

P.S. Sorry for my poor English.

test_step

Hello sir, why is test_step part missing?

【QUES】Padding ???

Obviously, only fixed-length sequences are used here, and there is no filling operation, which limits the scope of application of this model.

a question about PositionalEmbedding module

Helo,thanks for your complete code. I read this code carefully,and have a question.

It's BST model's forward function

transfomer_features, user_features, target_movie_rating = self.encode_input(batch)
transfomer_features = self.positional_embedding(transfomer_features)

And it's positional_embedding module

class PositionalEmbedding(nn.Module):
    def __init__(self, max_len, d_model):
        super().__init__()

        self.pe = nn.Embedding(max_len, d_model)

    def forward(self, x):
        batch_size = x.size(0)
        return self.pe.weight.unsqueeze(0).repeat(batch_size, 1, 1)

we can see that PositionalEmbedding do nothing, just return it's weight. PositionalEmbedding doesn't have any interaction with x. It's really confused.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.