https://github.com/ziyaogeng/mtrec
A simple package about multi-task recommendation
https://github.com/ziyaogeng/mtrec
mmoe multi-task multi-task-learning recommender-system
Last synced: about 2 months ago
JSON representation
A simple package about multi-task recommendation
- Host: GitHub
- URL: https://github.com/ziyaogeng/mtrec
- Owner: ZiyaoGeng
- License: apache-2.0
- Created: 2021-05-10T02:43:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-12T02:25:13.000Z (over 4 years ago)
- Last Synced: 2025-08-18T13:02:55.970Z (about 2 months ago)
- Topics: mmoe, multi-task, multi-task-learning, recommender-system
- Language: Python
- Homepage:
- Size: 18.2 MB
- Stars: 17
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# MTRec
![]()
![]()
![]()
![]()
![]()
MTRec is a simple **multi-task recommendation** package based Tensorflow2.x. You can install it to invoke some classic models, such as MMoE, and we also provide a `test file` to help you better use it.
Let's get started!
## Installation in Python
MTRec is on PyPI, so you can use `pip` to install it.
```
pip install mtrec==0.0.1pip install mtrec
```The default dependency that MTRec has are Tensorflow2.x.
## Example
There are some [simple tests](test) to use mtrec package.
**First,Dataset**.
1. MTREC stipulates that features must be sparse discrete features, and continuous features need discrete buckets.
2. The dataset is output in the form of a dictionary, for example`{'name1':[n1,n2,...], 'name2':[n1,n2,...]}`**Second, Build Model.**
```python
from mtrec import MMoEtask_names = ['task1', 'task2']
num_experts = 3model = MMoE(task_names, num_experts, sparse_feature_columns)
```for `sparse_feature_columns`,
```python
from mtrec.functions.feature_column import sparseFeatureembed_dim = 4
sparse_feature_columns = [sparseFeature(feat, len(data_df[feat].unique()), embed_dim=embed_dim) for feat in sparse_features]
```see the `test/utils.py` file for specific details.
**Third, Compile, Fit and Predict**
```python
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.metrics import AUCmodel.compile(loss={'task1': 'binary_crossentropy', 'task2': 'binary_crossentropy'},
optimizer=Adam(learning_rate=learning_rate),
metrics=[AUC()])model.fit(
train_X,
train_y,
epochs=epochs,
batch_size=batch_size,
)pred = model.predict(test_X, batch_size=batch_size)
```## Model
| Model | Paper | Published | Author/Group |
| :---: | :----------------------------------------------------------: | :-------: | :----------: |
| MMoE | Modeling Task Relationships in Multi-task Learning with Multi-gate Mixture-of-Experts | KDD, 2018 | Google |## Discussion
1. If you have any suggestions or questions about the project, you can leave a comment on `Issue` or email `zggzy1996@163.com`.
2. wechat: