├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── LICENSE ├── README.md ├── docs ├── biz │ ├── AdSys.md │ ├── LLMRec.md │ ├── PushSys.md │ ├── RecSys.md │ └── SearchSys.md ├── index.md ├── infra │ ├── BigData.md │ └── MachineLearning.md └── static │ ├── dnn_model.png │ └── recsys_jihoo_kim.jpg └── mkdocs.yml /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Docs 2 | on: 3 | push: 4 | branches: [ main ] 5 | jobs: 6 | deploy: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: actions/setup-python@v4 11 | - run: pip install mkdocs-material 12 | - run: mkdocs gh-deploy --force -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | site/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 zyxdtk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 1. RecSys-Notes 2 | 记录推荐系统相关的优化经验、学习笔记。 3 | 4 | 链接:[zyxdtk.github.io/RecSys-Notes/](https://zyxdtk.github.io/RecSys-Notes/) 5 | 6 | ## 目录 7 | - 基础 8 | - [todo]工程架构 9 | - 大数据 10 | - [todo]数据科学 11 | - 机器学习 12 | - 业务 13 | - 推荐系统 14 | - [todo]广告系统 15 | - [todo]搜索系统 16 | - [todo]Push 17 | - [todo]大模型时代 18 | 19 | 20 | ## 参考 21 | 22 | - [https://github.com/guyulongcs/Awesome-Deep-Learning-Papers-for-Search-Recommendation-Advertising](https://github.com/guyulongcs/Awesome-Deep-Learning-Papers-for-Search-Recommendation-Advertising) -------------------------------------------------------------------------------- /docs/biz/AdSys.md: -------------------------------------------------------------------------------- 1 | # 计算广告 2 | 3 | ## 学习资料 4 | 5 | - [互联网广告算法漫谈——引子](https://zhuanlan.zhihu.com/p/533658681) -------------------------------------------------------------------------------- /docs/biz/LLMRec.md: -------------------------------------------------------------------------------- 1 | # 1. 大模型在搜广推的应用 2 | 3 | 4 | ## 1.1. 生成式推荐 5 | 6 | - [2025.05] [MTGR:美团外卖生成式推荐Scaling Law落地实践](https://tech.meituan.com/2025/05/19/meituan-generative-recommendation.html) 美团 7 | - [2025.02] [Unlocking Scaling Law in Industrial Recommendation Systems with a Three-step Paradigm based Large User Model](https://arxiv.org/abs/2502.08309) 阿里 8 | - [2025.02] [OneRec: Unifying Retrieve and Rank with Generative Recommender and Iterative Preference Alignment](https://arxiv.org/abs/2502.18965) 快手 9 | - [2024.09] [HLLM: Enhancing Sequential Recommendations via Hierarchical Large Language Models for Item and User Modeling](https://arxiv.org/abs/2409.12740) 字节 10 | - [知乎](https://zhuanlan.zhihu.com/p/722159726) 11 | - [bytedance/HLLM](https://github.com/bytedance/HLLM) 12 | - [2024.02] [Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations](https://arxiv.org/abs/2402.17152) meta 13 | - [知乎](https://zhuanlan.zhihu.com/p/688952614) 14 | - [facebookresearch/generative-recommenders](https://github.com/facebookresearch/generative-recommenders) 15 | - [一文梳理业界落地LLM4Rec的若干范式](https://zhuanlan.zhihu.com/p/19923334099) 16 | - [2023.04] [DiffuRec: A Diffusion Model for Sequential Recommendation](https://arxiv.org/abs/2304.00686) -------------------------------------------------------------------------------- /docs/biz/PushSys.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyxdtk/RecSys-Notes/ee4aff9f4985784b9fbc205b0a2d831a9b607bef/docs/biz/PushSys.md -------------------------------------------------------------------------------- /docs/biz/RecSys.md: -------------------------------------------------------------------------------- 1 | # 1. RecSys-Notes 2 | 记录推荐系统相关的优化经验、学习笔记。 3 | 4 | - [1. RecSys-Notes](#1-recsys-notes) 5 | - [2. 推荐系统适用场景](#2-推荐系统适用场景) 6 | - [3. 推荐系统从0到1](#3-推荐系统从0到1) 7 | - [3.1. 冷启动](#31-冷启动) 8 | - [3.1.1. 系统冷启动](#311-系统冷启动) 9 | - [3.1.2. 新用户冷启动](#312-新用户冷启动) 10 | - [3.1.3. 新内容冷启动](#313-新内容冷启动) 11 | - [3.2. 搭建推荐系统](#32-搭建推荐系统) 12 | - [3.2.1. 数据采集](#321-数据采集) 13 | - [3.2.2. 数据处理](#322-数据处理) 14 | - [3.2.3. 推荐算法](#323-推荐算法) 15 | - [3.2.4. 评估体系](#324-评估体系) 16 | - [4. 推荐系统优化](#4-推荐系统优化) 17 | - [4.1. 召回优化](#41-召回优化) 18 | - [4.1.1. 召回的评估](#411-召回的评估) 19 | - [4.1.2. 召回算法](#412-召回算法) 20 | - [4.1.3. 召回负样本处理](#413-召回负样本处理) 21 | - [4.1.4. 推荐历史去重](#414-推荐历史去重) 22 | - [4.2. 排序优化](#42-排序优化) 23 | - [4.2.1. 排序的评估](#421-排序的评估) 24 | - [4.2.2. 代理指标](#422-代理指标) 25 | - [4.2.3. 特征工程](#423-特征工程) 26 | - [4.2.4. 样本](#424-样本) 27 | - [4.2.5. 模型](#425-模型) 28 | - [4.2.6. 偏置处理](#426-偏置处理) 29 | - [4.3. 策略优化](#43-策略优化) 30 | - [4.3.1. 打造生态:消费者、生产者、平台三方利益兼顾](#431-打造生态消费者生产者平台三方利益兼顾) 31 | - [4.3.2. 流量扶持:新内容、新生产者、新品类](#432-流量扶持新内容新生产者新品类) 32 | - [4.3.3. 探索与利用](#433-探索与利用) 33 | - [4.3.4. 如何缓解头部效应](#434-如何缓解头部效应) 34 | - [4.3.5. 重排模型](#435-重排模型) 35 | - [5. 推荐系统的未来](#5-推荐系统的未来) 36 | - [5.1. 对长期收益建模](#51-对长期收益建模) 37 | - [5.2. 对item组合建模](#52-对item组合建模) 38 | - [5.3. 极致的时效性](#53-极致的时效性) 39 | - [5.4. 更丰富的交互信息](#54-更丰富的交互信息) 40 | - [5.5. 与其他模块的协同](#55-与其他模块的协同) 41 | - [5.6. 自动化AutoML](#56-自动化automl) 42 | - [6. 学习资源](#6-学习资源) 43 | 44 | # 2. 推荐系统适用场景 45 | 信息过载+无明确意图 46 | 47 | # 3. 推荐系统从0到1 48 | 在开始搭建推荐系统前,建议可以看看[Google的机器学习最佳实践(共43条)](https://developers.google.com/machine-learning/guides/rules-of-ml)[【汉】](https://www.jiqizhixin.com/articles/2018-05-22-12)。里面讲到进行机器学习的基本方法是: 49 | 50 | 1. 确保机器学习流程从头到尾都稳固可靠。 51 | 2. 从制定合理的目标开始。 52 | 3. 以简单的方式添加常识性特征。 53 | 4. 确保机器学习流程始终稳固可靠。 54 | 55 | 上述方法将在长时间内取得很好的效果。只要您仍然可以通过某种简单的技巧取得进展,就不应该偏离上述方法。增加复杂性会减缓未来版本的发布。 56 | 57 | 58 | 从0到1就是要解决冷启动问题,冷启动问题可以用产品的办法解决,也可以在推荐系统内解决。 59 | 60 | ## 3.1. 冷启动 61 | ### 3.1.1. 系统冷启动 62 | ### 3.1.2. 新用户冷启动 63 | ### 3.1.3. 新内容冷启动 64 | 65 | ## 3.2. 搭建推荐系统 66 | 一个完整的推荐系统包括:数据采集、数据处理、推荐算法、评估体系。下图把推荐系统的基本结构描述得非常清除了。 67 | 68 | ![](../static/recsys_jihoo_kim.jpg) 69 | 70 | 来源:[jihoo-kim/awesome-RecSys](https://github.com/jihoo-kim/awesome-RecSys) 71 | 72 | ### 3.2.1. 数据采集 73 | 数据采集包括了:用户信息采集(人群属性、兴趣问卷),用户行为数据采集(埋点日志),推荐日志,内容打标。 74 | 75 | ### 3.2.2. 数据处理 76 | 数据处理包括:样本生成、特征工程、报表 77 | 78 | ### 3.2.3. 推荐算法 79 | 经典推荐架构:召回、排序、策略。从0到1的过程中需要特别关注冷启动问题:系统冷启动、用户冷启动、内容冷启动。 80 | - 召回。冷启动阶段没有太多用户行为数据。可以采集用户信息、多利用item标签、捕捉实时信息。热门召回、人群热门召回、用户采集兴趣召回、用户实时兴趣召回。另外需要做召回去重。 81 | - 排序。冷启动阶段最好是用单目标简单模型,把整个流程跑通。 82 | - 策略。黑白名单、调权、频控、打散、保量 83 | 84 | 有一些开源的推荐系统框架(2022-07-01更新star数): 85 | 86 | - [13.5k] [microsoft/recommenders](https://github.com/microsoft/recommenders) 87 | - [6.2k] [shenweichen/DeepCTR](https://github.com/shenweichen/DeepCTR) 兼容tf1和tf2 88 | - [2k] [shenweichen/DeepCTR-Torch(https://github.com/shenweichen/DeepCTR-Torch) pytorch版本 89 | - [5.9k] [gorse-io/gorse](https://github.com/gorse-io/gorse) 用go实现的推荐系统 90 | - [3.1k] [PaddlePaddle/PaddleRec](https://github.com/PaddlePaddle/PaddleRec) 百度开源,基于PaddlePaddle 91 | - [1.3k] [tensorflow/recommenders](https://github.com/tensorflow/recommenders) 92 | - [1k] [pytorch/torchrec](https://github.com/pytorch/torchrec) 93 | - [0.6k] [alibaba/EasyRec](https://github.com/alibaba/EasyRec) 兼容TF1.12-1.15 / TF2.x / PAI-TF 94 | 95 | 96 | ### 3.2.4. 评估体系 97 | 评估体系包括:在线评估(ABtest、报表)、离线评估。 98 | 99 | # 4. 推荐系统优化 100 | 101 | ## 4.1. 召回优化 102 | 103 | ### 4.1.1. 召回的评估 104 | 召回率、准确率、hit率、内容覆盖度、基尼指数 105 | 106 | ### 4.1.2. 召回算法 107 | 108 | - 热门召回 109 | - 基于人群属性 110 | - 协同过滤 111 | - [2013] [Amazon.com recommendations:Item-to-item collaborative filtering](https://www.cs.umd.edu/~samir/498/Amazon-Recommendations.pdf) 亚马逊提出经典的item-based协同过滤算法 112 | - 基于向量 113 | - 无监督,类似word2vec 114 | - [2017] [Item2Vec-Neural Item Embedding for Collaborative Filtering](https://arxiv.org/pdf/1603.04259.pdf) 其实就是word2vec 115 | - [2018] [Real-time Personalization using Embeddings for Search Ranking at Airbnb](https://www.researchgate.net/publication/326503432_Real-time_Personalization_using_Embeddings_for_Search_Ranking_at_Airbnb)[【汉】](https://blog.csdn.net/da_kao_la/article/details/105798365) airbnb的房源来旭,基于word2vec,在样本的选择上有很多trick 116 | - 无监督 Graph Embedding 117 | - [2014] [DeepWalk: Online Learning of Social Representations](https://arxiv.org/pdf/1403.6652.pdf)][【汉】](https://zhuanlan.zhihu.com/p/45167021) 无权图+ random-walk + word2vec,学习网络结构,偏DFS 118 | - [2015] [LINE: Large-scale Information Network Embedding](https://arxiv.org/pdf/1503.03578.pdf)[【汉】](https://zhuanlan.zhihu.com/p/56478167) 二阶优化,Negative Sampling,alias负采样,偏BFS 119 | - [2016] [node2vec: Scalable Feature Learning for Networks](https://arxiv.org/pdf/1607.00653.pdf)[【汉】](https://zhuanlan.zhihu.com/p/56478167),兼顾DFS和BFS 120 | - [2018] [Billion-scale Commodity Embedding for E-commerce Recommendation in Alibaba](https://arxiv.org/abs/1803.02349)[【汉】](http://felixzhao.cn/Articles/article/8) 引入side info,weight avg polling, 121 | - 有监督 122 | - [2013] [DSSM](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/cikm2013_DSSM_fullversion.pdf)[【汉】](http://felixzhao.cn/Articles/article/4) 123 | - 论文用的 sample softmax 4个负样本 124 | - 也可以用[triplet loss](https://zhuanlan.zhihu.com/p/136948465) 高内聚,低耦合 125 | - [2016] [DeepMatch:Deep Neural Networks for YouTube Recommendations](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/45530.pdf)[【汉】](http://felixzhao.cn/Articles/article/15) 126 | - 每个用户固定样本数量,避免高活用户带偏模型。加入样本年龄来消偏。ranking阶段用时长加权。 127 | - serving的时候用ANN库,如Faiss、HNSW 128 | - [2018] [TDM: Learning Tree-based Deep Model for Recommender Systems](https://arxiv.org/pdf/1801.02294.pdf)[【汉】](https://blog.csdn.net/XindiOntheWay/article/details/85220342) 利用品类信息初始化数,学到向量之后用k-means聚类 129 | - [2019] [MOBIUS: Towards the Next Generation of Query-Ad Matching in Baidu’s Sponsored Search](http://research.baidu.com/Public/uploads/5d12eca098d40.pdf)[【汉】](https://zhuanlan.zhihu.com/p/144765227) 广告召回兼顾相关性和CTR等业务指标。人工构造低相关高ctr的样本做为负样本。 130 | - [2019] [Deep Semantic Matching for Amazon Product Search](https://wsdm2019-dapa.github.io/slides/05-YiweiSong.pdf) 购买、曝光未购买、随机三类样本,商品这边用n-gram引入商品title然后和商品其他属性特征一起过nn得到商品的向量。把oov的n-gram hash到指定数量的bin里面。 131 | - [2019] [SDM: Sequential Deep Matching Model for Online Large-scale Recommender System](https://arxiv.org/pdf/1909.00385.pdf)[【汉】](http://felixzhao.cn/Articles/article/11) 短期兴趣是一个session内的行为,最多50个,用lstm + multi-head self-attention + user attention, 长期兴趣是7天,各种序列,先过atten,然后concat到一起。最后又搞了一个gate来融合长短期特征。就一个疑问:召回模型这么搞能训得动吗? 132 | - [2019] [Multi-Interest Network with Dynamic Routing for Recommendation at Tmall](https://arxiv.org/abs/1904.08030)[【汉】](https://blog.csdn.net/whgyxy/article/details/123515246) 133 | - [2020] [Deep Retrieval: Learning A Retrievable Structure for Large-Scale Recommendations](https://arxiv.org/pdf/2007.07203.pdf)[【汉】](https://zhuanlan.zhihu.com/p/260453374) 134 | - [2020] [Embedding-based Retrieval in Facebook Search](https://arxiv.org/pdf/2006.11632.pdf)[【汉】](https://wulc.me/2020/08/30/%E3%80%8AEmbedding-based%20Retrieval%20in%20Facebook%20Search%E3%80%8B%E9%98%85%E8%AF%BB%E7%AC%94%E8%AE%B0/) 双塔模型,负样本选择,serv的处理,非常的工业风 135 | - [2020] [Controllable Multi-Interest Framework for Recommendation](https://arxiv.org/abs/2005.09347?context=cs.LG)[【汉】](https://zhuanlan.zhihu.com/p/267870721) 136 | - [2021] [Que2Search: Fast and Accurate Query and Document Understanding for Search at Facebook](https://research.facebook.com/publications/que2search-fast-and-accurate-query-and-document-understanding-for-search-at-facebook/)[【汉】](https://zhuanlan.zhihu.com/p/449725861) 137 | - [2021] [Embedding based Product Retrieval in Taobao Search](https://arxiv.org/pdf/2106.09297.pdf)[【汉】](https://zhuanlan.zhihu.com/p/410331760) 双塔,把用户侧搞得特别复杂,有query(query用n-gram,transormer等各种放方法处理),有用户行为序列(实时、短期、长期),有lstm,transformer、attention等来处理序列。 138 | - [2021] [Pre-trained Language Model for Web-scale Retrieval in Baidu Search](https://arxiv.org/pdf/2106.03373.pdf)[【汉】](https://blog.csdn.net/Kaiyuan_sjtu/article/details/119770178) 139 | 140 | 构建item向量索引: 141 | 142 | - 向量索引的方法 143 | - 树,如KDtree 144 | - hash,如LSH 145 | - 聚类倒排,倒排里面有PCA降维,PQ降精度 146 | - 图算法,如NSW 147 | - 开源向量索引库(2022-07-02更新star数) 148 | - [17.3k] [faiss](https://github.com/facebookresearch/faiss) 支持billion级别向量索引 149 | - [faiss原理(Product Quantization)](https://zhuanlan.zhihu.com/p/534004381) IVFPQ,支持L2和内积 150 | - [Billion-scale similarity search with GPUs](https://arxiv.org/pdf/1702.08734.pdf) 151 | - [11.2k] [milvus](https://github.com/milvus-io/milvus) 已经是一个数据库了 152 | - [architecture_overview](https://milvus.io/docs/architecture_overview.md) 153 | - [前所未有的 Milvus 源码架构解析](https://zhuanlan.zhihu.com/p/473617910) 154 | - [10k] [annoy](https://github.com/spotify/annoy) 支持 欧氏距离,曼哈顿距离,余弦距离,汉明距离或点(内)乘积距离 155 | - [一文带你了解Annoy!](https://zhuanlan.zhihu.com/p/109633593) 156 | - [2k] [hnswlib](https://github.com/nmslib/hnswlib) 支持L2、内积、cos等距离方法 157 | - [Bithack/go-hnsw](https://github.com/Bithack/go-hnsw) 158 | - [ANN召回算法之HNSW](https://zhuanlan.zhihu.com/p/379372268) 159 | - [1.4K] [vearch](https://github.com/vearch/vearch) 京东开源 160 | - [24k] [google-research/tree/master/scann](https://github.com/google-research/google-research/tree/master/scann) 161 | 162 | 参考: [几款多模态向量检索引擎:Faiss 、milvus、Proxima、vearch、Jina等](https://zhuanlan.zhihu.com/p/364923722) 163 | 164 | ### 4.1.3. 召回负样本处理 165 | 166 | ### 4.1.4. 推荐历史去重 167 | 168 | ## 4.2. 排序优化 169 | 170 | ### 4.2.1. 排序的评估 171 | - 线上评估 172 | - ABtest。留存、时长、ctr、刷帖、点赞、评论、转发等 173 | - 模型评估指标。在线auc、gauc 174 | - 离线评估 175 | - 分类。auc、guac 176 | - 回归。rmse、mae、mape 177 | - debug工具 178 | - 推荐线上服务debug 179 | - 在推荐的整个留存打印debug信息,然后把debug信息放到debug工具中展示。 180 | - 模型debug 181 | - TensorBoard 182 | 183 | 184 | 评估指标 185 | 186 | - [MAP](https://zhuanlan.zhihu.com/p/274563041) (Mean Average Precision) 187 | - NDCG (Normalized Discounted Cumulative Gain) 188 | 189 | ### 4.2.2. 代理指标 190 | 不同业务线的业务目标,用户关键行为都不一样,需要针对性的建模。另外构建一套样本是成本非常大的事情,包括推动前端增改卖点,大数据做好样本关联,数据校验,累计一段时间样本用于训练,整个周期会非常长。所以一般推荐在一开始就把所有能想到的user-item的行为数据都做好埋点。 191 | 192 | - 电商 193 | - GMV。GMV=DAU*CTR*CVR*下单次数*单均价。以上指标一般是uv维度,按照天、周级别统计。无法作为直接排序label 194 | - item级别行为。曝光、击、加购、下单、成单、评分。电商的行为在时间维度上可能不较长,如成单、评分等动作的延迟甚至可能是几天。 195 | - 娱乐 196 | - 用户总停留时长。TotalDur=DAU*刷帖数*贴均时长=(DNU+DAU*留存)*刷帖数*贴均时长。 197 | - item级别行为。 198 | - 隐式反馈:曝光、点击、时长、完播 199 | - 显式反馈:点赞、评论、转发 200 | - 社交 201 | - 总互动。总互动=DAU*匹配率*互动数。 202 | - item级别行为。曝光、点击、关注、互动 203 | 204 | 排序的迭代路径一般是由一轮排序,到包含粗排、精排的两轮排序。甚至随着候选池的增加,可以增加更多轮排序。由单一目标排序,到多目标融合排序。由简单模型到复杂模型。LR、FM、Wide&Deep、DIN、MMOE、SNR 205 | 206 | 引入多目标的几种方式: 207 | - 样本调权 208 | - 见:[街首页推荐多目标优化之reweight实践:一把双刃剑?](https://zhuanlan.zhihu.com/p/271858727) 209 | - 线性加权。Score = a*scoreA + b * scoreB + c * ScoreC + … + m * ScoreM 210 | - 乘法加权。一般用在电商场景 Score = pow(ctr+ai, bi) * pow(price+aj, bj) 211 | 212 | 业界的一些多目标融合的实践: 213 | - [BIGO | 内容流多目标排序优化](https://toutiao.io/posts/ds6kdac/preview) 214 | - [爱奇艺:多目标排序在爱奇艺短视频推荐中的应用](https://juejin.cn/post/6977633076390133796) 215 | - [快手:多目标排序在快手短视频推荐中的实践](http://www.360doc.com/content/21/0225/09/7673502_963854442.shtml) 216 | 217 | 218 | ### 4.2.3. 特征工程 219 | - 主体维度 220 | - 用户 221 | - 人群属性 222 | - 行为特征 223 | - 统计特征 224 | - item 225 | - 标签 226 | - 统计特征 227 | - context 228 | - 地理位置 229 | - 时间 230 | - 推荐tab 231 | - 时效性维度 232 | - 批量特征 233 | - 实时特征 234 | 235 | 236 | 内容理解。通过NLP和CV的能力,给视频、图片的自动打标。做好场景识别、人脸识别、OCR、文本的关键词提取等。 237 | NLP相关: 238 | 239 | - Glove [NLP模型笔记】GloVe模型简介](https://blog.csdn.net/edogawachia/article/details/105804378) 相比起绝对地描述一个词语,通过与第三者的比较,得到第三者与两个词语中的哪个更接近这样一个相对的关系,来表达词语的含义,实际上更符合我们对于语言的认知。这样学习出来的vector space具有一个meaningful substructure。 240 | - [dav-word2vec](https://github.com/dav/word2vec) [【汉】](https://www.jianshu.com/p/471d9bfbd72f) google的word2vec 241 | - [2016] [Bag of Tricks for Efficient Text Classification](https://arxiv.org/pdf/1607.01759.pdf)[【汉】](https://blog.51cto.com/u_13933750/3229465) facebook开源的FastText,char-level n-gram, 242 | - [2017] [Attention Is All You Need](https://arxiv.org/abs/1706.03762) Transformer 243 | - [2018] [BERT(Bidirectional Encoder Representations from Transformers)](https://github.com/google-research/bert/) 上下文相关的表达,采用底层的双向编码,预训练与调优 244 | - [【NLP】彻底搞懂BERT](https://www.cnblogs.com/rucwxb/p/10277217.html) 245 | - [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805) 246 | - [BERT代码解读(3)-输出](https://www.jianshu.com/p/683b133310a6) 247 | 248 | CV相关 249 | 250 | - [PaddleVideo](https://github.com/PaddlePaddle/PaddleVideo) 251 | 252 | 253 | ### 4.2.4. 样本 254 | 样本=label+特征。 255 | label一般来自客户端的埋点,也有用到服务端数据的(比如,点赞、成单等数据服务端也有记录)。一般都会有多个label日志(曝光、点击、时长、点赞等),需要把这些日志关联起来。特征来源于推荐埋点日志或离线批处理特征,最好是把特征都埋在推荐replay日志中,这样可以避免离线在线特征不一致问题。label埋点和推荐replay日志的关联可以通过约定的唯一性id来确定,如:user_id、item_id对,或者唯一性的session_id。 256 | 257 | label埋点日志关联,可以在客户端关联,也可以在大数据这里关联。为了减少客户端的复杂性,现在一般都是无代码埋点,只埋事件日志,然后由大数据这边关联。中间存在一些问题: 258 | 259 | - 日志丢失 260 | - 客户端要做日志的持久化, 会导致日志延迟比较大,不过总比丢了好 261 | - 日志回传要做好丢包重传等机制 262 | - 服务端接收后一般是直接到kafka 263 | - user-itme粒度的日志回传事件跨度大 264 | - 天级别批处理,要做好跨天的处理 265 | - 实时关联,一般设定cache时间窗口 266 | - 负样本cache,[skip-above](https://tech.meituan.com/2016/04/21/online-learning.html) 267 | - [负样本不cache](https://www.infoq.cn/article/lTHcDaZelZgC639P1P5q),会有False Negative问题 268 | - 样本重要性采样(importance sampling) 269 | - FN矫正 270 | - PU loss (Positive-unlabeled loss) 问题是来多个正样本怎么办 271 | - 延迟反馈 Loss 272 | 273 | 274 | ### 4.2.5. 模型 275 | 正则:L1、L2、Dropout、BatchNorm、Relu 276 | 序列建模:Attention、Transformer、GRU、LSTM 277 | 参数共享:gate、routing 278 | 优化器:FTRL、Adagrad、Adam 279 | 280 | 281 | 树模型: 282 | 283 | - GBDT 284 | - [GBDT(MART) 迭代决策树入门教程 | 简介](http://blog.csdn.net/w28971023/article/details/8240756) 285 | - [GBDT:梯度提升决策树](http://www.jianshu.com/p/005a4e6ac775) 看过之后对gbdt原理有了大概了解,感觉还需要去了解决策树、adaboost、random forest、xgboost 这些东西。 286 | - [机器学习算法总结--GBDT](http://blog.csdn.net/lc013/article/details/56667157) 287 | - [Xgboost](https://github.com/dmlc/xgboost) 288 | - [Introduction to Boosted Trees](https://xgboost.readthedocs.io/en/stable/tutorials/model.html) 1.5h xgboost官网上对BT介绍文章,这个文章降低非常浅显易懂,首先摆出训练时的优化函数=偏差+复杂度,我们要在减少偏差和减少复杂度之间寻求平衡,先讲了CART的结构,然后讲BT是一步步添加树的,然后讲到每次添加一棵树的时候,是如何从众多树里面寻找到最好的那颗树,这里面就是刚刚说的优化函数。最后在讲了单颗的训练过程中也可以尽量去优化。感觉大致懂了,有时间再去深究里面的一些东西吧。  论文 [XGBoost: A Scalable Tree Boosting System](http://www.kdd.org/kdd2016/papers/files/rfp0697-chenAemb.pdf) 289 | - [xgboost 实战以及源代码分析](http://m.blog.csdn.net/u010159842/article/details/77503930) 290 | - [xgboost_code_analysis](https://github.com/daoliker/xgboost_code_analysis) 291 | - [XGboost核心源码阅读](http://mlnote.com/2016/10/29/xgboost-code-review-with-paper/) 292 | - [DART booster](http://xgboost.apachecn.org/cn/latest/tutorials/dart.html) 在gbtree.cc中看到dart,特性就是通过drop树来解决over-fitting。但是预测会变慢,early-stop可能不稳定。 293 | - [Dropout 解决 overfitting](https://www.jianshu.com/p/b5e93fa01385) 简单搜了下,在NN中就是drop一些单元,属于一种正则化的手段。 294 | - [Monotonic Constraints](https://xgboost.readthedocs.io/en/latest/tutorials/monotonic.html) 在模型训练中添加单调性约束 295 | - 模型调参 296 | - [xgboost参数](http://xgboost.readthedocs.io/en/latest/parameter.html)([汉](http://blog.sina.com.cn/s/blog_9132d85b0102w65l.html)) 这些参数不太懂:gamma 、 max_delta_step、colsample_bylevel、alpha、lambda、 b。 297 | 个人理解所有的GB,学出来的都是tree,本质上就是用特征将目标进行分类。一颗树学习得太浅,所以会学出很多颗tree,然后加权到一起,这样可以学得更精细一点,可以对一个特征进行更多次切分,可以试验多种特征组合。 298 | 然后由于用于训练的样本是有限的,训练样本级与实际总样本之间可能存在偏差,而我们学到的森林其实是对我们的样本集的统计学特性的模拟,和样本拟合得太匹配,就越容易拟合到其中的偏差部分。所以会通过控制树的深度、叶子节点的样本最小数量等控制精度,以免学得太过了。 299 | 由于样本收集的时候可能存在一些不随机的部分,就是有偏差。我们在样本集的基础上,做一些处理,来消除这个不随机的部分。一种是随机的抽一部分样本(随机样本子集),一种是训练的时候只训练一部分特征(随机特征子集)。 300 | 还有一种就是我们学习的时候,不要学得太像这个样本了,就是所谓的学习率调低一点,学习得更模糊一点。 301 | 另一方面因为是GB,就是梯队推进,就是走一段路看一下调整方向,然后继续继续往前走一步。这个过程中,如果每次走的路短一点,就是增加了对齐方向的次数,就越不容易出现偏差,就不容易过拟合。 302 | 如果样本集的正负样本数量差距太大,可能导致正样本被埋没了,所以有必要增加正样本的权重。 303 | - [param_tuning](https://xgboost.readthedocs.io/en/latest/tutorials/param_tuning.html) 理解样本偏差,控制过拟合,处理不平衡的数据集。 304 | - [论XGBOOST科学调参](https://zhuanlan.zhihu.com/p/25308120) 305 | - [为什么xgboost/gbdt在调参时为什么树的深度很少就能达到很高的精度?](https://www.zhihu.com/question/45487317) 306 | - [机器学习算法中GBDT和XGBOOST的区别有哪些?](https://www.zhihu.com/question/41354392) 307 | - [xgboost如何使用MAE或MAPE作为目标函数?](https://zhuanlan.zhihu.com/p/34373008) 308 | - [Xgboost-How to use “mae” as objective function?](https://stackoverflow.com/questions/45006341/xgboost-how-to-use-mae-as-objective-function) 309 | - 模型分析 310 | - [xgbfi](https://github.com/limexp/xgbfir) xgboost特征交互和重要度。里面提到用Gain(特征增益)和Cover(分裂方向的概率)构造出期望增益ExpectedGain,相比于分裂次数更能体现特征的实际作用。另外考虑了如何评估多个特征之间的影响,就是计算一条路径的增益。不过工具还不完善,对评估指标本身也没有进行详细解释。 311 | - [Understand your dataset with XGBoost](http://xgboost.readthedocs.io/en/latest/R-package/discoverYourData.html) xgboost提供了特征重要度工具,主要有gain和cover 312 | - [LightGBM](https://github.com/Microsoft/LightGBM) 313 | - [如何看待微软新开源的LightGBM?](https://www.zhihu.com/question/51644470/answer/130946285) 314 | - [LightGBM 的中文文档](http://lightgbm.apachecn.org/cn/latest/index.html) 315 | 316 | 317 | ![](../static/dnn_model.png) 318 | 319 | 来源:[从算法到工程,推荐系统全面总结](https://www.infoq.cn/article/qeawCIJQfrycQpueaqs4) 320 | 321 | 从LR到DNN模型: 322 | 323 | - [2007] [Predicting clicks: estimating the click-through rate for new ads](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/predictingclicks.pdf) LR算法应用于CTR问题 324 | - [2010] [Factorization Machines](https://www.csie.ntu.edu.tw/~b97053/paper/Rendle2010FM.pdf) FM算法 325 | - [2011] [Fast Context-aware Recommendations with Factorization Machines](https://www.ismll.uni-hildesheim.de/pub/pdfs/Rendle_et_al2011-Context_Aware.pdf) 326 | - [2013] [Ad Click Prediction: a View from the Trenches](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/41159.pdf) 提出了FTRL算法 327 | - [2014] [Practical lessons from predicting clicks on ads at facebook](https://quinonero.net/Publications/predicting-clicks-facebook.pdf) LR+GBDT组合模型 328 | - [2016] [Deep Neural Networks for YouTube Recommendations](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/45530.pdf) 排序这里用时长作为正样本权重,然后预估近似时长 329 | - [2016] [Wide & Deep Learning for Recommender Systems](https://arxiv.org/abs/1606.07792)[【汉】](http://felixzhao.cn/Articles/article/18) wide记忆,deep稠密特征交叉 330 | - 特征交叉 331 | - [2016] [Deep Crossing: Web-Scale Modeling without Manually Crafted Combinatorial Features](https://www.kdd.org/kdd2016/papers/files/adf0975-shanA.pdf)[【汉】](https://zhuanlan.zhihu.com/p/91057914) 没用过。感觉跟其他DNN模型差不多,可能跟DSSM比,emb喂给MLP更早,所以叫corss吧。 332 | - [2016] [Product-based Neural Networks for User Response Prediction](https://arxiv.org/abs/1611.00144)[【汉】](https://blog.csdn.net/XindiOntheWay/article/details/105618692) emb先做两两交叉,然后再喂给MLP。 333 | - [2017] [DeepFM : A Factorization-Machine based Neural Network for CTR Prediction](https://arxiv.org/abs/1703.04247)[【汉】](http://felixzhao.cn/Articles/article/26)DeepFM在Wide&Deep的基础上引入了交叉特征,使得模型能够更好的学习到组合特征,wide是一阶,FM是二阶交叉,MLP是高阶交叉。 334 | - [2017] [Deep & Cross Network for Ad Click Predictions](https://arxiv.org/abs/1708.05123)[【汉】](http://felixzhao.cn/Articles/article/25) 对Wide & Deep模型优化,将Wide & Deep模型中的Wide部分替换成Cross network,用于自动化特征交叉。试过,参数量有点大。 335 | - [2017] [Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks](https://arxiv.org/abs/1708.04617)[【汉】](https://blog.csdn.net/buwei0239/article/details/86766008) AFM对FM不同的特征交互引入不同重要性来改善FM,重要性通过注意力机制来学习; 336 | - [2018] [xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems](https://arxiv.org/abs/1803.05170)[【汉】](https://blog.csdn.net/qq_40006058/article/details/88870482) 在DCN基础上,用CIN代替cross网络,每个vector一个参数,而不是每个bit一个参数。 337 | - [2019] [Feature Generation by Convolutional Neural Network for Click-Through Rate Prediction](https://arxiv.org/pdf/1904.04447.pdf)[【汉】](https://blog.csdn.net/w55100/article/details/90601310) 底层用卷积在做特征的局部交叉 338 | - [2019] [Interaction-aware Factorization Machines for Recommender Systems](https://arxiv.org/pdf/1902.09757.pdf) 有点像AFM,在FM基础上魔改。 339 | - [2019] [FiBiNET: Combining Feature Importance and Bilinear feature Interaction for Click-Through Rate Prediction](https://arxiv.org/pdf/1905.09433.pdf) [【汉】](https://zhuanlan.zhihu.com/p/72931811)通常处理特征交叉是通过Hadamard product和inner product,很少关注交叉特征的重要性,在FiBiNET中,改进特征的交叉方式以及增加特征重要行的学习,分别通过**SENET**机制动态学习特征的重要性,通过**bilinear**函数学习特征的交叉 340 | - [2019] [AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks](https://arxiv.org/pdf/1810.11921.pdf)[【汉】](https://blog.csdn.net/pearl8899/article/details/106747210) 用multi-head self attention来学习emb的交叉 341 | - 序列特征建模 342 | - [2016] [Session-based Recommendations with Recurrent Neural Networks](https://arxiv.org/pdf/1511.06939.pdf)[【汉】](https://zhuanlan.zhihu.com/p/28776432) 用GRU来对用户session序列建模,不过很少这么建模。因为还要考虑跟其他特征怎么组合进来的问题。 343 | - [2018] [Deep Interest Network for Click-Through Rate Prediction](https://arxiv.org/abs/1706.06978)[【汉】](https://zhuanlan.zhihu.com/p/54085498) DIN其实就是序列emb加权求和 344 | - [2019] [Behavior Sequence Transformer for E-commerce Recommendation in Alibaba](https://arxiv.org/abs/1905.06874v1)[【汉】](https://zhuanlan.zhihu.com/p/96338316) item序列过tranformer,多层tranformer后auc反而降低 345 | - [2019] [Deep Interest Evolution Network for Click-Through Rate Prediction](https://arxiv.org/abs/1809.03672) DIEN,用GRU来建模用户兴趣迁移 346 | - [2019] [Deep Session Interest Network for Click-Through Rate Prediction](https://arxiv.org/pdf/1905.06482.pdf)[【汉】](https://zhuanlan.zhihu.com/p/71695849) 347 | - [2019] [BERT4Rec: Sequential Recommendation with Bidirectional Encoder Representations from Transformer](https://arxiv.org/pdf/1904.06690.pdf)[【汉】](https://blog.csdn.net/pearl8899/article/details/118003945) 直接用bert来建模用户序列特征 348 | - [2017] [Learning Piece-wise Linear Models from Large Scale Data for Ad Click Prediction](https://arxiv.org/pdf/1704.05194.pdf)[【汉】](https://zhuanlan.zhihu.com/p/392793309) 阿里的MLR模型,把样本聚成多簇,然后分别用LR去分类。 349 | - [2019] [Real-time Attention Based Look-alike Model for Recommender System](https://arxiv.org/abs/1906.05022) 实时Look-alike 算法在微信看一看中的应用 350 | - [2019] [Deep Learning Recommendation Model for Personalization and Recommendation Systems](https://arxiv.org/abs/1906.00091v1) facebook的DLRM,比较工业风 351 | - [2020] [FuxiCTR: An Open Benchmark for Click-Through Rate Prediction](https://arxiv.org/abs/2009.05794) [【汉】](https://blog.csdn.net/Eric_1993/article/details/109038340)对多种CTR模型的对比,包括浅层模型和深度模型,浅层模型包括LR,FM,FFM等,深度模型包括DNN,Wide&Deep,PNN等 352 | - [2020] [COLD: Towards the Next Generation of Pre-Ranking System](https://arxiv.org/abs/2007.16122v1)[【汉】](https://cloud.tencent.com/developer/article/1677703) 长期以来,粗排(pre-ranking)一直被认为是精排(ranking)的简化版本,这就导致系统会陷入局部最优,文中提出COLD同时优化粗排模型和计算效率 353 | 354 | 355 | 模型引入图像特征: 356 | 357 | - [2017] [Visual Search at eBay](https://arxiv.org/pdf/1706.03154.pdf) 358 | - [2017] [Visual Search at Pinterest](https://arxiv.org/pdf/1706.03154.pdf) 359 | - [2021] [Visual Search at Alibaba](https://arxiv.org/pdf/2102.04674.pdf) 360 | 361 | 推荐的可解释性: 362 | 363 | - [2018] [Explainable Recommendation via Multi-Task Learning in Opinionated Text Data](https://arxiv.org/pdf/1806.03568.pdf)[【汉】](https://blog.csdn.net/TgqDT3gGaMdkHasLZv/article/details/84576762) 个性化推荐的可解释性,需要依赖用户对商品的评论信息进行训练。 364 | - [2018] [TEM: Tree-enhanced Embedding Model for Explainable Recommendation](http://staff.ustc.edu.cn/~hexn/papers/www18-tem.pdf)[【汉】](https://blog.csdn.net/qq_35771020/article/details/88722399) 365 | - [2018] [Neural Attentional Rating Regression with Review-level Explanations](http://www.thuir.cn/group/~YQLiu/publications/WWW2018_CC.pdf)[【汉】](https://blog.csdn.net/weixin_41306220/article/details/103232795) 366 | 367 | 多任务模型结构: 368 | 369 | - [2018] [ESMM](https://zhuanlan.zhihu.com/p/57481330)[【code】](https://github.com/busesese/ESMM) 370 | - [2018] [MMOE](https://dl.acm.org/doi/pdf/10.1145/3219819.3220007) 371 | - [2019] [MKR](https://arxiv.org/pdf/1901.08907.pdf)[【code】](https://github.com/hwwang55/MKR)[【汉】](https://blog.csdn.net/qq_40006058/article/details/89977929) 372 | - [2019] [Recommending What Video to Watch Next: A Multitask Ranking System](https://daiwk.github.io/assets/youtube-multitask.pdf)[【汉】](https://zhuanlan.zhihu.com/p/82584437) 373 | - [2019] [SNR:Sub-Network Routing for Flexible Parameter Sharing in Multi-Task Learning](https://ojs.aaai.org//index.php/AAAI/article/view/3788) 374 | - [2019] [A Pareto-Efficient Algorithm for Multiple Objective Optimization in E-Commerce Recommendation](http://ofey.me/papers/Pareto.pdf) 375 | - [2019] [Recommending What Video to Watch Next: A Multitask Ranking System](https://dl.acm.org/doi/10.1145/3298689.3346997) 多目标优化是推荐系统中一个重要的研究方向,文章为解决多目标提出Multi-gate Mixture-of-Experts,以及为解决选择偏差的问题,提出对应的解决方案 376 | - [2020] [Progressive Layered Extraction (PLE): A Novel Multi-Task Learning (MTL) Model for Personalized Recommendations](https://dl.acm.org/doi/10.1145/3383313.3412236)[【汉】](https://zhuanlan.zhihu.com/p/272708728) 腾讯的PLE,就是有私有expert和公共expert 377 | 378 | 多任务模型的loss设计: 379 | 380 | - [多个label的loss如何平衡](https://blog.csdn.net/qq_34527082/article/details/100048864) [【知乎上的讨论】](https://www.zhihu.com/question/359962155) 381 | - [2017] [GradNorm: Gradient Normalization for Adaptive Loss Balancing in Deep Multitask Networks](https://arxiv.org/abs/1711.02257) 对更新快的任务,使用小一点的学习率,对更新慢的任务,使用大一点的学习率。 382 | - [2018] [Multi-Task Learning Using Uncertainty to Weigh Losses for Scene Geometry and Semantics](https://arxiv.org/abs/1705.07115) [【code】](https://github.com/ranandalon/mtl) 基于不确定性,最终效果比我人工调参的结果好一丢丢 383 | - [2019] [Multi-Task Learning as Multi-Objective Optimization](https://arxiv.org/pdf/1810.04650.pdf) 384 | 385 | 业界实践 386 | 387 | - [多目标排序各大公司落地](https://zhuanlan.zhihu.com/p/341345727) 388 | 389 | 390 | ### 4.2.6. 偏置处理 391 | 偏置的类型: 392 | 393 | - 点击位置偏置 394 | - 视频时长偏置 395 | 396 | 处理偏置的方法: 397 | 398 | - 模型训练学习bias,serv的时候去掉bias 399 | - 如: [Youtube推荐算法中的多任务模型和消偏](https://zhuanlan.zhihu.com/p/261170030) 400 | 401 | 402 | ## 4.3. 策略优化 403 | 404 | ### 4.3.1. 打造生态:消费者、生产者、平台三方利益兼顾 405 | 406 | ### 4.3.2. 流量扶持:新内容、新生产者、新品类 407 | 408 | ### 4.3.3. 探索与利用 409 | 缓解回音壁、保持多样性、提供惊喜和新鲜感 410 | 411 | ### 4.3.4. 如何缓解头部效应 412 | 413 | ### 4.3.5. 重排模型 414 | 415 | - [2019] [Personalized Re-ranking for Recommendation](https://arxiv.org/pdf/1904.06813.pdf)[【汉】](https://zhuanlan.zhihu.com/p/79182904) rerank的10个item是一个序列,用transformer来重排 416 | - [微信「看一看」 推荐排序技术揭秘](http://blog.itpub.net/31559354/viewspace-2704029/) 重排用到了DQN 417 | 418 | 419 | 420 | # 5. 推荐系统的未来 421 | 422 | ## 5.1. 对长期收益建模 423 | 强化学习在推荐的应用: 424 | 425 | - [2018] [Top-K Off-Policy Correction for a REINFORCE Recommender System](https://arxiv.org/abs/1812.02353)[【汉】](https://zhuanlan.zhihu.com/p/71601897) 据说获得了Youtube近两年单次上线的最高收益,看起来是召回阶段,召回的优化效果都这么牛逼! 426 | - [Intro to Policy Optimization](https://spinningup.openai.com/en/latest/spinningup/rl_intro3.html) 427 | - [2015] [Trust Region Policy Optimization](https://arxiv.org/abs/1502.05477) 428 | - [2019] [Reinforcement Learning for Slate-based Recommender Systems: A Tractable Decomposition and Practical Methodology](https://arxiv.org/abs/1905.12767)[【汉】](https://zhuanlan.zhihu.com/p/83387560) 这个是用来排序的ctr*Q值 429 | - [sarsa 算法](https://mofanpy.com/tutorials/machine-learning/reinforcement-learning/intro-sarsa/) 430 | - [Values of User Exploration in Recommender Systems](https://dl.acm.org/doi/pdf/10.1145/3460231.3474236) 评估探索对长期收益的影响。对比了两种探索的做法:Entropy Regularization 和 Intrinsic Motivation(其实就是对没见过的item加一个提权)。多样性和新颖性并不一定带来用户体验上升,并且过犹不及。惊喜度才是长期收益的关键。 431 | 432 | 强化学习的资料: 433 | 434 | - [openai的强化学习课程](https://spinningup.openai.com/en/latest/) 435 | - [Facebook-朱哲清Bill 关于RL的研究进展的描述](https://www.zhihu.com/question/404471029/answer/2485186947) 436 | 437 | ## 5.2. 对item组合建模 438 | 439 | ## 5.3. 极致的时效性 440 | 实时特征、实时模型、端上重排 441 | 442 | - 实时特征。这个最容易,时效性可以比模型高。 443 | - 实时模型 444 | - [半实时](https://zhuanlan.zhihu.com/p/75597761) 445 | - GBDT+LR 446 | - Wide&Deep 447 | - 全实时。现在都有ps了,模型本身是可以实时训练的。这里有几个问题 448 | - 模型的batch大小。为了凑齐batch最长等多久。 449 | - 更新serving模型的实践间隔。一个是工程问题,大模型参数同步也要实践。另外一个是更新太快不一定有效果。对广告这种特别依赖id,且素材id更新非常频繁的,可能会比较有用。 450 | - 端上重排 451 | - 阿里 [EdgeRec:边缘计算在推荐系统中的应用](https://mp.weixin.qq.com/s/O806chMT_BFzkA-Tuv94Hw) 452 | - 快手 [渠江涛:重排序在快手短视频推荐系统中的演进](https://mp.weixin.qq.com/s/OTyEbPCBh1NHogPM7bBtvA) 453 | 454 | 455 | 实时优化器。本质上就是要加好正则,避免被少数样本带偏了 456 | 457 | - FTRL(Follow The Regularized Leader) 458 | - [Online Learning算法理论与实践](https://tech.meituan.com/online_learning.html) 主要介绍Online Learning的基本原理和两种常用的Online Learning算法:FTRL(Follow The Regularized Leader)和BPR(Bayesian Probit Regression)。基本原理理解,具体公式推导有点晕。 459 | - [RDA, FTRL 在线学习算法最初的优化公式是依据什么得到的?](https://www.zhihu.com/question/266462198/answer/309780073) 460 | - [在线学习(Online Learning)导读](https://zhuanlan.zhihu.com/p/36410780) 461 | - [Online Learning and Online Convex Optimization](http://www.cs.huji.ac.il/~shais/papers/OLsurvey.pdf) 其中的2.3节讲到FTRL 462 | - MIRA(Margin-infused relaxed algorithm) 463 | - [浅谈在线机器学习算法](http://yjliu.net/blog/2012/07/14/a-brief-talk-about-online-learning.html) 提到了Perceptron算法用于二分类问题,MIRA算法用于多类问题。 464 | - Online gradient descent: Logarithmic Regret Algorithms for Online Convex Optimization 465 | - Dual averaging: Dual Averaging Methods for Regularized Stochastic Learning and Online Optimization 466 | - Adagrad: Adaptive Subgradient Methods for Online Learning and Stochastic Optimization 467 | - PA(Online Passive-Aggressive Algorithms) 468 | - [Online Passive-Aggressive Algorithms](https://link.zhihu.com/?target=http%3A//www.jmlr.org/papers/volume7/crammer06a/crammer06a.pdf) Shai Shalev-Shwartz于[2006]发表,提出了一种基于边界的在线学习算法簇,可以支持多种预测任务。具体来说可以用于二分类、回归、多分类、序列预测等任务,使用hingeloss损失函数。 469 | - [Online Learning:Theory, Algorithms, and Applications](http://ttic.uchicago.edu/~shai/papers/ShalevThesis07.pdf) Shai Shalev-Shwartz的博士论文,[2007]发表,旨在建立一个支持多种预测任务的在线学习簇。 470 | - 综述性文章 471 | - [Online Learning and Stochastic Approximations](http://leon.bottou.org/publications/pdf/online-1998.pdf) L´eon Bottou,AT&T实验室,[2018]修订版,在线学习和随机优化的解释文章。 472 | - [Online Learning and Online Convex Optimization](http://www.cs.huji.ac.il/~shais/papers/OLsurvey.pdf) Shai Shalev-Shwartz于[2011]写的一篇综述性论文 473 | 474 | ## 5.4. 更丰富的交互信息 475 | 476 | ## 5.5. 与其他模块的协同 477 | 478 | 迁移学习。引入其他人口(如搜索),其他app的用户信息。 479 | 480 | ## 5.6. 自动化AutoML 481 | 482 | AutoML工具(2022-07-07更新star数): 483 | 484 | - 资料 485 | - [windmaple/awesome-AutoML](https://github.com/windmaple/awesome-AutoML) 486 | - [AutoML: Methods, Systems, Challenges (first book on AutoML)](https://www.automl.org/book/) automl的书2019年出版 487 | - HPO 超参搜索 488 | - mode-free, 网格搜索,随机搜索,guide search 固定一个参数找到最优质然后训练下一个,进化算法(遗传算法、进化算法、粒子群优化) 489 | - bayesian优化,多保真度优化(就是先用少量子集去筛选各种参数,然后逐渐增加样本量) 490 | - meta-learning,元数据,用元数据学习参数空间特点如:参数重要性、参数间的相关性,任务之间的相似性。 491 | - 从之前的模型学习。迁移学习、NN里的元学习、few-shot learning、 492 | - NAS neural architecture search,神经架构搜索。搜索空间、搜索策略、性能评估。 493 | - [AutoML的一些开源项目](https://zhuanlan.zhihu.com/p/93109455) 494 | - 超参搜索 495 | - [21.2k] [ray-project/ray](https://github.com/ray-project/ray) 其中Tune是超参学习,RLlib是强化学习学习。 496 | - [Ray Tune](https://zhuanlan.zhihu.com/p/364613087) 497 | - [6.3k] [hyperopt/hyperopt](https://github.com/hyperopt/hyperopt) 498 | - 自动特征 499 | - [6.5k] [blue-yonder/tsfresh](https://github.com/blue-yonder/tsfresh) 从时间序列自动提取特征 500 | - [6.3k] [alteryx/featuretools](https://github.com/alteryx/featuretools) 自动特征工程开源库 501 | - [2k] [scikit-learn-contrib/category_encoders](https://github.com/scikit-learn-contrib/category_encoders) 分类特征编码 502 | - automl框架 503 | - [8.6k] [keras-team/autokeras](https://github.com/keras-team/autokeras) 504 | - [8.6k] [EpistasisLab/tpot](https://github.com/EpistasisLab/tpot) 505 | - [5.9k] [h2oai/h2o-3](https://github.com/h2oai/h2o-3) 506 | 507 | 508 | # 6. 学习资源 509 | 510 | - [zhaozhiyong19890102/Recommender-System](https://github.com/zhaozhiyong19890102/Recommender-System) 511 | - [shenweichen/AlgoNotes](https://github.com/shenweichen/AlgoNotes) 512 | - [jihoo-kim/awesome-RecSys](https://github.com/jihoo-kim/awesome-RecSys) 513 | - [fun-rec](https://github.com/datawhalechina/fun-rec) 推荐系统入门教程 514 | - [从零单排推荐系统](https://www.zhihu.com/column/c_1392507941388414976) -------------------------------------------------------------------------------- /docs/biz/SearchSys.md: -------------------------------------------------------------------------------- 1 | # 搜索系统 2 | 3 | ## 学习资料 4 | 5 | - [搜索系统核心技术概述【1.5w字长文】](https://juejin.cn/post/7033227795996246052) 了解基础概念 6 | 7 | 8 | 9 | ## 核心模块 10 | 11 | ### 爬虫 12 | 抓取网页的覆盖率、时效性及重要性 13 | 14 | - [heritrix3](https://github.com/internetarchive/heritrix3) 15 | - [crawler4j](https://github.com/yasserg/crawler4j) 16 | 17 | ### 解析 18 | 过滤清洗、信息提取以及权重排序 19 | 20 | 21 | ### 索引 22 | 23 | - 正排索引 24 | - 倒排索引 25 | - [lucene](https://lucene.apache.org/) 26 | - [solr](https://solr.apache.org/) 多模态搜索平台 27 | - [elasticsearch](https://www.elastic.co/elasticsearch) 搜索和分析引擎 28 | - 向量索引 29 | - [faiss](https://github.com/facebookresearch/faiss) 30 | - [hnsw](https://github.com/nmslib/hnswlib) 31 | - [milvus](https://github.com/milvus-io/milvus) 32 | 33 | ### Query理解 34 | 35 | Query理解主要包含Query预处理、Query纠错、Query扩展、Query归一、联想词、Query分词、意图识别、term重要性分析、敏感Query识别、时效性识别等,实际应用中会构建一个可插拔的pipeline完成Query理解流程。 36 | 37 | - Query分词 38 | - [jieba](https://github.com/fxsjy/jieba) 39 | - [analysis-ik](https://github.com/infinilabs/analysis-ik) 40 | - term重要性分析 41 | - [LDA](https://scikit-learn.org/stable/modules/lda_qda.html) 42 | - [TextRank](https://github.com/davidadamojr/TextRank) 43 | - 意图识别 44 | - 敏感Query识别 45 | - 时效性识别 46 | 47 | ### 召回 48 | 基于词的传统召回和基于向量的语义召回。 49 | 50 | 51 | ### 排序 52 | 53 | #### 经典论文 54 | 55 | - [2009] [Learning to Rank for Information Retrieval](https://didawiki.cli.di.unipi.it/lib/exe/fetch.php/magistraleinformatica/ir/ir13/1_-_learning_to_rank.pdf) 56 | - [2009] [The Probabilistic Relevance Framework: BM25 and Beyond](https://www.staff.city.ac.uk/~sbrp622/papers/foundations_bm25_review.pdf) 57 | - [BM25算法, Best Matching](https://zhuanlan.zhihu.com/p/79202151) 58 | - [1999.09] [Authoritative sources in a hyperlinked environment](https://dl.acm.org/doi/10.1145/324133.324140) 基于用户query得到topk的网页,然后扩展出一个候选集,然后对候选集进行排序。 59 | - [[算法系列02] 浅谈HITS算法](https://zhuanlan.zhihu.com/p/206965478) 60 | - [1998.01] [The PageRank Citation Ranking: Bringing Order to the Web.](http://ilpubs.stanford.edu:8090/422/) 61 | - [PageRank算法详解](https://zhuanlan.zhihu.com/p/137561088) 62 | 63 | #### 排序模型 64 | 65 | - 粗排 66 | - tf-idf 67 | - bm25 68 | - embedding-similarity 69 | - 精排 70 | - pointwise、pairwise、listwise 71 | - gbdt 72 | - DNN。dssm、transform 73 | 74 | ### 评估 75 | 76 | 评估指标 77 | 78 | - 准确率和召回率 79 | - F1值 80 | - AP(Average Precision) 对不同召回率点上的准确率进行平均 81 | - NDCG 82 | - MAP(Mean Average Precision) 每个query的ap的平均 83 | - MRR(Mean Reciprocal Rank) 每个query第一个正例的位置导数的平均值 84 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # 搜推广算法学习笔记 2 | 3 | 链接:[zyxdtk.github.io/RecSys-Notes/](https://zyxdtk.github.io/RecSys-Notes/) 4 | 5 | ## 目录 6 | 7 | - 基础 8 | - [todo]工程架构 9 | - [大数据](infra/BigData.md) 10 | - [todo]数据科学 11 | - [机器学习](infra/MachineLearning.md) 12 | - 业务 13 | - [推荐系统](biz/RecSys.md) 14 | - [todo]广告系统 15 | - [todo]搜索系统 16 | - [todo]Push 17 | - [todo]大模型时代 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/infra/BigData.md: -------------------------------------------------------------------------------- 1 | # BigData-Note 2 | 模型工程和大数据相关的笔记 3 | 4 | # 计算 5 | 6 | 特征的计算框架 7 | - 批量 8 | - Hive 9 | - Spark 10 | - [sparkInternals](https://github.com/JerryLead/SparkInternals/tree/master/markdown) github上的一个讲spark原理的项目,强烈推荐 11 | - [Spark Overview](http://spark.apache.org/docs/latest/) spark官方文档,太多了,偶尔看看 12 | - [Spark的使用及源码走读](http://www.cnblogs.com/hseagle/category/569175.html) 牛人的spark笔记,mark,还没看 13 | - [Tuning Spark](https://spark.apache.org/docs/latest/tuning.html) 14 | - 实时 15 | - Storm 16 | - Flink 17 | 18 | ## Spark 19 | 20 | ## TensorFlow 21 | 22 | # 存储 23 | 24 | # 管理 -------------------------------------------------------------------------------- /docs/infra/MachineLearning.md: -------------------------------------------------------------------------------- 1 | # 1. 机器学习笔记 2 | 3 | - [1. 机器学习笔记](#1-机器学习笔记) 4 | - [2. 基础问题](#2-基础问题) 5 | - [2.1. 过拟合与欠拟合](#21-过拟合与欠拟合) 6 | - [2.2. 正则化](#22-正则化) 7 | - [2.3. AUC](#23-auc) 8 | - [2.4. 超参搜索](#24-超参搜索) 9 | - [2.5. PCA和LDA](#25-pca和lda) 10 | - [3. 树模型](#3-树模型) 11 | - [3.1. xgbost和gbdt的区别](#31-xgbost和gbdt的区别) 12 | - [3.2. xgboost和lgb的区别](#32-xgboost和lgb的区别) 13 | - [4. DNN](#4-dnn) 14 | - [4.1. 参数是否可以初始化为0](#41-参数是否可以初始化为0) 15 | - [4.2. relu](#42-relu) 16 | - [4.3. 梯度消失和梯度膨胀](#43-梯度消失和梯度膨胀) 17 | - [5. CNN \&\& CV](#5-cnn--cv) 18 | - [5.1. CNN适合处理什么问题](#51-cnn适合处理什么问题) 19 | - [5.2. CNN为什么具有平移不变性](#52-cnn为什么具有平移不变性) 20 | - [5.3. Pooling操作是什么?有几种?作用是什么?](#53-pooling操作是什么有几种作用是什么) 21 | - [5.4. BatchNormalization](#54-batchnormalization) 22 | - [5.5. 卷积](#55-卷积) 23 | - [5.6. 怎么看CNN的每个神经元都学到了什么。](#56-怎么看cnn的每个神经元都学到了什么) 24 | - [5.7. Resnet skip-connection](#57-resnet-skip-connection) 25 | - [6. RNN\&\&NLP](#6-rnnnlp) 26 | - [6.1. RNN原理?RNN适合解决什么类型问题?为什么?](#61-rnn原理rnn适合解决什么类型问题为什么) 27 | - [6.2. LSTM如何实现长短期记忆功能?](#62-lstm如何实现长短期记忆功能) 28 | - [6.3. GRU跟LSTM有什么异同](#63-gru跟lstm有什么异同) 29 | - [6.4. RNN的长期以来问题是什么?怎么解决](#64-rnn的长期以来问题是什么怎么解决) 30 | - [6.5. Seq2Seq模型](#65-seq2seq模型) 31 | - [7. 强化学习](#7-强化学习) 32 | - [7.1. 学习资源](#71-学习资源) 33 | - [7.2. 基础概念](#72-基础概念) 34 | - [8. 参考资料](#8-参考资料) 35 | 36 | # 2. 基础问题 37 | 38 | ## 2.1. 过拟合与欠拟合 39 | 过拟合:训练集效果好,测试机效果差。 40 | 41 | - 欠拟合 42 | - 增加特征 43 | - 增加模型复杂度 44 | - 减少正则项稀疏 45 | - 过拟合 46 | - 提高样本量 47 | - 简化模型 48 | - 加入正则项或提高惩罚稀疏 49 | - 是用集成学习 50 | - dropout 51 | - early stopping 52 | - [label smoothing(标签平滑)](https://blog.csdn.net/qq_40176087/article/details/121519888) 避免模型过于自信,让标签不绝对 53 | 54 | ## 2.2. 正则化 55 | - 数据增强 56 | - L2正则 57 | - L1正则 58 | - dropout,神经元被丢弃的概率为 1 − p,减少神经元之间的共适应。一种廉价的 Bagging 集成近似方法。减少训练节点提高了学习速度。 59 | - drop connect, 在 Drop Connect 的过程中需要将网络架构权重的一个随机选择子集设置为零,取代了在 Dropout 中对每个层随机选择激活函数的子集设置为零的做法。 60 | - 随机pooling 61 | - early stopping 62 | 63 | ## 2.3. AUC 64 | - ROC曲线下的面积。ROC是用FPR和TPR作为x,y绘制的曲线。 65 | - AUC取值一般在0.5到1之间 66 | - AUC更关注序,对于样本不均衡情况,也能给出合理的评价 67 | - 有几种计算方式 68 | - 计算ROC曲线下的面积。只能用近似方法去算。 69 | - 统计逆序对个数。按照pred升序排列。得到正样本的rank累计值R。 (R-M(M-1)/2)/(M*N)。这里M是正样本个数,N是负样本个数。分母是正负样本对的个数,分子是逆序对的个数。 70 | 71 | ## 2.4. 超参搜索 72 | 73 | [超参数搜索的方式](https://zhuanlan.zhihu.com/p/304373868) 74 | - 人工调参(babysitting) 75 | - 网格搜索(Grid Search),先用较大步长在较大范围搜索,确定可能的位置,然后逐渐缩小搜索范围和步长。简单有效,但是耗时久,目标函数非凸时容易miss全局最优。 76 | - 随机搜索(Random Search),在搜索范围内随机选取样本点,样本集足够大也能找到全局最优或者近似解。优点是快,但是也可能miss全局最优。 77 | - 贝叶斯优化,对目标函数的形状进行学习,找到使目标函数向全局最优值提升的参数。优点是充分利用之前的信息。缺点是容易陷入局部最优。 78 | - [SMBO](https://zhuanlan.zhihu.com/p/53826787)(Sequential model-based optimization) 79 | - 进化算法 80 | - 基础理论:[帕累托最优](https://zhuanlan.zhihu.com/p/54691447) 81 | - [CEM](https://blog.csdn.net/ppp8300885/article/details/80567682)(Cross Entropy Method) 82 | - [PSO](https://cloud.tencent.com/developer/article/1424756)(Particle Swarm Optimization, 粒子群算法) 83 | - [NES](https://mofanpy.com/tutorials/machine-learning/evolutionary-algorithm/evolution-strategy-natural-evolution-strategy/)(Natural Evolution Strategy) 84 | 85 | ## 2.5. PCA和LDA 86 | 87 | PCA无监督,基于方差降维,去除冗余维度。LDA有监督,类内方差最小。 88 | 89 | 90 | # 3. 树模型 91 | ## 3.1. xgbost和gbdt的区别 92 | - GBDT是机器学习算法,xgboost是该算法的工程实现 93 | - 传统GBDT是用CART作为基分类器,XGBOOST还支持线性分类器,比如LR或者线性回归 94 | - GBDT只用了一阶导数。xgboost用了二阶泰勒展开。支持自定义损失函数,但是要求一阶、二阶可导 95 | - GBDT每次迭代用全量数据,xgboost有行采样和列采样 96 | - xgboost的目标函数里面有正则项,相当于预剪枝 97 | - xgboost支持对缺失值处理 98 | - xgboost支持并行。并行是在特征粒度上 99 | - 支持统计直方图做近似计算 100 | 101 | ## 3.2. xgboost和lgb的区别 102 | 103 | 不同: 104 | - xgboost是level-wise,lightgbm使用leaf-wise,这个可以提升训练速度。但是其实xgboost已经支持leaf-wise 105 | - leaf-wise的问题是可能忽略未来有潜力的节点 106 | - xgboost单机默认是exact greedy,搜索所有的可能分割点。分布式是dynamic histogram,每一轮迭代重新estimate 潜在split candidate。LightGBM和最近的FastBDT都采取了提前histogram binning再在bin好的数据上面进行搜索。在限定好candidate splits。lightgbm在pre-bin之后的histogram的求和用了一个非常巧妙的减法trick,省了一半的时间。 107 | - 提前限定分割点然后快速求histogram的方法,实际影响不确定。理论上树越深,需要的潜在分割点越多,可能需要动态训练来更新潜在分割点 108 | - xgboost主要是特征并行,lightgbm是有数据并行、特征并行、投票并行。当时其实xgboost也支持数据并行了。 109 | - lightgbm支持分类特征的many vs many,用G/H排序,然后再分桶 110 | 参考: 111 | - [如何看待微软新开源的LightGBM?-陈天奇和柯国霖都有回答](https://www.zhihu.com/question/51644470) 112 | 113 | 114 | # 4. DNN 115 | ## 4.1. 参数是否可以初始化为0 116 | 不可以。对于全连接多层神经网络,初始化为0,反向传播过程如下: 117 | - 1)第1次反向传播,仅最后一层权重值更新,前面的权重值不更新(仍为0) 118 | - 2)第2次反向传播,最后一层和倒数第二层权重值更新,前面的权重值不更新(仍为0) 119 | - 3)以此类推,若干次反向传播之后,达到如下状态: 120 | - a)输入层和隐层之间,链接在同一个输入节点的权重值相同,链接在不同输入节点的权重值不同; 121 | - b)两个隐层之间,所有权重值相同 122 | - 输出层和隐层之间,链接在同一个输出节点的权重值相同,链接在不同输出节点的权重值不同 123 | 以上分析针对sigmoid激活函数,tanh函数下权重值无论怎么训练都保持为0.relu估计也是都为0 124 | 125 | 参考:[关于神经网络参数初始化为全0的思考](https://zhuanlan.zhihu.com/p/32063750) 126 | 127 | ## 4.2. relu 128 | - y=max(0,x) 129 | - relu在0处是不可导的,TensorFlow实现默认0点的导数为0 130 | - relu是非饱和激活函数。sigmoid和tanh是饱和激活函数。 131 | - relu的优势: 132 | - 非饱和激活函数可以解决梯度消失问题,提供相对宽的激活边界 133 | - 能加快收敛速度 134 | - 单次抑制提供了稀疏表达能力,防止过拟合 135 | - 缺点 136 | - 训练很脆弱,很容易权重就为0了,也就是神经元死亡 137 | - relu变种 138 | - Leaky Relu 给所有负值一个非零斜率 139 | - [PRelu](https://blog.csdn.net/shuzfan/article/details/51345832) 是Leaky Relu的一个变体,负值部分的斜率是根据数据来定的。斜率a是用带动量的更新方式。论文中初始值0.25,动量= 动量系数*动量+学习率*偏导 140 | - RRelu 也是Leaky Relu的一个变体,负值斜率在训练中是随机的,在测试中变成固定值。权重a是一个均匀分布U(l,u) l,u∈[0,1) 141 | 142 | 参考:[激活函数ReLU、Leaky ReLU、PReLU和RReLU](https://blog.csdn.net/qq_23304241/article/details/80300149) 143 | 144 | ## 4.3. 梯度消失和梯度膨胀 145 | 原因:反向传播是根据链式法则,连乘每一层的偏导。每一层的偏导是激活函数的导数乘以当前节点的权重。如果每一层的偏导都同时偏向一个方向,都大于1会导致最终梯度爆炸,都小于1会导致梯度消失(变为0) 146 | 147 | 解决办法:relu可以缓解。但是用了relu的网络也还是存在梯度消失的问题,Leaky ReLU就此应运而生。 148 | 参考: 149 | - [梯度消失与梯度爆炸的原因](https://zhuanlan.zhihu.com/p/25631496) 150 | - [在使用relu的网络中,是否还存在梯度消失的问题?](https://www.zhihu.com/question/49230360) 151 | 152 | # 5. [CNN](https://zhuanlan.zhihu.com/p/29605049) && CV 153 | ## 5.1. CNN适合处理什么问题 154 | CNN通过卷积层+pooling层不断堆积,从小的pattern开始不断识别到大的pattern,从而识别整张图像。 155 | CNN利用了图像的三个性质: 156 | - 图像的pattern通常比整张图像小 157 | - 通用的patterns会出现在图像的不同区域 158 | - 对图像进行子采样并不影响图像的识别 159 | 160 | ## 5.2. CNN为什么具有平移不变性 161 | 参数共享的物理意义是使得卷积层具有平移等变性。在卷积神经网路中,卷积核中的每一个元素将作用于每一次局部输入的特定位置上。 162 | 163 | 假如图像中有一只猫,无论它出现在图像中的任何位置,我们都应该将它识别为猫,也就是说神经网络的输出对于平移变换来说应当是等变的。 164 | 165 | ## 5.3. Pooling操作是什么?有几种?作用是什么? 166 | - 将Pooling核覆盖区域中所有制的平均值(最大值)作为输出。 167 | - 有average-pooling、max-pooling、stochastic-pooling(对输入数据中的元素按照一定概率大小随机选择,元素值大的activattion被选中的概率大)。Pooling操作后的结果相比起输入减小了,是一种降采样操作。 168 | - 作用:特征不变形。数据降维。 169 | 170 | 为什么CNN需要Pooling?因为图片的信号过于丰富,需要降维来减少计算量。图像信息存在冗余,子采样不影响图像识别。 171 | 172 | ## 5.4. BatchNormalization 173 | 对每个Batch的mean、var做指数加权平均用于作为整个样本空间的mean、var的近似估计。做了normalization之后所有值的丰富都在0,1,同层的神经元的差异性就没了,所以需要在修正回来,修正的参数是可学习的。 174 | 175 | ## 5.5. 卷积 176 | 卷积的特性 177 | - 稀疏交互。每个神经元的只跟上一层的某些神经元连接(vs DNN全连接),用到较少参数 178 | - 参数共享。同一层的不同神经元之间共享部分权重,用到比原来更少的参数 179 | 180 | ## 5.6. 怎么看CNN的每个神经元都学到了什么。 181 | - [特征可视化](https://zhuanlan.zhihu.com/p/443264651)指的就是将那些可以引起CNN Kernel最大反应的图像制作出来. 182 | 183 | ## 5.7. Resnet skip-connection 184 | 添加一个捷径,来自深层的梯度能直接畅通无阻地通过,去到上一层,使得浅层的网络层参数等到有效的训练! 185 | 186 | # 6. RNN&&NLP 187 | ## 6.1. RNN原理?RNN适合解决什么类型问题?为什么? 188 | RNN能够很好地处理变长并且有序的输入序列(例如,文本数据)。它模拟了人阅读一篇文章的顺序,从前到后阅读文章中的每一个单词,将前面阅读到的有用信息编码到状态变量中去,从而拥有一定的记忆能力,可以更好地理解之后的文本。下一时刻的状态于当前输入以及当前状态有关。 189 | 190 | ## 6.2. LSTM如何实现长短期记忆功能? 191 | LSTM可以对有价值的信息进行长期记忆。与RNN不同的是,LSTM记忆单元c的转移不一定完全取决于激活函数计算得到的状态,还由输入门和遗忘门共同控制。在一个训练好的LSTM模型中,当输入序列中没有重要信息时,遗忘门的值接近于1,输入门的值接近于0,表示过去的记忆被完整保存,而输入信息被放弃,从而实现长期记忆功能。当输入序列中存在重要信息时,LSTM应把他存入记忆中,此时输入门接近于1;当输入序列中存在重要信息且该信息意味着之前的记忆不再重要时,输入门的值接近1,遗忘门的值接近0。 192 | 193 | 参考:[理解 LSTM 网络](https://www.jianshu.com/p/9dc9f41f0b29) 194 | 195 | LSTM参数数量?若输入的长度=m,隐藏层的长度=n,则一个LSTM层的参数个数是(n*(n+m)+n)*4。输入、记忆门、遗忘门、输出。(把状态遍历和输出给到下一层) 196 | 参考:[关于LSTM的神经元数及参数个数](https://blog.csdn.net/code_wxy/article/details/100887492) 197 | 198 | ## 6.3. GRU跟LSTM有什么异同 199 | 相同点: 200 | - 都有门 201 | - 遗忘门或者更新门选择不更新memeory,网络会一直记住之前的重要特征。 202 | - 不同 203 | - GRU比LSTM比少了一个门。将遗忘门和输入门合成了一个单一的更新门 204 | - GRU不区分长期记忆和短期记忆了 205 | - LSTM有一个输出门控制memory的曝光程度,GRU是直接输出 206 | - GRU通过重置门来控制从H(t-1)中得到的信息粒度,LSTM是直接输入。 207 | - 相同参数量,GRU比LSTM表现稍好 208 | 参考:[门控循环单元(GRU)](https://zh.d2l.ai/chapter_recurrent-modern/gru.html#) 209 | 210 | ## 6.4. RNN的长期以来问题是什么?怎么解决 211 | 长期依赖问题是:随着输入序列的增长,模型的性能发生显著下降,RNN难以捕捉长距离输入之间的依赖。从结构上来看,理论上RNN可以学习捕捉到长距离依赖,但是实践中使用BPTT算法学习的RNN并不能成功捕捉长距离的医疗关系,主要源于深度神经网络中的梯度消失。 212 | 213 | 解决方法: 214 | 梯度爆炸:权重矩阵连乘,特征值幅度大于1,于是指数级增长,加tanh可以缓解 215 | - 梯度截断 216 | 梯度消失:权重矩阵连乘,特征幅度小于0,于是衰减到0 217 | - LSTM、GRU等模型加入门控机制,捕捉长期记忆,很大程度上弥补了梯度消失 218 | - 残差结构 219 | - 设计多个时间尺度的模型:在细粒度的时间尺度上处理近期信息、在粗粒度时间尺度上处理远期的信息。得到粗粒度时间尺度方法1跳跃链接:增加从远期的隐变量到当前隐变量的直接连接;2. 是删除连接:主动删除时间跨度为 1 的连接,并用更长的连接替换。 220 | 221 | ## 6.5. Seq2Seq模型 222 | seq2seq模型是将一个序列信号,通过编码和解码生成一个新的序列信号,输入和输出序列的长度实现并不知道。seq2seq的模型的核心思想由编码输入和解码输出两个环节构成。在经典的实现中,编码器和解码器各由一个循环神经网络构成,两个循环神经网络是共同训练的。 223 | 224 | # 7. 强化学习 225 | 226 | ## 7.1. 学习资源 227 | - [Spinning Up in Deep RL](https://spinningup.openai.com/en/latest/) 228 | - [Key Papers in Deep RL](https://spinningup.openai.com/en/latest/spinningup/keypapers.html) 229 | - [huggingface: deep-rl-course](https://huggingface.co/learn/deep-rl-course/unit0/introduction) 230 | 231 | 232 | ## 7.2. 基础概念 233 | 234 | 235 | - [2018.02] [Addressing Function Approximation Error in Actor-Critic Methods](https://arxiv.org/abs/1802.09477) TD3,解决DDPG的Q函数高估导致的policy更新奔溃的问题。用到了double Q-learning截断、延迟policy更新、target policy smoothing。off-policy。 236 | - [2018.01] [Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor](https://arxiv.org/abs/1801.01290) SAC 237 | - [2017.07] [Emergence of Locomotion Behaviours in Rich Environments](https://arxiv.org/abs/1707.02286) 238 | - [2017.07] [Proximal Policy Optimization Algorithms](https://arxiv.org/abs/1707.06347) PPO主要是引入了clip 239 | - [2015.09] [Continuous control with deep reinforcement learning](https://arxiv.org/abs/1509.02971) DDPG同时优化q函数和策略函数,off-policy,连续动作空间。 240 | - [贝尔曼方程(Bellman equation)](https://blog.csdn.net/qq_39160779/article/details/107289652) 241 | - off-policy挑战:分布偏移、探索不足、过时策略数据 242 | - [2015.06] [High-Dimensional Continuous Control Using Generalized Advantage Estimation](https://arxiv.org/abs/1506.02438) GAE平衡优势函数估计中的偏差和方差的方法 243 | - [2015.02] [Trust Region Policy Optimization](https://arxiv.org/abs/1502.05477) TRPO添加了KL散度约束 244 | - [2014.07] [Deterministic Policy Gradient Algorithms](https://proceedings.mlr.press/v32/silver14.pdf) DPG 245 | 246 | 247 | 248 | # 8. 参考资料 249 | 250 | - [算法工程师-机器学习面试题总结](https://github.com/zhengjingwei/machine-learning-interview) 总结得很全 251 | - [人工智能学习资料书籍](https://github.com/leerumor/ai-study) -------------------------------------------------------------------------------- /docs/static/dnn_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyxdtk/RecSys-Notes/ee4aff9f4985784b9fbc205b0a2d831a9b607bef/docs/static/dnn_model.png -------------------------------------------------------------------------------- /docs/static/recsys_jihoo_kim.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyxdtk/RecSys-Notes/ee4aff9f4985784b9fbc205b0a2d831a9b607bef/docs/static/recsys_jihoo_kim.jpg -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: 推荐系统笔记 2 | theme: readthedocs 3 | markdown_extensions: 4 | - toc: 5 | permalink: "#" 6 | baselevel: 2 7 | separator: "_" --------------------------------------------------------------------------------