Giter Club home page Giter Club logo

melu's Introduction

MeLU: Meta-Learned User Preference Estimator for Cold-Start Recommendation

PyTorch implementation of the paper: "MeLU: Meta-Learned User Preference Estimator for Cold-Start Recommendation", KDD, 2019.

Abstract

This paper proposes a recommender system to alleviate the coldstart problem that can estimate user preferences based on only a small number of items. To identify a user’s preference in the cold state, existing recommender systems, such as Netflix, initially provide items to a user; we call those items evidence candidates. Recommendations are then made based on the items selected by the user. Previous recommendation studies have two limitations: (1) the users who consumed a few items have poor recommendations and (2) inadequate evidence candidates are used to identify user preferences. We propose a meta-learning-based recommender system called MeLU to overcome these two limitations. From metalearning, which can rapidly adopt new task with a few examples, MeLU can estimate new user’s preferences with a few consumed items. In addition, we provide an evidence candidate selection strategy that determines distinguishing items for customized preference estimation. We validate MeLU with two benchmark datasets, and the proposed model reduces at least 5.92% mean absolute error than two comparative models on the datasets. We also conduct a user study experiment to verify the evidence selection strategy.

Usage

Requirements

  • python 3.6+
  • pytorch 1.1+
  • tqdm 4.32+
  • pandas 0.24+

Preparing dataset

It needs about 22GB of hard disk space.

import os
from data_generation import generate
master_path= "./ml"
if not os.path.exists("{}/".format(master_path)):
    os.mkdir("{}/".format(master_path))
    generate(master_path)

Training a model

Our model needs support and query sets. The support set is for local update, and the query set is for global update.

import torch
import pickle
from MeLU import MeLU
from options import config
from model_training import training
melu = MeLU(config)
model_filename = "{}/models.pkl".format(master_path)
if not os.path.exists(model_filename):
    # Load training dataset.
    training_set_size = int(len(os.listdir("{}/warm_state".format(master_path))) / 4)
    supp_xs_s = []
    supp_ys_s = []
    query_xs_s = []
    query_ys_s = []
    for idx in range(training_set_size):
        supp_xs_s.append(pickle.load(open("{}/warm_state/supp_x_{}.pkl".format(master_path, idx), "rb")))
        supp_ys_s.append(pickle.load(open("{}/warm_state/supp_y_{}.pkl".format(master_path, idx), "rb")))
        query_xs_s.append(pickle.load(open("{}/warm_state/query_x_{}.pkl".format(master_path, idx), "rb")))
        query_ys_s.append(pickle.load(open("{}/warm_state/query_y_{}.pkl".format(master_path, idx), "rb")))
    total_dataset = list(zip(supp_xs_s, supp_ys_s, query_xs_s, query_ys_s))
    del(supp_xs_s, supp_ys_s, query_xs_s, query_ys_s)
    training(melu, total_dataset, batch_size=config['batch_size'], num_epoch=config['num_epoch'], model_save=True, model_filename=model_filename)
else:
    trained_state_dict = torch.load(model_filename)
    melu.load_state_dict(trained_state_dict)

Extracting evidence candidates

We extract evidence candidate list based on the MeLU.

from evidence_candidate import selection
evidence_candidate_list = selection(melu, master_path, config['num_candidate'])
for movie, score in evidence_candidate_list:
    print(movie, score)

Note that, you may have a different evidence candidate list from the paper. That's because we do not open the random seeds of data generation and model training.

Citation

If you use this code, please cite the paper.

@inproceedings{lee2019melu,
  title={MeLU: Meta-Learned User Preference Estimator for Cold-Start Recommendation},
  author={Lee, Hoyeop and Im, Jinbae and Jang, Seongwon and Cho, Hyunsouk and Chung, Sehee},
  booktitle={Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery \& Data Mining},
  pages={1073--1082},
  year={2019},
  organization={ACM}
}

melu's People

Contributors

hoyeoplee 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  avatar

melu's Issues

You are a liar

You said in your paper that the code is available. You are a liar.

A question about the gradients

Hi,
First thank you for providing us such a nice work!

But I meet a question and really need you help:

In your MeLU.py lines 71-79:

grad = torch.autograd.grad(loss, self.model.parameters(), create_graph=True)
            # local update
            for i in range(self.weight_len):
                if self.weight_name[i] in self.local_update_target_weight_name:
                    self.fast_weights[self.weight_name[i]] = weight_for_local_update[i] - self.local_lr * grad[i]
                else:
                    self.fast_weights[self.weight_name[i]] = weight_for_local_update[i]
        self.model.load_state_dict(self.fast_weights)
        query_set_y_pred = self.model(query_set_x)

I understand this is the standard MAML approach (inner loop).

However, the function load_state_dict() will erase (break) the gradient (https://discuss.pytorch.org/t/loading-a-state-dict-seems-to-erase-grad/56676) and thus the global update will no longer consider the local update gradient in the final optimization. So, create_graph=True may not work and the algorithm may not be standard MAML any more. I am wondering whether I lose any insight behind that.

Looking forward to your reply!

Some questions about the evaluation process

Hello, I can't find the evaluation code in this project.
For MAML, the evaluation need updae on the support set of test data, then evaluating on the query set of test data. Do you do the same process. Or do not need to update on the support set of test dataset, evaluate directly on the query set of test set.

Thank you!

My implementation with better results based on reasonable hyperparameters

Dear authors,

I have reproduced the algorithm in the paper. In your original paper, you set the inner loop learning rate to 5e-5 and outer-loop learning rate to 5e-6, which from my perspective is too low to have a good learning process. So I reset the parameters and test the MAE of my implementation. And it turns out to be better than your results.

So I wonder whether the hyperparameters in your paper isn't proper or is there any other reasons to lower inner and outer learning rate to that extent.

My implementation is in:
https://github.com/waterhorse1/MELU_pytorch

Inaccurate “Cold Start” dataset partition method? Lack of evaluation process?

The data set is divided in a way that seems is inconsistent with the motivation to be solved in this paper. What the paper hopes to solve is the universal cold start problem (very few interactive data). However, the three "cold start" situations obtained by dividing the user and item in chronological order do not seem to be the general "cold start" concept that we want to solve.
In fact, many newly registered users have many interaction records in the dataset partition obtained in this way, which does not seem to be a user cold start problem. Similarly, many new items also have a number of interaction records, which is not an item cold start condition.

In addition, this project lacks evaluation code. According to the idea of the experimental part of the paper, the author seems to mean that training and testing are carried out in each of the four data sets. However, this code does not divide each data set into training part and testing part, and there is no code for testing part.

In addition, training and testing in each of the four datasets separately does not seem to meet the motivation of meta-learning. According to the concept of meta-learning, it should be trained on warm-state data and then select one of the three cold start datasets for testing to verify the ability of meta-learning to quickly learn new tasks and cope with cold start conditions. But that doesn't seem to be the case in this paper.

The above is my personal thinking and doubt, I don't know if I understand that correctly.

유저 배치 쌤플한다는 것은 여러유저를 묶어서 동시에 한 rating씩 학습한다는 것인가요?

안녕하세요 위메프 W마인드실 오원석이라고 합니다.

우선 소중한 노하우를 논문으로 공유해주신 것에 감사드립니다.

올려주신 논문 잘 보고 구현해보고 있습니다.

셰도코드 부분을 보면

결국 예를들어 5 유저의 각각 1래팅 씩을 쎄타2의 다섯가지 업데이트가 존재하며

결국 5가지 쎄타2에 대한 쎄타1의 그레디언트를 동시에 적용한 후

쎄타2는 다시 로컬업데이트때 적용했던 그레디언트를 전부 합쳐서 하이퍼파라미터베타 곱해서 업데이트 하는 것이 맞나요?

결국 배치하나가 5유저라면 레이팅5개가 피드되어 로컬 5번, 글로벌1번 업데이트 되는 게 맞는지요?

그리고 유저별로 레이팅 갯수가 너무 차이나면 바이어스가 문제되어 갯수도 맞춰줘야 하는 것이 맞겠죠?

while not converge 라는 부분도 결국 레이팅 갯수를 어느 정도 맞춘 상태에서 배치별 밸리데이션 셋 (ex - 5유저에 대한 각각 20래이팅 ) 의 loss가 일정 이상 줄어드는 것으로 보면 될까요? 아니면 전체 레이팅에서의 밸리데이션 셋을 정의해야 할까요.

답변 기다리겠습니다.

How to evaluate your model?

Dear authors,

Thanks for sharing the code and data. But I didn't find the code for evaluation. Could you also provide that code so that we can reproduce the results in paper quickly?

How do you select the meta-train data?

In the paper, it says there are four partitions for evaluation (existing items for existing users, existing items for new users, new items for existing users, new items for new users). But which partition is used for the meta-train?

We are waiting for the code

Hi authors,

Is there any reason that you don't share your code at this moment? Would you please let us know your plan?
Besides, it's quite surprising that none of the authors reply my email (sent one week ago). Don't know what's happening there! :(

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.