Package: torecsys
ToR[e]cSysNewsIt is happy to know the new package ofTensorflow Recommenders.ToR[e]cSys is a PyTorch Framework to implement recommendation system algorithms, including but not limited to click-through-rate (CTR) prediction, learning-to-ranking (LTR), and Matrix/Tensor Embedding. The project objective is to develop a ecosystem to experiment, share, reproduce, and deploy in real world in a smooth and easy way (Hope it can be done).InstallationImplemented ModelsDocumentationGetting StartedExamplesAuthorsLicenseInstallationTBUDocumentationThe complete documentation for ToR[e]cSys is available viaReadTheDocs website.Thank you for ReadTheDocs! You are the best!Implemented Models1. SubsamplingModel NameResearch PaperYearWord2VecOmer Levy et al, 2015. Improving Distributional Similarity with Lessons Learned from Word Embeddings20152. Negative SamplingModel NameResearch PaperYearTBU3. Click through Rate (CTR) ModelModel NameResearch PaperYearLogistic Regression//Factorization MachineSteffen Rendle, 2010. Factorization Machine2010Factorization Machine Support Neural NetworkWeinan Zhang et al, 2016. Deep Learning over Multi-field Categorical Data: A Case Study on User Response Prediction2016Field-Aware Factorization MachineYuchin Juan et al, 2016. Field-aware Factorization Machines for CTR Prediction2016Product Neural NetworkYanru QU et al, 2016. Product-based Neural Networks for User Response Prediction2016Attentional Factorization MachineJun Xiao et al, 2017. Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks2017Deep and Cross NetworkRuoxi Wang et al, 2017. Deep & Cross Network for Ad Click Predictions2017Deep Factorization MachineHuifeng Guo et al, 2017. DeepFM: A Factorization-Machine based Neural Network for CTR Prediction2017Neural Collaborative FilteringXiangnan He et al, 2017. Neural Collaborative Filtering2017Neural Factorization MachineXiangnan He et al, 2017. Neural Factorization Machines for Sparse Predictive Analytics2017eXtreme Deep Factorization MachineJianxun Lian et al, 2018. xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems2018Deep Field-Aware Factorization MachineJunlin Zhang et al, 2019. FAT-DeepFFM: Field Attentive Deep Field-aware Factorization Machine2019Deep Matching Correlation PredictionWentao Ouyang et al, 2019. Representation Learning-Assisted Click-Through Rate Prediction2019Deep Session Interest NetworkYufei Feng et al, 2019. Deep Session Interest Network for Click-Through Rate Prediction2019Elaborated Entire Space Supervised Multi Task ModelHong Wen et al, 2019. Conversion Rate Prediction via Post-Click Behaviour Modeling2019Entire Space Multi Task ModelXiao Ma et al, 2019. Entire Space Multi-Task Model: An Effective Approach for Estimating Post-Click Conversion Rate2019Field Attentive Deep Field Aware Factorization MachineJunlin Zhang et al, 2019. FAT-DeepFFM: Field Attentive Deep Field-aware Factorization Machine2019Position-bias aware learning frameworkHuifeng Guo et al, 2019. PAL: a position-bias aware learning framework for CTR prediction in live recommender systems20194. Embedding ModelModel NameResearch PaperYearMatrix Factorization//StarspaceLedell Wu et al, 2017 StarSpace: Embed All The Things!20175. Learning-to-Rank (LTR) ModelModel NameResearch PaperYearPersonalized Re-ranking ModelChanghua Pei et al, 2019. Personalized Re-ranking for Recommendation2019Getting StartedThere are several ways using ToR[e]cSys to develop a Recommendation System. Before talking about them, we first need to discuss about components of ToR[e]cSys.A model in ToR[e]cSys is constructed by two parts mainly: inputs and model, and they will be wrapped into a sequential module (torecsys.models.sequential) to be trained by Trainer (torecsys.trainer.Trainer). \For inputs module (torecsys.inputs), it will handle most kinds of inputs in recommendation system, like categorical features, images, etc, with several kinds of methods, including token embedding, pre-trained image models, etc.For models module (torecsys.models), it will implement some famous models in recommendation system, like Factorization Machine family. I hope I can make the library rich. To construct a model in the module, in addition to the modules implemented inPyTorch, I will also implement some layers intorecsys.layerswhich are called by models usually.After the explanation of ToR[e]cSys, let's move on to theGetting Started. We can use ToR[e]cSys in the following ways:Run by command-line (In development)</code></pre>
</li>
</ol>
<blockquote>
<p>torecsysbuild--inputs_config='{}'<br/>
--model_config='{"method":"FM", "embed_size": 8, "num_fields": 2}'<br/>
--regularizer_config='{"weight_decay": 0.1}'<br/>
--criterion_config='{"method": "MSELoss"}'<br/>
--optimizer_config='{"method": "SGD", "lr": "0.01"}'<br/>
...```</p>
</blockquote>
<olstart="2">
<li>
<p>Runbyclassmethod</p>
<prelang="python"><code>import torecsys as trsbuild trainer by class methodtrainer = trs.trainer.Trainer().bind_objective("CTR").set_inputs().set_model(method="FM", embed_size=8, num_fields=2).set_sequential().set_regularizer(weight_decay=0.1).build_criterion(method="MSELoss").build_optimizer(method="SGD", lr="0.01").build_loader(name="train", ...).build_loader(name="eval", ...).set_targets_name("labels").set_max_num_epochs(10).use_cuda()start to fit the modeltrainer.fit()
```Run like PyTorch Module</code></pre></li></ol><p>importtorchimporttorch.nnasnnimporttorecsysastrs</p><h1>somecodeshere</h1><p>inputs=trs.inputs.InputsWrapper(schema=schema)model=trs.models.FactorizationMachineModel(embed_size=8,num_fields=2)</p><p>foriinrange(epochs):optimizer.zero_grad()outputs=model(**inputs(batches))loss=criterion(outputs,labels)loss.backward()optimizer.step()```</p><p>(Indevelopment)YoucananyoneyouliketotrainaRecommenderSystemandserveitinthefollowingways:</p><ol><li><p>Runbycommand-line</p><prelang="bash"><code>>torecsysserve--load_from='{}'Run by class method</code></pre></li></ol><p>importtorecsysastrs</p><p>serving=trs.serving.Model()<br/>.load_from(filepath=filepath).run()```</p><olstart="3"><li><p>Serveityourself</p><prelang="python"><code>from flask import Flask, request
import torecsys as trsmodel = trs.serving.Model().load_from(filepath=filepath)@app.route("/predict")
def predict():
args = request.json
inference = model.predict(args)
return inference, 200ifname== "main":
app.run()
```For further details, please refer to theexamplein repository or read thedocumentation. Hope you enjoy~ExamplesTBUSample CodesTBUSample of ExperimentsTBUAuthorsJasper Li- DeveloperLicenseToR[e]cSys is MIT-style licensed, as found in the LICENSE file.