推薦系統
從訂餐、隨選影片、音訊串流到時尚內容, 推薦系統可為目前許多最熱門的應用程式提供助力。探索如何運用 TensorFlow 生態系統中的開放原始碼程式庫和工具, 建構可用於生產環境的推薦系統。
Recommendation systems increase user engagement within your app and elevate user experience by providing the most desirable content. Modern recommenders are complex systems that are often broken down into multiple stages to achieve low latency in production. Through the retrieval, ranking, and potentially post-ranking stages, irrelevant items are gradually filtered out from a large pool of candidates and a list of options that users are the most likely to interact with are finally presented.
Start building with TensorFlow Recommenders, an easy-to-use framework that facilitates the full workflow of building a recommender system from data preparation to deployment.
模型訓練完成後,即可部署到生產環境,為使用者提供推薦內容。TensorFlow Serving 會將你的模型推送至生產環境執行成效推論作業,藉此最大限度提高機器學習模型的處理量,並能為需要分散式內容的大型推薦模型提供支援。
# Deploy the retrieval model with TensorFlow Serving docker run -t --rm -p 8501:8501 \ -v "RETRIEVAL/MODEL/PATH:/models/retrieval" \ -e MODEL_NAME=retrieval tensorflow/serving & # Retrieve top movies that user 42 may like curl -X POST -H "Content-Type: application/json" \ -d '{"instances":["42"]}' \ http://localhost:8501/v1/models/retrieval:predict # Output # { # "predictions":[ # { # "output_1": [2.032, 1.969, 1.813], # "output_2": ["movie1”, “movie2”, “movie3”] # } # ] # } # Deploy the ranking model with TensorFlow Serving docker run -t --rm -p 8501:8501 \ -v "RANKING/MODEL/PATH:/models/ranking" \ -e MODEL_NAME=ranking tensorflow/serving & # Get the prediction score for user 42 and movie 3 curl -X POST -H "Content-Type: application/json" \ -d '{"instances":[{"user_id":"42", "movie_title":"movie3"}]}' \ http://localhost:8501/v1/models/ranking:predict # Output: # {"predictions": [[3.66357923]]}
改善推薦引擎的擷取和排名階段
如要大規模採用推薦系統,就必須在擷取和排名階段運用有效且快速的方式,從數百萬個候選項目中挑出最相關的項目。使用 ScaNN 程式庫中最先進的最鄰近搜尋 (ANN) 演算法,以及 TensorFlow Ranking 程式庫中的機器學習演算排序 (LTR) 技巧,來輔助 TensorFlow 建議工具的運作,藉此獲得更貼近需求的推薦內容。
ScaNN is a library for vector similarity search at scale. It leverages state-of-the-art ANN techniques, such as asymmetric hashing and anisotropic quantization, to accelerate retrieval of top candidates.
TensorFlow Ranking 程式庫可用來開發可擴充的類神經 LTR 模型。這個程式庫提供為候選項目排名的額外功能,可充分發揮排名公用程式的功效。
針對模型訓練和推論將大型的嵌入最佳化
嵌入查詢運算是大規模推薦系統的重要元件。運用硬體加速和動態嵌入技術,克服大型嵌入表格中常見的效能瓶頸。
TPUEmbedding Layer API 有助在 Tensor Processing Unit (TPU) 中訓練及放送大型嵌入表格。
保障使用者隱私
Traditional recommendation engines rely on collecting user interaction logs and training recommendation models based on raw user activities. Ensure that user data remains private by incorporating Responsible AI development practices.
TensorFlow Federated 架構可根據分散資料進行聯合學習及其他運算。聯合重建技術能在聯合學習設定中加入矩陣分解功能,在提供推薦時更妥善地保障使用者隱私。
使用進階技巧,開發更複雜的建議工具
雖然業界目前廣泛採用傳統協同過濾模型,但運用強化學習和圖表類神經網路 (GNN) 等進階技巧來建構推薦系統,這個趨勢日益明顯。
Learn how to use large language models (LLMs) like the PaLM API to augment your recommendation systems.
參照最先進的推薦模型
如要為知名模型進行成效基準評估,或建構自己的推薦模型,請參閱熱門 TensorFlow 模型 (例如 NCF、DLRM 和 DCN 第 2 版) 的官方導入最佳做法。
教育資源
按照課程和影片中的逐步說明,進一步瞭解如何建構推薦系統。
真實世界的推薦系統
探索支援每個產業應用程式的推薦系統例子和個案研究。
Learn how Spotify leveraged the TensorFlow ecosystem to design an extendable offline simulator and train RL Agents to generate playlist recommendations.