推薦系統中的冷啟動問題

什麼是冷啟動? 推薦系統主要是把物品推薦給喜歡的使用者,在使用的環境中,物品和使用者皆會持續的增長變化,也因此會持續面對有新物品和新使用者的情境;有新的物品和使用者使得無法做好的推薦就稱為冷啟動,我們要討論在這種情況下如何做合適的推薦。 基本的冷啟動可以分成三類: 使用者冷啟動:新用戶產生時沒有有任何瀏覽購買紀錄,如何推薦用品的問題。 物品冷啟動:新物品如何推薦給合適的用戶。 系統冷啟動:新系統上線時,物品、使用者、資料皆不足的推薦問題。 圖片來源:https://www.researchgate.net/figure/Illustration-of-Cold-Start-problem-in-recommender-systems-New-user-problem-left-and_fig2_332511384 接下來我們介紹幾個常見的解決方式 排行榜推薦 新物品的推薦 秉持著大家會喜新厭舊的心態,推薦新的物品給使用者;像是電影、影集等等就很適合,有新影片上線時,不管是新或舊的使用者都會想看。 熱門物品的推薦 推薦大家都喜歡的物品給使用者,這是非常常見的做法,簡單有效;也可以用作新演算法的AB test或benchmark,等到資料足夠後才做個性化推薦。 常用物品、必需品推薦 推薦生活必需品、常用物品給新使用者;這種情況適合一些居家用品、常用家電、廚房用具等等的情境。 標籤推薦 這種方式是針對前三項作更細微的推薦,像是ott 串流平台可以直接選擇喜劇、動作片、愛情片等等的推薦;但要注意標籤要先設計完整。 圖片來源:https://deepai.org/publication/addressing-the-cold-start-problem-in-outfit-recommendation-using-visual-preference-modelling 簡易的使用者推薦 簡易的使用者推薦 根據使用者簡易的年齡、性別等等資料分出人群進行推薦。 授權平台推薦 導入第三方社交平台facebook、google等等,根據這些平台的歷史數據進行推薦。 問答題推薦 目前有許多平台都是這種方式,註冊登入時會問幾個問題,了解你的喜好,根據你的反饋來推薦物品。 新物品的相似度推薦 新物品推薦系統在不同的平台有不同的重要程度,在新聞媒體等等時效性強的平台就特別重要,必須要快速的推薦出去,不然時間過了這個資訊、消息也就不重要了。 新物品跟用戶的相似度 計算新物品的特徵(標籤、cos相似度、TF-IDF、影像相似度等等)和使用者的行為特徵進行推薦。 新物品和舊物品的相似度 新物品進入平台後,根據平台的標籤、屬性資訊等等,計算出相似的物品,再推薦給喜歡此物品的使用者。 試探策略 這幾年短影片的流行,無論是純做短影片的網站,抑或是一般影音平台的短影片,皆是爆發性的成長;快速試探策略就很適合,快速、隨機推薦影片給使用者,再根據使用者觀看、點擊、滑動瀏覽網站、停留時間等等的行為,快速獲得使用者的資訊,再進行推薦。 結尾 上面是簡單介紹幾個常用的方式,還有許多做法可以解決遇到的冷啟動問題,主要必須先定義好問題,知道自己產品、平台的特徵、類型、使用者如何才會滿意等等的資訊,才能真正的對症下藥。 最後推薦幾篇論文,大家有興趣可以看看他們遇到的問題是什麼又是如何解決的。 Behavior-based popularity ranking on Amazon Video Billion-scale Commodity Embedding for E-commerce Recommendation in Alibaba Performance of recommender algorithms on top-N recommendation tasks ...

2021-11-29 · 1 min · 69 words · KbWen

Deep Reinforcement learning

Reinforcement learning (RL) is a framework where agents learn to perform actions in an environment so as to maximize a reward. It’s actually training an AI to learn through every mistake and find the correct path without any label. The two main components are the environment and the agent. Deep Reinforcement learning (DRL) combined with deep learning technology is even more powerful. AlphaGo, is a typical application of deep reinforcement learning. ...

2020-10-26 · 3 min · 472 words · KbWen

Tensorflow2 -- MNIST

Tensorflow2.X和1.X有多了很多差別和使用方式, 今天用tf2來實作MNIST分類問題 MNIST MNIST是一個很標準的手寫數字分類問題, 數據集下載有很多方式,這次直接使用tf API提供的 28 * 28 且只有黑白的數據 開發 在local 起 jupyter lab 先看看GPU是否啟用 %matplotlib widget import matplotlib.pyplot as plt import tensorflow as tf import numpy as np # check gpu tf.config.list_physical_devices('GPU') tf.test.is_built_with_cuda() # output True 方法一 繼承 tf.keras.model class MLP(tf.keras.Model): def __init__(self): super().__init__() self.flatten = tf.keras.layers.Flatten() self.dense1 = tf.keras.layers.Dense(units=100, activation=tf.nn.relu) self.dense2 = tf.keras.layers.Dense(units=20, activation=tf.nn.leaky_relu) self.dense3 = tf.keras.layers.Dense(units=10) @tf.function def call(self, inputs): # [batch_size, 28, 28, 1] flat1 = self.flatten(inputs) # [batch_size, 784] dens1 = self.dense1(flat1) # [batch_size, 100] dens2 = self.dense2(dens1) # [batch_size, 20] dens3 = self.dense3(dens2) # [batch_size, 10] output = tf.nn.softmax(dens3) return output 使用tf.GradientTape訓練 # @tf.function def one_batch_step(X, y, **kwargs): with tf.GradientTape() as tape: y_pred = model(X) loss = tf.keras.losses.sparse_categorical_crossentropy(y_true=y, y_pred=y_pred) loss = tf.reduce_mean(loss) tf.print(f"{batch_index} loss {loss}", [loss]) with summary_writer.as_default(): tf.summary.scalar("loss", loss, step=batch_index) grads = tape.gradient(loss, model.variables) optimizer.apply_gradients(grads_and_vars=zip(grads, model.variables)) for epoch_index in range(num_epochs): for batch_index in range(num_batches): X, y = data_loader.get_batch(batch_size) one_batch_step(X, y, batch_index=batch_index) with summary_writer.as_default(): tf.summary.trace_export(name="model_trace", step=0, profiler_outdir=log_dir) tf.saved_model.save(model, f"saved/{model_name}") 方法二 使用keras Pipeline來疊每一層要用的函數,彈性較低,但非常適合簡單的Model ...

2020-09-26 · 1 min · 194 words · KbWen

Google NLP API parsing

使用google 提供的API做語意分析。 語意分析(syntactic analysis)能夠提取語言的訊息,把文章拆成句子,句子在拆成更小的每個分詞,做更進一步的分析,Goole NLP API 會給予每個字詞的詞性以及彼此的關係。 Analyzing syntax 進入GCP新增一個API Key 並確認NLP API狀態為enable;詳細的GCP申請操作步驟可以看官方文件。(或是以後有機會寫。) API Enabled 因為這次是介紹,所以使用google cloud shell;在平常使用下可以把某些步驟改成習慣的語言及IDE。 新增環境變數 export API_KEY=<YOUR_KEY> 確認輸入後,增加要丟進API的文字json檔 text.json { "document":{ "type":"PLAIN_TEXT", "content": "Beirut rescuers search the site for possible survivor 30 days after the explosion." }, "encodingType": "UTF8" } 標準的json檔輸入資訊:https://cloud.google.com/natural-language/docs 使用curl post資料 curl "https://language.googleapis.com/v1/documents:analyzeSyntax?key=${API_KEY}" \ -s -X POST -H "Content-Type: application/json" --data-binary @text.json 會得到解析出來的資訊 { "sentences": [ { "text": { "content": "Beirut rescuers search the site for possible survivor 30 days after the explosion.", "beginOffset": 0 } } ], "tokens": [ { "text": { "content": "Beirut", "beginOffset": 0 }, "partOfSpeech": { "tag": "NOUN", "aspect": "ASPECT_UNKNOWN", "case": "CASE_UNKNOWN", "form": "FORM_UNKNOWN", "gender": "GENDER_UNKNOWN", "mood": "MOOD_UNKNOWN", "number": "SINGULAR", "person": "PERSON_UNKNOWN", "proper": "PROPER", "reciprocity": "RECIPROCITY_UNKNOWN", "tense": "TENSE_UNKNOWN", "voice": "VOICE_UNKNOWN" }, "dependencyEdge": { "headTokenIndex": 1, "label": "NN" }, "lemma": "Beirut" }, { "text": { "content": "rescuers", "beginOffset": 7 }, "partOfSpeech": { "tag": "NOUN", "aspect": "ASPECT_UNKNOWN", "case": "CASE_UNKNOWN", "form": "FORM_UNKNOWN", "gender": "GENDER_UNKNOWN", "mood": "MOOD_UNKNOWN", "number": "PLURAL", "person": "PERSON_UNKNOWN", "proper": "PROPER_UNKNOWN", "reciprocity": "RECIPROCITY_UNKNOWN", "tense": "TENSE_UNKNOWN", "voice": "VOICE_UNKNOWN" }, "dependencyEdge": { "headTokenIndex": 2, "label": "NSUBJ" }, "lemma": "rescuer" }, { "text": { "content": "search", "beginOffset": 16 }, "partOfSpeech": { "tag": "VERB", "aspect": "ASPECT_UNKNOWN", "case": "CASE_UNKNOWN", "form": "FORM_UNKNOWN", "gender": "GENDER_UNKNOWN", "mood": "INDICATIVE", "number": "NUMBER_UNKNOWN", "person": "PERSON_UNKNOWN", "proper": "PROPER_UNKNOWN", "reciprocity": "RECIPROCITY_UNKNOWN", "tense": "PRESENT", "voice": "VOICE_UNKNOWN" } } ...... ], "language": "en" } 觀察一下上面的結果 ...

2020-09-04 · 2 min · 233 words · KbWen