{"id":13418795,"url":"https://github.com/cnkuangshi/LightCTR","last_synced_at":"2025-03-15T04:30:42.595Z","repository":{"id":201792336,"uuid":"110526529","full_name":"cnkuangshi/LightCTR","owner":"cnkuangshi","description":"Lightweight and Scalable framework that combines mainstream algorithms of Click-Through-Rate prediction based computational DAG, philosophy of Parameter Server and Ring-AllReduce collective communication.","archived":false,"fork":false,"pushed_at":"2019-06-17T03:38:13.000Z","size":9871,"stargazers_count":674,"open_issues_count":2,"forks_count":142,"subscribers_count":59,"default_branch":"master","last_synced_at":"2024-07-31T22:44:05.113Z","etag":null,"topics":["computational-graphs","deep-learning","distributed-systems","factorization-machines","machine-learning","model-compression","parameter-server"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnkuangshi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-11-13T09:19:55.000Z","updated_at":"2024-05-31T08:43:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"625f043c-7bd4-46ac-a4fa-7404d4df80a4","html_url":"https://github.com/cnkuangshi/LightCTR","commit_stats":null,"previous_names":["cnkuangshi/lightctr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnkuangshi%2FLightCTR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnkuangshi%2FLightCTR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnkuangshi%2FLightCTR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnkuangshi%2FLightCTR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnkuangshi","download_url":"https://codeload.github.com/cnkuangshi/LightCTR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221536609,"owners_count":16839538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-graphs","deep-learning","distributed-systems","factorization-machines","machine-learning","model-compression","parameter-server"],"created_at":"2024-07-30T22:01:07.188Z","updated_at":"2025-03-15T04:30:42.565Z","avatar_url":"https://github.com/cnkuangshi.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings","C++"],"sub_categories":[],"readme":"![Alt text -w135](./LightCTR_LOGO.png)\n## LightCTR Overview\nLightCTR is a lightweight and scalable framework that combines mainstream algorithms of Click-Through-Rate prediction based **computational DAG, philosophy of Parameter Server and Ring-AllReduce collective communication**. The library is suitable for sparse data and designed for large-scale distributed model training.\n\nMeanwhile, LightCTR is also an **undergoing experimental study** and open source project that oriented to code readers. The clear execution logic will be of significance to leaners on the machine-learning related field.\n\n## Features\n* Distributed training based on Parameter Server and Ring-AllReduce collective communication\n* Directed Acyclic Graph(DAG) of autograd computation\n* Gradient clipping, stale synchronous parallel(SSP) and Asynchronous SGD with Delay compensation\n* Compressing Neural Network with Half precision and Quantization(PQ or Int8)\n* Shared parameters Key-Value pairs store in physical nodes by DHT in Shared memory\n* Lock-free Multi-threaded training and SIMD operations\n* Optimizer implemented by Mini-Batch GD, Adagrad, FTRL, Adam, etc\n\n## List of Implemented Algorithms\n\n* Wide \u0026 Deep Model\n* Factorization Machine, Field-aware Factorization Machine, Neural Factorization Machine\n* Gradient Boosting Tree Model\n* Gaussian Mixture Clustering Model\n* Topic Model PLSA, Embedding Model\n* Ngram Convolution Neural Network, Self-Attention Recurrent Neural Network\n* Variational AutoEncoder\n* Approximate Nearest Neighbors Retrieval\n\n## Benchmark\n#### High performance\n\u003cdiv\u003e\n\u003cimg style=\"float:left;\" src=\"https://github.com/cnkuangshi/LightCTR/blob/master/benchmark/vs_libfm.png\" width = \"350\"/\u003e\n\u003cimg style=\"float:left;\" src=\"https://github.com/cnkuangshi/LightCTR/blob/master/benchmark/vs_libffm.png\" width = \"350\"/\u003e\n\u003cimg style=\"float:left;\" src=\"https://github.com/cnkuangshi/LightCTR/blob/master/benchmark/vs_tf_cpu.png\" width = \"350\"/\u003e\n\u003c/div\u003e\n\n#### Scalable\n\u003cdiv\u003e\n\u003cimg style=\"float:left;\" src=\"https://github.com/cnkuangshi/LightCTR/blob/master/benchmark/4_node_ps.png\" width = \"420\"/\u003e\n\u003cimg style=\"float:left;\" src=\"https://github.com/cnkuangshi/LightCTR/blob/master/benchmark/4_node_ring.png\" width = \"420\"/\u003e\n\u003c/div\u003e\n\n## Introduction (zh)\n#### 用于群体发现\n点击率预估即是给合适的用户群体投放合适的内容，以达成促进广告收益或交易转化率的目的。具体操作来说，将收集到的用户点击与行为数据，用离散值与连续值结构化描述特征、归一化与De-bias等处理后，选择合适的模型拟合流量的数据分布，来对用户是否会对某一内容感兴趣并带来商业转化的概率进行评估；通常可将所有特征组合输入集成树模型`LightCTR::GBM`预先找群体，训练得到的每个叶子节点代表一个用户群，再使用`LightCTR::LR`或`LightCTR::MLP`对树模型建立的低维0/1群体特征做进一步分类。\n当标识类别的离散特征过多使得输入变得高维稀疏，可能达到树模型与神经网络的处理瓶颈；一般可使用`LightCTR::FM`或`LightCTR::FFM`将离散特征做特征交叉训练，提升了特征利用率并降低了数据稀疏下的过拟合的风险，每维特征映射在低维空间中，也方便作为连续特征输入其他模型。\n相比使用FM预训练特征低维映射后、再输入DNN中的两阶段训练，通过DNN在输入层按Field内部局部连接，在输入层直接端到端训练特征低维Embedding，可以更好的保证模型时效性；或采用将DNN嵌入FM模型中的`LightCTR::NFM`及其他相关变种，进行特征非线性高维组合，提升模型的表征能力，拥有更好的AUC表现。\n\n#### 用于行为序列\n用户点击内容序列往往蕴含内容间的局部相关性信息，如前后点击同一类商品或查看同一类网页，这些行为序列的局部关系可被`LightCTR::Embedding`建模捕获，得到点击内容或行为的低维隐向量表示；或基于变分自编码器`LightCTR::VAE`实现特征组合衍生，增强低维特征的表达能力；低维隐向量可被用来判断相关性或直接作为其他模型输入。进一步，序列数据经过平滑处理后，将训练好的行为隐向量按时序输入循环神经网络`LightCTR::LSTMUnit`，最后将RNN输出的特征表达输入`LightCTR::Softmax`分类器，利用预设的监督标签，训练对用户的评估模型或判别模型；\n当预设标签覆盖率不足时，可将高维特征表达输入`LightCTR::GMM`进行无监督聚类，聚类簇概括为意图簇，作为用户意图匹配的依据，补充到用户画像的人群类别中。\n\n#### 用于内容分析\n用户评论、搜索广告页面上下文等文本也蕴含很多用户的兴趣信息可被挖掘，如搜索广告场景下用户关键词需要匹配语义相关度最高的拍卖词进而投放高转化率的广告，因此分析文本信息是点击率预估的重要依据。在提取整段文本语义信息方面，首先可使用`LightCTR::Embedding`预先训练词向量表，对文本中出现的词按词频做词向量加权并移除主成分；或参考Skip-thought方法结合负例采样，将文本中每个词向量按时序输入`LightCTR::LSTMUnit`，训练得到文本的语义特征表达，向量内积对应文本相关度。此外，参考DSSM将由文本词向量构成的矩阵，输入Ngram卷积神经网络`LightCTR::CNN`用于提取句子局部语义相关性特征，并结合正负样本训练对预设标签的Pairwise判别模型。\n当文本缺乏分类标签时，可使用`LightCTR::PLSA`无监督的获取文章主题分布，应用于按主题分布区分不同内容类别、计算长语料与短查询间的语义相似度，也可通过后验计算得到上下文中各词汇的重要程度，作为长文本关键词摘要。\n\n#### 分层模型融合\n更复杂的模型带来更好的表征能力，但同时也加大了计算时间消耗，而响应时间与点击率呈强负相关，因此为了兼顾线上点击率预估的性能与效果，可使用不同模型逐层预测，如第一层采用在线学习、并引入稀疏解的简单模型`LightCTR::FTRL_LR`，第二层采用上文提到的输入层局部连接的`LightCTR::MLP`、或`LightCTR::NFM`等复杂模型进行精细预测。在系统层面，抽取并缓存DNN模型中最后一组全连接层权值或输出，作为用户或商品的固定表达，使用`LightCTR::ANN`近邻向量检索的TopN结果作为推荐召回，在最大化CTR/ROI的同时，降低线上推理的平均响应时间。此外，LightCTR在探索通过模型参数分位点压缩、二值网络等方法，在不损失预测精度前提下大幅提升计算效率。\n\n#### 多机多线程并行计算\nLightCTR使用SIMD向量化指令、流水线并行、多核心多线程计算、Cache-aware等多重优化手段实现单机高性能数值计算，但当模型参数量超过单机内存容量、或单机训练效率达不到时效性要求时，LightCTR进一步提供了基于参数服务器与Ring-AllReduce的可扩展模型集群训练方案。\n* 参数服务器模式下，集群分为Master, ParamServer与Worker三种角色；一个集群有一个Master负责集群启动与运行状态的维护，大规模模型稀疏与稠密Tensor参数以DHT散布在多个ParamServer上，与多个负责模型数据并行梯度运算的Worker协同，每轮训练都先从ParamServer拉取(Pull)一个样本Batch的参数，运算得到的参数梯度推送(Push)到ParamServer进行梯度汇总。ParamServer通过梯度TopK截断、延迟梯度补偿等手段，异步无锁、半同步的更新参数。参数在ParamServer上紧凑存储，按特征命中率进行优选与淘汰；使用变长编码/半精度/Int8的方式压缩梯度传输量，并用Batch化参数请求与读写分离的方法提升网络同步效率。\n* 环拓扑Ring-AllReduce模式下，LightCTR在不引入协调节点下实现集群训练进度的动态自平衡，结合梯度融合机制，实现了高效、高稳定性的去中心化梯度同步，适合稠密参数模型的可扩展训练；在这种模式下每个节点存储全量模型可单独提供推理预测能力，训练过程通过有限次迭代获取其他节点梯度结果，在一定集群规模与合适的Batch size、学习率设置下可实现训练任务的线性加速比。\n* LightCTR分布式集群采取心跳监控、消息重传等Failover容错方式。此外，LightCTR也在探索RDMA、DPDK、多网卡等网络优化方式来降低网络通信延时。\n\n## Quick Start\n* LightCTR depends on C++11 and ZeroMQ only, lightweight and modular design\n* Easy to use, just change configuration (e.g. Learning Rate, Data source) in `main.cpp`\n* run `./build.sh` to start training task on Parameter Server mode or `./build_ring.sh` to start on Ring-AllReduce mode\n* Current CI Status: [![Build Status](https://travis-ci.org/cnkuangshi/LightCTR.svg?branch=master)](https://travis-ci.org/cnkuangshi/LightCTR) on Ubuntu and MacOS\n\n## Welcome to Contribute\n* Welcome everyone interested in intersection of machine learning and scalable systems to contribute code, create issues or pull requests.\n* LightCTR is released under the Apache License, Version 2.0.\n\n## Disclaimer\n* Please note that LightCTR is still undergoing and it does not give any warranties, as to the suitability or usability.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnkuangshi%2FLightCTR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnkuangshi%2FLightCTR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnkuangshi%2FLightCTR/lists"}