SlideShare a Scribd company logo
Music	Entertainment	System
Collaborative Recommender
System for Music
Valentin Nagacevschi
What to listen next …..
Music	Entertainment	System
Why Recommender Systems?
• Information overload too many choices
• Help users find items of their interest
• Help item providers deliver items to right users
• Help platforms build user engagement
Music	Entertainment	System
What is a Recommender System?
• Most successful and widespread application of ML in business.
• Many users interact with many items: predict items for users
• Applied Movies, Books, Music, Retail, etc.
The Goal of Recommender System
Relevance Novelty
Serendipity Diversity
Music	Entertainment	System
Domains
• Media
News, videos, movies, music
• eCommerce
Product recommendation
• Jobs
Personalised job boards, newsletters with best matching jobs
• Travel & Real Estate
Events, Places, Hotels, Restaurants, Flights, Car Rentals
• Education
Personalised education - materials, courses, specialisations, skills
Music	Entertainment	System
Types of Recommender Systems
• Content-based recommendation systems
• Item bases / User based
• Need information for items or users to calculate similarities
• Collaborative recommendation system
• People like
• things similar to other things they like
• things that are liked by other people with similar taste
Collaborative Filtering
Memory based approach
Model based approach
Find similar users based on cosine
similarity or Pearson correlation and
use weighted average of ratings
Use machine learning to find user
ratings of unrated items using Matrix
Factorization and Neural Networks
Music	Entertainment	System
Matrix Factorization
Music	Entertainment	System
Ratings vs. Interactions
• Ratings
• Normally 1 - 5
• Unreliable and biased
• Interactions
• Normally 0 - 1
• Cannot capture dislikes
Music	Entertainment	System
Music Interactions Dataset
user_id track_id gt30 lt30 rating
0 133575735 15717314 1 0
1 133575735 29494564 3 1
2 133575735 31531850 1 0
3 133575735 37472673 2 0
4 133575735 42984237 0 1
Music	Entertainment	System
Prepare Music Data
• No ratings, but better than interactions
• Labels standard: 30 seconds threshold
• Derived ratings:
3 + (gt30 - lt30) if (gt30 - lt30) >= 0
2 + (gt30 - lt30) if (gt30 - lt30) < 0
Rating - Before and After
Music	Entertainment	System
Why PyTorch ?
• Dynamic approach to Graph Computation
• Increased developer productivity
• Easier to learn and simpler to code
• Easy to debug
• Simplicity and transparency
Music	Entertainment	System
Matrix Factorization Model
import torch.nn as nn
import torch.optim as optim
class MatrixFactorization(nn.Module):
def __init__(self, n_users, n_items, n_factors=20):
super().__init__()
self.user_factors = nn.Embedding(n_users, n_factors, sparse=True)
self.item_factors = nn.Embedding(n_items, n_factors, sparse=True)
self.user_biases = nn.Embedding(n_users, 1, sparse=True)
self.item_biases = nn.Embedding(n_items, 1, sparse=True)
def forward(self, user, item):
dot = (self.user_factors(user) * self.item_factors(item)).sum(1)
bias = self.user_biases(user) + self.item_biases(item)
return dot + bias
Music	Entertainment	System
Model and Data Preparation
model = MatrixFactorization(1000, 1000)
loss_func = nn.MSELoss()
optimizer = optim.SGD(model.parameters(), lr=1e-6)
# shuffle training data
rows, cols = ratings.nonzero()
p = np.random.permutation(len(rows))
rows, cols = rows[p], cols[p]
Music	Entertainment	System
Train the Model
for row, col in zip(*(rows, cols)):
# Turn data into variables
rating = Variable(torch.FloatTensor([ratings[row, col]]))
row = Variable(torch.LongTensor([np.long(row)]))
col = Variable(torch.LongTensor([np.long(col)]))
# Predict and calculate loss
prediction = model(row, col)
loss = loss_func(prediction, rating)
# Backpropagate
loss.backward()
# Update the parameters
optimizer.step()
Music	Entertainment	System
SpotLight Library
dataset = get_music_dataset(variant=‘100K')
train, test = random_train_test_split(dataset)
model = ExplicitFactorizationModel(
loss=‘regression', # loss function
embedding_dim=40, # latent dimensionality
n_iter=12, # number of epochs of training
batch_size=1024, # minibatch size
l2=1e-9, # strength of L2 regularization
learning_rate=0.1)
model.fit(train)
train_rmse = rmse_score(model, train) # 0.907
test_rmse = rmse_score(model, test) # 0.946
Maciej Kula
Music	Entertainment	System
Neural Collaborative Filtering
Layer 1
Layer 2
Layer x
0 0 0 0 0 0 ……
Item Latent Vector
0 0 0 0 0 0 ……
User Latent Vector
Y
^
ui Yui
Training TargetOutput Layer
Neural CF Layers
Embeddings Layers
Input Layers
Dr. Xiangnan He - 2017
Music	Entertainment	System
Layer 1
Layer 2
Layer x
0 0 0 0 0 0 ……0 0 0 0 0 0 ……
Y
^
ui Yui
Training
MF User Vector MLP User Vector MF Item Vector MLP Item Vector
MF Layer
NeuMF Layer
Concatenation
Dot Product
Concatenation
Dr. Xiangnan He - 2017
Music	Entertainment	System
def __init__(self, config):
super(NeuMF, self).__init__()
self.dim_mf = config[‘dim_mf']
self.dim_mlp = config[‘dim_mlp']
#mf part
self.user_mf = nn.Embedding(num_embeddings=self.num_users, embedding_dim=self.dim_mf)
self.item_mf = nn.Embedding(num_embeddings=self.num_items, embedding_dim=self.dim_mf)
#mlp part
self.user_mlp = nn.Embedding(num_embeddings=self.num_users, embedding_dim=self.dim_mlp)
self.item_mlp = nn.Embedding(num_embeddings=self.num_items, embedding_dim=self.dim_mlp)
self.fc_layers = nn.ModuleList()
for (in_size, out_size) in enumerate(zip(config['layers'][:-1], config['layers'][1:])):
self.fc_layers.append(nn.Linear(in_size, out_size))
self.logist = nn.Linear(in_features=config['layers'][-1] + self.dim_mf, out_features=1)
self.sigmoid = nn.Sigmoid()
Music	Entertainment	System
def forward(self, user, item):
user_embedding_mlp = self.embedding_user_mlp(user)
item_embedding_mlp = self.embedding_item_mlp(item)
user_embedding_mf = self.embedding_user_mf(user)
item_embedding_mf = self.embedding_item_mf(item)
#### mf part
mf_vector =torch.mul(user_embedding_mf, item_embedding_mf)
#### mlp part
mlp_vector = torch.cat([user_embedding_mlp, item_embedding_mlp], dim=-1)
for idx, _ in enumerate(range(len(self.fc_layers))):
mlp_vector = self.fc_layers[idx](mlp_vector)
mlp_vector = nn.ReLU()(mlp_vector)
vector = torch.cat([mlp_vector, mf_vector], dim=-1)
logits = self.logist(vector)
output = self.sigmoid(logits)
return output
Music	Entertainment	System
Next Steps
• Group Collaborative Recommender System
• Collaborative Recommender for Playlists
• Add meta content into mix, such as genre, artist, album, year
• Consider audio features: Tempo, Time signature, Mode, Key,
Loudness, Danceability, Energy, Timbre, Beat, Mel spectrogram.
Music	Entertainment	System
Takeaways
• Collaborative Recommender - perfect for user/item interactions
(explicit or implicit)
• Matrix Factorization models performs good in most of the cases
• MF - a particular case for Neural Collaborative Filtering
• Combine pre-trained MF and NCF for even better performance
• PyTorch is the best choice for both research and production
Thank	you	!
linkedin.com/in/vnagacevschi/

More Related Content

What's hot

Movie recommendation system using collaborative filtering system
Movie recommendation system using collaborative filtering system Movie recommendation system using collaborative filtering system
Movie recommendation system using collaborative filtering system
Mauryasuraj98
 
Recommendation Systems
Recommendation SystemsRecommendation Systems
Recommendation Systems
Robin Reni
 
Recommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filteringRecommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filtering
Viet-Trung TRAN
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
Lior Rokach
 
Collaborative filtering
Collaborative filteringCollaborative filtering
Collaborative filtering
Tien-Yang (Aiden) Wu
 
Recommendation system
Recommendation systemRecommendation system
Recommendation system
Akshat Thakar
 
Recommendation system
Recommendation systemRecommendation system
Recommendation system
Ding Li
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
T212
 
Recommendation system
Recommendation system Recommendation system
Recommendation system
Vikrant Arya
 
Tag based recommender system
Tag based recommender systemTag based recommender system
Tag based recommender system
Karen Li
 
An introduction to Recommender Systems
An introduction to Recommender SystemsAn introduction to Recommender Systems
An introduction to Recommender Systems
David Zibriczky
 
Collaborative Filtering 1: User-based CF
Collaborative Filtering 1: User-based CFCollaborative Filtering 1: User-based CF
Collaborative Filtering 1: User-based CF
Yusuke Yamamoto
 
Content based filtering
Content based filteringContent based filtering
Content based filtering
Bendito Freitas Ribeiro
 
Recommendation Systems Basics
Recommendation Systems BasicsRecommendation Systems Basics
Recommendation Systems Basics
Jarin Tasnim Khan
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
Federico Cargnelutti
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
Francesco Casalegno
 
Recommender systems using collaborative filtering
Recommender systems using collaborative filteringRecommender systems using collaborative filtering
Recommender systems using collaborative filtering
D Yogendra Rao
 
Movie Recommender system
Movie Recommender systemMovie Recommender system
Movie Recommender system
PalakNath
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
Carlos Castillo (ChaTo)
 
Fair Recommender Systems
Fair Recommender Systems Fair Recommender Systems
Fair Recommender Systems
Sharmistha Chatterjee
 

What's hot (20)

Movie recommendation system using collaborative filtering system
Movie recommendation system using collaborative filtering system Movie recommendation system using collaborative filtering system
Movie recommendation system using collaborative filtering system
 
Recommendation Systems
Recommendation SystemsRecommendation Systems
Recommendation Systems
 
Recommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filteringRecommender systems: Content-based and collaborative filtering
Recommender systems: Content-based and collaborative filtering
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
 
Collaborative filtering
Collaborative filteringCollaborative filtering
Collaborative filtering
 
Recommendation system
Recommendation systemRecommendation system
Recommendation system
 
Recommendation system
Recommendation systemRecommendation system
Recommendation system
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
 
Recommendation system
Recommendation system Recommendation system
Recommendation system
 
Tag based recommender system
Tag based recommender systemTag based recommender system
Tag based recommender system
 
An introduction to Recommender Systems
An introduction to Recommender SystemsAn introduction to Recommender Systems
An introduction to Recommender Systems
 
Collaborative Filtering 1: User-based CF
Collaborative Filtering 1: User-based CFCollaborative Filtering 1: User-based CF
Collaborative Filtering 1: User-based CF
 
Content based filtering
Content based filteringContent based filtering
Content based filtering
 
Recommendation Systems Basics
Recommendation Systems BasicsRecommendation Systems Basics
Recommendation Systems Basics
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
 
Recommender systems using collaborative filtering
Recommender systems using collaborative filteringRecommender systems using collaborative filtering
Recommender systems using collaborative filtering
 
Movie Recommender system
Movie Recommender systemMovie Recommender system
Movie Recommender system
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
 
Fair Recommender Systems
Fair Recommender Systems Fair Recommender Systems
Fair Recommender Systems
 

Similar to Collaborative Recommender System for Music using PyTorch

Recsys2016 Tutorial by Xavier and Deepak
Recsys2016 Tutorial by Xavier and DeepakRecsys2016 Tutorial by Xavier and Deepak
Recsys2016 Tutorial by Xavier and Deepak
Deepak Agarwal
 
Data science essentials in azure ml
Data science essentials in azure mlData science essentials in azure ml
Data science essentials in azure ml
Mostafa
 
[系列活動] 資料探勘速遊 - Session4 case-studies
[系列活動] 資料探勘速遊 - Session4 case-studies[系列活動] 資料探勘速遊 - Session4 case-studies
[系列活動] 資料探勘速遊 - Session4 case-studies
台灣資料科學年會
 
Movie Recommender System Using Artificial Intelligence
Movie Recommender System Using Artificial Intelligence Movie Recommender System Using Artificial Intelligence
Movie Recommender System Using Artificial Intelligence
Shrutika Oswal
 
Practical Recommendation System - Scalable Machine Learning
Practical Recommendation System - Scalable Machine LearningPractical Recommendation System - Scalable Machine Learning
Practical Recommendation System - Scalable Machine Learning
Son Phan
 
Rokach-GomaxSlides (1).pptx
Rokach-GomaxSlides (1).pptxRokach-GomaxSlides (1).pptx
Rokach-GomaxSlides (1).pptx
Jadna Almeida
 
Rokach-GomaxSlides.pptx
Rokach-GomaxSlides.pptxRokach-GomaxSlides.pptx
Rokach-GomaxSlides.pptx
Jadna Almeida
 
A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...
A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...
A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...
PAPIs.io
 
Analytics in Online Retail
Analytics in Online RetailAnalytics in Online Retail
Build a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlowBuild a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlow
Entrepreneur / Startup
 
Deep Learning Recommender Systems
Deep Learning Recommender SystemsDeep Learning Recommender Systems
Deep Learning Recommender Systems
Cristian Javier Martinez
 
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
Louis Dorard
 
IntroductionRecommenderSystems_Petroni.pdf
IntroductionRecommenderSystems_Petroni.pdfIntroductionRecommenderSystems_Petroni.pdf
IntroductionRecommenderSystems_Petroni.pdf
AlphaIssaghaDiallo
 
Telecom datascience master_public
Telecom datascience master_publicTelecom datascience master_public
Telecom datascience master_public
Vincent Michel
 
powerpoint presentation on movie recommender system.
powerpoint presentation on movie recommender system.powerpoint presentation on movie recommender system.
powerpoint presentation on movie recommender system.
amanpandey7656
 
Machine learning @ Spotify - Madison Big Data Meetup
Machine learning @ Spotify - Madison Big Data MeetupMachine learning @ Spotify - Madison Big Data Meetup
Machine learning @ Spotify - Madison Big Data Meetup
Andy Sloane
 
Recommendation Systems Roadtrip
Recommendation Systems RoadtripRecommendation Systems Roadtrip
Recommendation Systems Roadtrip
The Real Dyl
 
System Analysis and Design.pptx
System Analysis and Design.pptxSystem Analysis and Design.pptx
System Analysis and Design.pptx
ssuserf8714c
 
Movie Recommendation System.pptx
Movie Recommendation System.pptxMovie Recommendation System.pptx
Movie Recommendation System.pptx
Cbra2
 
Teacher training material
Teacher training materialTeacher training material
Teacher training material
Vikram Parmar
 

Similar to Collaborative Recommender System for Music using PyTorch (20)

Recsys2016 Tutorial by Xavier and Deepak
Recsys2016 Tutorial by Xavier and DeepakRecsys2016 Tutorial by Xavier and Deepak
Recsys2016 Tutorial by Xavier and Deepak
 
Data science essentials in azure ml
Data science essentials in azure mlData science essentials in azure ml
Data science essentials in azure ml
 
[系列活動] 資料探勘速遊 - Session4 case-studies
[系列活動] 資料探勘速遊 - Session4 case-studies[系列活動] 資料探勘速遊 - Session4 case-studies
[系列活動] 資料探勘速遊 - Session4 case-studies
 
Movie Recommender System Using Artificial Intelligence
Movie Recommender System Using Artificial Intelligence Movie Recommender System Using Artificial Intelligence
Movie Recommender System Using Artificial Intelligence
 
Practical Recommendation System - Scalable Machine Learning
Practical Recommendation System - Scalable Machine LearningPractical Recommendation System - Scalable Machine Learning
Practical Recommendation System - Scalable Machine Learning
 
Rokach-GomaxSlides (1).pptx
Rokach-GomaxSlides (1).pptxRokach-GomaxSlides (1).pptx
Rokach-GomaxSlides (1).pptx
 
Rokach-GomaxSlides.pptx
Rokach-GomaxSlides.pptxRokach-GomaxSlides.pptx
Rokach-GomaxSlides.pptx
 
A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...
A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...
A business level introduction to Artificial Intelligence - Louis Dorard @ PAP...
 
Analytics in Online Retail
Analytics in Online RetailAnalytics in Online Retail
Analytics in Online Retail
 
Build a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlowBuild a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlow
 
Deep Learning Recommender Systems
Deep Learning Recommender SystemsDeep Learning Recommender Systems
Deep Learning Recommender Systems
 
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
From Data to Artificial Intelligence with the Machine Learning Canvas — ODSC ...
 
IntroductionRecommenderSystems_Petroni.pdf
IntroductionRecommenderSystems_Petroni.pdfIntroductionRecommenderSystems_Petroni.pdf
IntroductionRecommenderSystems_Petroni.pdf
 
Telecom datascience master_public
Telecom datascience master_publicTelecom datascience master_public
Telecom datascience master_public
 
powerpoint presentation on movie recommender system.
powerpoint presentation on movie recommender system.powerpoint presentation on movie recommender system.
powerpoint presentation on movie recommender system.
 
Machine learning @ Spotify - Madison Big Data Meetup
Machine learning @ Spotify - Madison Big Data MeetupMachine learning @ Spotify - Madison Big Data Meetup
Machine learning @ Spotify - Madison Big Data Meetup
 
Recommendation Systems Roadtrip
Recommendation Systems RoadtripRecommendation Systems Roadtrip
Recommendation Systems Roadtrip
 
System Analysis and Design.pptx
System Analysis and Design.pptxSystem Analysis and Design.pptx
System Analysis and Design.pptx
 
Movie Recommendation System.pptx
Movie Recommendation System.pptxMovie Recommendation System.pptx
Movie Recommendation System.pptx
 
Teacher training material
Teacher training materialTeacher training material
Teacher training material
 

Recently uploaded

Econ3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdfEcon3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdf
blueshagoo1
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
keesa2
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
aguty
 
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
z6osjkqvd
 
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
osoyvvf
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
Vineet
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
ElizabethGarrettChri
 
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCAModule 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
yuvarajkumar334
 
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
asyed10
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
NABLAS株式会社
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
Vietnam Cotton & Spinning Association
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptxREUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
KiriakiENikolaidou
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
Vineet
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
dataschool1
 
一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理
ugydym
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
uevausa
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
1tyxnjpia
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
Vietnam Cotton & Spinning Association
 

Recently uploaded (20)

Econ3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdfEcon3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdf
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
 
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
 
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
 
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCAModule 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
 
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptxREUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
 
一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
 

Collaborative Recommender System for Music using PyTorch

  • 2. What to listen next …..
  • 3. Music Entertainment System Why Recommender Systems? • Information overload too many choices • Help users find items of their interest • Help item providers deliver items to right users • Help platforms build user engagement
  • 4. Music Entertainment System What is a Recommender System? • Most successful and widespread application of ML in business. • Many users interact with many items: predict items for users • Applied Movies, Books, Music, Retail, etc.
  • 5. The Goal of Recommender System Relevance Novelty Serendipity Diversity
  • 6. Music Entertainment System Domains • Media News, videos, movies, music • eCommerce Product recommendation • Jobs Personalised job boards, newsletters with best matching jobs • Travel & Real Estate Events, Places, Hotels, Restaurants, Flights, Car Rentals • Education Personalised education - materials, courses, specialisations, skills
  • 7. Music Entertainment System Types of Recommender Systems • Content-based recommendation systems • Item bases / User based • Need information for items or users to calculate similarities • Collaborative recommendation system • People like • things similar to other things they like • things that are liked by other people with similar taste
  • 8. Collaborative Filtering Memory based approach Model based approach Find similar users based on cosine similarity or Pearson correlation and use weighted average of ratings Use machine learning to find user ratings of unrated items using Matrix Factorization and Neural Networks
  • 9.
  • 11. Music Entertainment System Ratings vs. Interactions • Ratings • Normally 1 - 5 • Unreliable and biased • Interactions • Normally 0 - 1 • Cannot capture dislikes
  • 12. Music Entertainment System Music Interactions Dataset user_id track_id gt30 lt30 rating 0 133575735 15717314 1 0 1 133575735 29494564 3 1 2 133575735 31531850 1 0 3 133575735 37472673 2 0 4 133575735 42984237 0 1
  • 13. Music Entertainment System Prepare Music Data • No ratings, but better than interactions • Labels standard: 30 seconds threshold • Derived ratings: 3 + (gt30 - lt30) if (gt30 - lt30) >= 0 2 + (gt30 - lt30) if (gt30 - lt30) < 0
  • 14. Rating - Before and After
  • 15. Music Entertainment System Why PyTorch ? • Dynamic approach to Graph Computation • Increased developer productivity • Easier to learn and simpler to code • Easy to debug • Simplicity and transparency
  • 16. Music Entertainment System Matrix Factorization Model import torch.nn as nn import torch.optim as optim class MatrixFactorization(nn.Module): def __init__(self, n_users, n_items, n_factors=20): super().__init__() self.user_factors = nn.Embedding(n_users, n_factors, sparse=True) self.item_factors = nn.Embedding(n_items, n_factors, sparse=True) self.user_biases = nn.Embedding(n_users, 1, sparse=True) self.item_biases = nn.Embedding(n_items, 1, sparse=True) def forward(self, user, item): dot = (self.user_factors(user) * self.item_factors(item)).sum(1) bias = self.user_biases(user) + self.item_biases(item) return dot + bias
  • 17. Music Entertainment System Model and Data Preparation model = MatrixFactorization(1000, 1000) loss_func = nn.MSELoss() optimizer = optim.SGD(model.parameters(), lr=1e-6) # shuffle training data rows, cols = ratings.nonzero() p = np.random.permutation(len(rows)) rows, cols = rows[p], cols[p]
  • 18. Music Entertainment System Train the Model for row, col in zip(*(rows, cols)): # Turn data into variables rating = Variable(torch.FloatTensor([ratings[row, col]])) row = Variable(torch.LongTensor([np.long(row)])) col = Variable(torch.LongTensor([np.long(col)])) # Predict and calculate loss prediction = model(row, col) loss = loss_func(prediction, rating) # Backpropagate loss.backward() # Update the parameters optimizer.step()
  • 19. Music Entertainment System SpotLight Library dataset = get_music_dataset(variant=‘100K') train, test = random_train_test_split(dataset) model = ExplicitFactorizationModel( loss=‘regression', # loss function embedding_dim=40, # latent dimensionality n_iter=12, # number of epochs of training batch_size=1024, # minibatch size l2=1e-9, # strength of L2 regularization learning_rate=0.1) model.fit(train) train_rmse = rmse_score(model, train) # 0.907 test_rmse = rmse_score(model, test) # 0.946 Maciej Kula
  • 20. Music Entertainment System Neural Collaborative Filtering Layer 1 Layer 2 Layer x 0 0 0 0 0 0 …… Item Latent Vector 0 0 0 0 0 0 …… User Latent Vector Y ^ ui Yui Training TargetOutput Layer Neural CF Layers Embeddings Layers Input Layers Dr. Xiangnan He - 2017
  • 21. Music Entertainment System Layer 1 Layer 2 Layer x 0 0 0 0 0 0 ……0 0 0 0 0 0 …… Y ^ ui Yui Training MF User Vector MLP User Vector MF Item Vector MLP Item Vector MF Layer NeuMF Layer Concatenation Dot Product Concatenation Dr. Xiangnan He - 2017
  • 22. Music Entertainment System def __init__(self, config): super(NeuMF, self).__init__() self.dim_mf = config[‘dim_mf'] self.dim_mlp = config[‘dim_mlp'] #mf part self.user_mf = nn.Embedding(num_embeddings=self.num_users, embedding_dim=self.dim_mf) self.item_mf = nn.Embedding(num_embeddings=self.num_items, embedding_dim=self.dim_mf) #mlp part self.user_mlp = nn.Embedding(num_embeddings=self.num_users, embedding_dim=self.dim_mlp) self.item_mlp = nn.Embedding(num_embeddings=self.num_items, embedding_dim=self.dim_mlp) self.fc_layers = nn.ModuleList() for (in_size, out_size) in enumerate(zip(config['layers'][:-1], config['layers'][1:])): self.fc_layers.append(nn.Linear(in_size, out_size)) self.logist = nn.Linear(in_features=config['layers'][-1] + self.dim_mf, out_features=1) self.sigmoid = nn.Sigmoid()
  • 23. Music Entertainment System def forward(self, user, item): user_embedding_mlp = self.embedding_user_mlp(user) item_embedding_mlp = self.embedding_item_mlp(item) user_embedding_mf = self.embedding_user_mf(user) item_embedding_mf = self.embedding_item_mf(item) #### mf part mf_vector =torch.mul(user_embedding_mf, item_embedding_mf) #### mlp part mlp_vector = torch.cat([user_embedding_mlp, item_embedding_mlp], dim=-1) for idx, _ in enumerate(range(len(self.fc_layers))): mlp_vector = self.fc_layers[idx](mlp_vector) mlp_vector = nn.ReLU()(mlp_vector) vector = torch.cat([mlp_vector, mf_vector], dim=-1) logits = self.logist(vector) output = self.sigmoid(logits) return output
  • 24. Music Entertainment System Next Steps • Group Collaborative Recommender System • Collaborative Recommender for Playlists • Add meta content into mix, such as genre, artist, album, year • Consider audio features: Tempo, Time signature, Mode, Key, Loudness, Danceability, Energy, Timbre, Beat, Mel spectrogram.
  • 25. Music Entertainment System Takeaways • Collaborative Recommender - perfect for user/item interactions (explicit or implicit) • Matrix Factorization models performs good in most of the cases • MF - a particular case for Neural Collaborative Filtering • Combine pre-trained MF and NCF for even better performance • PyTorch is the best choice for both research and production