This release is a pre-release and may not be stable for production use.
ToR[e]cSys
News
It is happy to know the new package of Tensorflow 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).
Installation
TBU
Documentation
The complete documentation for ToR[e]cSys is available via ReadTheDocs website.
Thank you for ReadTheDocs! You are the best!
Implemented Models
1. Subsampling
| Model Name | Research Paper | Year |
|---|---|---|
| Word2Vec | Omer Levy et al, 2015. Improving Distributional Similarity with Lessons Learned from Word Embeddings | 2015 |
2. Negative Sampling
| Model Name | Research Paper | Year |
|---|---|---|
| TBU |
3. Click through Rate (CTR) Model
4. Embedding Model
| Model Name | Research Paper | Year |
|---|---|---|
| Matrix Factorization | / | / |
| Starspace | Ledell Wu et al, 2017 StarSpace: Embed All The Things! | 2017 |
5. Learning-to-Rank (LTR) Model
| Model Name | Research Paper | Year |
|---|---|---|
| Personalized Re-ranking Model | Changhua Pei et al, 2019. Personalized Re-ranking for Recommendation | 2019 |
Getting Started
There 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 in PyTorch, I will also implement some layers in torecsys.layers which are called by models usually.
After the explanation of ToR[e]cSys, let's move on to the Getting Started. We can use ToR[e]cSys in the following ways:
-
Run by command-line (In development)
</code></pre> </li> </ol> <blockquote> <p>torecsys build --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> <ol start="2"> <li> <p>Run by class method</p> <pre><code class="language-python">
import torecsys as trs
build trainer by class method
trainer = 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 model
trainer.fit() ```
-
Run like PyTorch Module
</code></pre> </li> </ol> <p>import torch import torch.nn as nn import torecsys as trs</p> <h1 id="user-content-some-codes-here">some codes here<a href="#user-content-some-codes-here" aria-label="Link to heading 'some codes here'" data-heading-content="some codes here" class="anchor"></a></h1> <p>inputs = trs.inputs.InputsWrapper(schema=schema) model = trs.models.FactorizationMachineModel(embed_size=8, num_fields=2)</p> <p>for i in range(epochs): optimizer.zero_grad() outputs = model(**inputs(batches)) loss = criterion(outputs, labels) loss.backward() optimizer.step() ```</p> <p>(In development) You can anyone you like to train a Recommender System and serve it in the following ways:</p> <ol> <li> <p>Run by command-line</p> <pre><code class="language-bash">> torecsys serve --load_from='{}'
-
Run by class method
</code></pre> </li> </ol> <p>import torecsys as trs</p> <p>serving = trs.serving.Model() <br /> .load_from(filepath=filepath) .run() ```</p> <ol start="3"> <li> <p>Serve it yourself</p> <pre><code class="language-python">
from flask import Flask, request import torecsys as trs
model = trs.serving.Model()
.load_from(filepath=filepath)
@app.route("/predict") def predict(): args = request.json inference = model.predict(args) return inference, 200
if name == "main": app.run() ```
For further details, please refer to the example in repository or read the documentation. Hope you enjoy~
Examples
TBU
Sample Codes
TBU
Sample of Experiments
TBU
Authors
- Jasper Li - Developer
License
ToR[e]cSys is MIT-style licensed, as found in the LICENSE file.
Metadata
Release files for torecsys 0.0.1.dev2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torecsys-0.0.1.dev2.tar.gz | 82.2 kB | Without provenance | Details for torecsys-0.0.1.dev2.tar.gz |
Release files / torecsys-0.0.1.dev2.tar.gz
| Download URL | torecsys-0.0.1.dev2.tar.gz |
|---|---|
| Size | 82.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83d99b046247cdcb90f9df443e23eaefa95930b91932937ea00935f698d7215f
|
|
BLAKE2b-256 checksum How to use checksums |
45b4fd9cfec8ed74dec66eaa7b5e8e741cdc83190eac649390a2aa63b8cfe022
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.2
|
Security for torecsys 0.0.1.dev2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.