DeepCTR
Easy-to-use,Modular and Extendible package of deep-learning based CTR models .
Top Related Projects
An implementation of a deep learning recommendation model (DLRM)
TensorFlow Recommenders is a library for building recommender system models using TensorFlow.
An industrial deep learning framework for high-dimension sparse data
Quick Overview
DeepCTR is an open-source library for building deep learning-based CTR (Click-Through Rate) prediction models. It provides a collection of popular CTR models implemented in TensorFlow and PyTorch, making it easier for researchers and practitioners to experiment with and deploy state-of-the-art CTR prediction algorithms.
Pros
- Comprehensive collection of CTR models, including both classic and cutting-edge algorithms
- Supports both TensorFlow and PyTorch backends, offering flexibility for different deep learning frameworks
- Well-documented with clear examples and tutorials for easy adoption
- Actively maintained with regular updates and contributions from the community
Cons
- Steep learning curve for users unfamiliar with deep learning concepts
- Limited customization options for some models compared to implementing from scratch
- Performance may vary depending on the specific use case and dataset
- Requires significant computational resources for training large-scale models
Code Examples
- Creating a DeepFM model:
from deepctr.models import DeepFM
from deepctr.feature_column import SparseFeat, DenseFeat, get_feature_names
# Define feature columns
sparse_features = ['category', 'ad_type']
dense_features = ['age', 'ctr_history']
feature_columns = [SparseFeat(feat, vocabulary_size=1000, embedding_dim=4)
for feat in sparse_features] + \
[DenseFeat(feat, 1) for feat in dense_features]
model = DeepFM(feature_columns, feature_names=get_feature_names(feature_columns))
- Compiling and training the model:
model.compile("adam", "binary_crossentropy", metrics=['binary_crossentropy'])
history = model.fit(train_model_input, train_labels,
batch_size=256, epochs=10, verbose=2, validation_split=0.2)
- Making predictions:
pred_ans = model.predict(test_model_input, batch_size=256)
Getting Started
To get started with DeepCTR, follow these steps:
- Install the library:
pip install deepctr
- Import the necessary modules:
from deepctr.models import DeepFM
from deepctr.feature_column import SparseFeat, DenseFeat, get_feature_names
- Prepare your data and define feature columns:
feature_columns = [SparseFeat('user_id', vocabulary_size=100, embedding_dim=4),
SparseFeat('item_id', vocabulary_size=100, embedding_dim=4),
DenseFeat('user_age', 1)]
feature_names = get_feature_names(feature_columns)
- Create, compile, and train the model:
model = DeepFM(feature_columns, feature_names=feature_names)
model.compile("adam", "binary_crossentropy", metrics=['AUC'])
model.fit(train_model_input, train_labels, batch_size=256, epochs=10, validation_split=0.2)
Competitor Comparisons
An implementation of a deep learning recommendation model (DLRM)
Pros of DLRM
- Developed and maintained by Facebook, benefiting from their expertise in large-scale recommendation systems
- Focuses specifically on deep learning recommendation models, offering specialized features for this domain
- Includes both PyTorch and Caffe2 implementations, providing flexibility for different frameworks
Cons of DLRM
- Less comprehensive in terms of model variety compared to DeepCTR
- May have a steeper learning curve for users not familiar with Facebook's specific approach to recommendation systems
- Documentation could be more extensive, especially for beginners
Code Comparison
DLRM (PyTorch implementation):
dlrm = DLRM_Net(
m_spa, ln_emb, ln_bot, ln_top,
arch_interaction_op="dot",
arch_interaction_itself=False,
sigmoid_bot=-1, sigmoid_top=ln_top.size - 2,
sync_dense_params=True
)
DeepCTR (TensorFlow implementation):
model = DeepFM(linear_feature_columns, dnn_feature_columns, task='binary')
model.compile("adam", "binary_crossentropy", metrics=['binary_crossentropy'], )
Both repositories provide implementations for deep learning recommendation models, but they differ in their approach and focus. DLRM is more specialized for Facebook's recommendation use cases, while DeepCTR offers a wider range of models and may be more accessible for general use cases.
TensorFlow Recommenders is a library for building recommender system models using TensorFlow.
Pros of TensorFlow Recommenders
- Built on TensorFlow 2.x, offering better integration with the TensorFlow ecosystem
- Provides end-to-end solutions for building recommendation systems
- Includes pre-built models and layers specifically designed for recommendation tasks
Cons of TensorFlow Recommenders
- Less flexible compared to DeepCTR's modular approach
- Steeper learning curve for users not familiar with TensorFlow
- Limited support for some advanced CTR prediction models
Code Comparison
DeepCTR:
from deepctr.models import DeepFM
from deepctr.feature_column import SparseFeat, DenseFeat
model = DeepFM(linear_feature_columns, dnn_feature_columns)
model.compile("adam", "binary_crossentropy", metrics=['AUC'])
TensorFlow Recommenders:
import tensorflow_recommenders as tfrs
class MovieLensModel(tfrs.Model):
def __init__(self):
super().__init__()
self.ranking_model = tf.keras.Sequential([...])
self.task = tfrs.tasks.Ranking(...)
def call(self, features):
return self.ranking_model(features)
Both repositories offer powerful tools for building recommendation systems, but they cater to different user needs. DeepCTR provides a more flexible and modular approach, allowing users to easily implement various CTR prediction models. TensorFlow Recommenders, on the other hand, offers a more integrated solution within the TensorFlow ecosystem, with pre-built components specifically designed for recommendation tasks.
An industrial deep learning framework for high-dimension sparse data
Pros of x-deeplearning
- More comprehensive and enterprise-grade solution for large-scale deep learning
- Supports distributed training and inference on heterogeneous hardware
- Offers a wider range of advanced features and optimizations
Cons of x-deeplearning
- Steeper learning curve due to its complexity and extensive feature set
- Less focused on specific CTR prediction tasks compared to DeepCTR
- Requires more computational resources and setup time
Code Comparison
x-deeplearning:
import xdl
model = xdl.Model()
model.add(xdl.layers.Embedding(...)
model.add(xdl.layers.FCLayer(...))
model.compile(optimizer='adam', loss='binary_crossentropy')
DeepCTR:
from deepctr.models import DeepFM
model = DeepFM(linear_feature_columns, dnn_feature_columns)
model.compile(optimizer='adam', loss='binary_crossentropy')
Summary
x-deeplearning is a more comprehensive and powerful deep learning framework suitable for large-scale enterprise applications, while DeepCTR is more focused and easier to use for specific CTR prediction tasks. x-deeplearning offers advanced features and distributed training capabilities but requires more resources and expertise. DeepCTR provides a simpler API and is more accessible for smaller projects or those specifically focused on CTR prediction.
Pros of RecommenderSystems
- Focuses on graph-based recommendation algorithms, which can capture complex user-item interactions
- Includes implementations of advanced techniques like Graph Neural Networks (GNNs) for recommendations
- Provides a broader range of recommendation models beyond just CTR prediction
Cons of RecommenderSystems
- Less specialized in Click-Through Rate (CTR) prediction compared to DeepCTR
- May have a steeper learning curve due to its focus on graph-based methods
- Potentially less optimized for large-scale industrial applications
Code Comparison
DeepCTR example:
from deepctr.models import DeepFM
from deepctr.feature_column import SparseFeat, DenseFeat, get_feature_names
model = DeepFM(linear_feature_columns, dnn_feature_columns)
model.compile("adam", "binary_crossentropy", metrics=['AUC'])
RecommenderSystems example:
from recbole.quick_start import run_recbole
run_recbole(model='GCN', dataset='ml-100k')
The DeepCTR code shows a more explicit model setup, while RecommenderSystems offers a higher-level API for quick experimentation with different recommendation models and datasets.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
DeepCTR
DeepCTR is a Easy-to-use, Modular and Extendible package of deep-learning based CTR models along with lots of
core components layers which can be used to easily build custom models.You can use any complex model with model.fit()
ï¼and model.predict()
.
- Provide
tf.keras.Model
like interfaces for quick experiment. example - Provide
tensorflow estimator
interface for large scale data and distributed training. example - It is compatible with both
tf 1.x
andtf 2.x
.
Some related projects:
- DeepMatch: https://github.com/shenweichen/DeepMatch
- DeepCTR-Torch: https://github.com/shenweichen/DeepCTR-Torch
Let's Get Started!(Chinese Introduction) and welcome to join us!
Models List
Citation
- Weichen Shen. (2017). DeepCTR: Easy-to-use,Modular and Extendible package of deep-learning based CTR models. https://github.com/shenweichen/deepctr.
If you find this code useful in your research, please cite it using the following BibTeX:
@misc{shen2017deepctr,
author = {Weichen Shen},
title = {DeepCTR: Easy-to-use,Modular and Extendible package of deep-learning based CTR models},
year = {2017},
publisher = {GitHub},
journal = {GitHub Repository},
howpublished = {\url{https://github.com/shenweichen/deepctr}},
}
DisscussionGroup
- Github Discussions
- Wechat Discussions
å ¬ä¼å·ï¼æµ 梦å¦ä¹ ç¬è®° | 微信ï¼deepctrbot | å¦ä¹ å°ç» å å ¥ 主é¢éå |
---|---|---|
Main contributors(welcome to join us!)
â â Shen Weichen â Alibaba Group â |
Zan Shuxun â Alibaba Group â |
â â Harshit Pande Amazon â |
â â Lai Mincai ByteDance â |
â â Li Zichao ByteDance â |
â Tan Tingyi Chongqing University |
Top Related Projects
An implementation of a deep learning recommendation model (DLRM)
TensorFlow Recommenders is a library for building recommender system models using TensorFlow.
An industrial deep learning framework for high-dimension sparse data
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot