نمای کلی نسل نامزد
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ایجاد نامزد اولین مرحله توصیه است. با توجه به یک پرس و جو، سیستم مجموعه ای از نامزدهای مرتبط را تولید می کند. جدول زیر دو رویکرد رایج تولید نامزد را نشان می دهد:
تایپ کنید | تعریف | مثال |
---|
فیلترینگ مبتنی بر محتوا | از شباهت بین آیتم ها برای توصیه مواردی مشابه آنچه کاربر دوست دارد استفاده می کند. | اگر کاربر A دو ویدیو از گربه های بامزه تماشا کند، سیستم می تواند ویدیوهای حیوانات بامزه را به آن کاربر توصیه کند. |
فیلتر مشارکتی | از شباهت های بین پرس و جو و موارد به طور همزمان برای ارائه توصیه ها استفاده می کند. | اگر کاربر A مشابه کاربر B باشد و کاربر B ویدیو 1 را دوست داشته باشد، سیستم می تواند ویدیوی 1 را به کاربر A توصیه کند (حتی اگر کاربر A هیچ ویدیویی مشابه ویدیو 1 ندیده باشد). |
فضای تعبیه شده
هر دو فیلتر مبتنی بر محتوا و مشارکتی، هر مورد و هر پرس و جو (یا زمینه) را به یک بردار جاسازی در یک فضای جاسازی مشترک\(E = \mathbb R^d\)ترسیم می کنند. به طور معمول، فضای جاسازی ابعاد پایینی دارد (یعنی \(d\) بسیار کوچکتر از اندازه بدنه است)، و برخی از ساختارهای پنهان مورد یا مجموعه پرس و جو را به تصویر می کشد. موارد مشابه، مانند ویدیوهای یوتیوب که معمولاً توسط یک کاربر تماشا می شود، در نهایت در فضای تعبیه شده به هم نزدیک می شوند. مفهوم "نزدیک" با معیار تشابه تعریف می شود.
اقدامات مشابه
معیار تشابه یک تابع \(s : E \times E \to \mathbb R\) است که یک جفت جاسازی را می گیرد و یک اسکالر برای اندازه گیری شباهت آنها برمی گرداند. جاسازیها را میتوان برای تولید نامزد به صورت زیر استفاده کرد: با توجه به یک پرسوجو که \(q \in E\)را تعبیه میکند، سیستم به دنبال جاسازیهای آیتمی\(x \in E\) نزدیک به \(q\)میگردد، یعنی جاسازیهایی با شباهت زیاد \(s(q, x)\).
برای تعیین درجه شباهت، اکثر سیستم های توصیه بر یک یا چند مورد زیر تکیه می کنند:
- کسینوس
- محصول نقطه ای
- فاصله اقلیدسی
کسینوس
این به سادگی کسینوس زاویه بین دو بردار، \(s(q, x) = \cos(q, x)\)است
محصول نقطه ای
حاصل ضرب نقطه ای دو بردار\(s(q, x) = \langle q, x \rangle = \sum_{i = 1}^d q_i x_i\)است. همچنین توسط \(s(q, x) = \|x\| \|q\| \cos(q, x)\) (کسینوس زاویه ضرب در حاصلضرب هنجارها) داده می شود. بنابراین، اگر تعبیهها نرمال شوند، محصول نقطه و کسینوس بر هم منطبق میشوند.
فاصله اقلیدسی
این فاصله معمولی در فضای اقلیدسی است، \(s(q, x) = \|q - x\| = \left[ \sum_{i = 1}^d (q_i - x_i)^2\right]^{\frac{1}{2}}\). فاصله کمتر به معنای شباهت بیشتر است. توجه داشته باشید که وقتی جاسازیها نرمال میشوند، فاصله اقلیدسی مجذور با حاصلضرب نقطه (و کسینوس) تا یک ثابت منطبق است، زیرا در آن حالت \(\frac{1}{2}\|q - x\|^2 = 1 - \langle q, x \rangle\).

مقایسه معیارهای تشابه
به مثال شکل سمت راست توجه کنید. بردار سیاه رنگ جاسازی پرس و جو را نشان می دهد. سه بردار تعبیه شده دیگر (مورد A، آیتم B، آیتم ج) آیتم های کاندید را نشان می دهند. بسته به معیار تشابه مورد استفاده، رتبه بندی اقلام می تواند متفاوت باشد.
با استفاده از تصویر، سعی کنید رتبه بندی مورد را با استفاده از هر سه معیار تشابه تعیین کنید: کسینوس، حاصلضرب نقطه، و فاصله اقلیدسی.
کلید پاسخ
چطور انجامش دادی؟
مورد A دارای بیشترین هنجار است و با توجه به محصول نقطهای در رتبه بالاتری قرار میگیرد. مورد C کمترین زاویه را با پرس و جو دارد و بنابراین بر اساس شباهت کسینوس در رتبه اول قرار می گیرد. مورد B از نظر فیزیکی نزدیکترین به پرس و جو است، بنابراین فاصله اقلیدسی آن را ترجیح می دهد.

کدام معیار تشابه؟
در مقایسه با کسینوس، شباهت محصول نقطه ای به هنجار تعبیه حساس است. یعنی هر چه هنجار تعبیه بزرگتر باشد، شباهت بیشتر (برای موارد با زاویه تند) بیشتر می شود و احتمال بیشتری وجود دارد که مورد توصیه شود. این می تواند بر توصیه های زیر تأثیر بگذارد:
مواردی که اغلب در مجموعه آموزشی ظاهر می شوند (به عنوان مثال، ویدیوهای محبوب YouTube) معمولاً دارای تعبیه هایی با هنجارهای بزرگ هستند. اگر گرفتن اطلاعات محبوبیت مطلوب است، پس باید محصول نقطه ای را ترجیح دهید. با این حال، اگر مراقب نباشید، موارد محبوب ممکن است در نهایت بر توصیهها غالب شوند. در عمل، میتوانید از انواع دیگر معیارهای تشابه استفاده کنید که تأکید کمتری بر هنجار مورد دارد. به عنوان مثال،\(s(q, x) = \|q\|^\alpha \|x\|^\alpha \cos(q, x)\) را برای برخی \(\alpha \in (0, 1)\)تعریف کنید.
مواردی که بسیار به ندرت ظاهر می شوند ممکن است به طور مکرر در طول آموزش به روز نشوند. در نتیجه، اگر آنها با یک هنجار بزرگ مقداردهی اولیه شوند، سیستم ممکن است موارد کمیاب را نسبت به موارد مرتبط تر توصیه کند. برای جلوگیری از این مشکل، مراقب تعبیه مقداردهی اولیه باشید و از تنظیم مناسب استفاده کنید. این مشکل را در تمرین اول به تفصیل بیان خواهیم کرد.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-07-27 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-07-27 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eCandidate generation, the initial step in recommendation, involves identifying a set of relevant items using approaches like content-based filtering (similarity between items) and collaborative filtering (similarity between users and items).\u003c/p\u003e\n"],["\u003cp\u003eBoth methods utilize embedding spaces to represent items and queries as vectors, where similar items are positioned closer to each other based on chosen similarity measures (cosine, dot product, or Euclidean distance).\u003c/p\u003e\n"],["\u003cp\u003eThe choice of similarity measure influences item ranking: dot product considers embedding norms (favoring frequent items), while cosine focuses on the angle between vectors (favoring items with high semantic similarity).\u003c/p\u003e\n"],["\u003cp\u003eEuclidean distance prioritizes items physically closest in the embedding space and is less sensitive to norm or frequency, offering a balance between popularity and relevance.\u003c/p\u003e\n"],["\u003cp\u003eUnderstanding the properties and biases of different similarity measures is crucial for building effective and unbiased recommendation systems.\u003c/p\u003e\n"]]],[],null,["# Candidate generation overview\n\nCandidate generation is the first stage of recommendation. Given a query, the\nsystem generates a set of relevant candidates. The following table shows two\ncommon candidate generation approaches:\n\n| Type | Definition | Example |\n|-----------------------------|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **content-based filtering** | Uses *similarity between items* to recommend items similar to what the user likes. | If user A watches two cute cat videos, then the system can recommend cute animal videos to that user. |\n| **collaborative filtering** | Uses *similarities between queries and items simultaneously* to provide recommendations. | If user A is similar to user B, and user B likes video 1, then the system can recommend video 1 to user A (even if user A hasn't seen any videos similar to video 1). |\n\nEmbedding space\n---------------\n\nBoth content-based and collaborative filtering map each item and each query\n(or context) to an embedding vector in a common embedding space\n\\\\(E = \\\\mathbb R\\^d\\\\). Typically, the embedding space is low-dimensional\n(that is, \\\\(d\\\\) is much smaller than the size of the corpus), and captures\nsome latent structure of the item or query set. Similar items, such as YouTube\nvideos that are usually watched by the same user, end up close together in the\nembedding space. The notion of \"closeness\" is defined by a similarity measure.\n| **Extra Resource:** [projector.tensorflow.org](http://projector.tensorflow.org/) is an interactive tool to visualize embeddings.\n\nSimilarity measures\n-------------------\n\nA similarity measure is a function \\\\(s : E \\\\times E \\\\to \\\\mathbb R\\\\) that\ntakes a pair of embeddings and returns a scalar measuring their similarity.\nThe embeddings can be used for candidate generation as follows: given a\nquery embedding \\\\(q \\\\in E\\\\), the system looks for item embeddings\n\\\\(x \\\\in E\\\\) that are close to \\\\(q\\\\), that is, embeddings with high\nsimilarity \\\\(s(q, x)\\\\).\n\nTo determine the degree of similarity, most recommendation systems rely\non one or more of the following:\n\n- cosine\n- dot product\n- Euclidean distance\n\n### Cosine\n\nThis is simply the cosine of the angle between the two\nvectors, \\\\(s(q, x) = \\\\cos(q, x)\\\\)\n\n### Dot product\n\nThe dot product of two vectors is\n\\\\(s(q, x) = \\\\langle q, x \\\\rangle = \\\\sum_{i = 1}\\^d q_i x_i\\\\).\nIt is also given by \\\\(s(q, x) = \\\\\\|x\\\\\\| \\\\\\|q\\\\\\| \\\\cos(q, x)\\\\) (the cosine of the\nangle multiplied by the product of norms). Thus, if the embeddings are\nnormalized, then dot-product and cosine coincide.\n\n### Euclidean distance\n\nThis is the usual distance in Euclidean\nspace, \\\\(s(q, x) = \\\\\\|q - x\\\\\\| = \\\\left\\[ \\\\sum_{i = 1}\\^d (q_i - x_i)\\^2\\\\right\\]\\^{\\\\frac{1}{2}}\\\\).\nA smaller distance means higher similarity. Note that when the embeddings\nare normalized, the squared Euclidean distance coincides with dot-product\n(and cosine) up to a constant, since in that\ncase \\\\(\\\\frac{1}{2}\\\\\\|q - x\\\\\\|\\^2 = 1 - \\\\langle q, x \\\\rangle\\\\).\n\nComparing similarity measures\n-----------------------------\n\nConsider the example in the figure to the right. The black vector illustrates the\nquery embedding. The other three embedding vectors (Item A, Item B, Item C)\nrepresent candidate items. Depending on the similarity measure used, the\nranking of the items can be different.\n\nUsing the image, try to determine the item ranking using all three of the\nsimilarity measures: cosine, dot product, and Euclidean distance.\n\n#### Answer key\n\n**How did you do?**\n\nItem A has the largest norm, and is ranked higher according to the\ndot-product. Item C has the smallest angle with the query, and is thus\nranked first according to the cosine similarity. Item B is physically\nclosest to the query so Euclidean distance favors it.\n\nWhich similarity measure?\n-------------------------\n\nCompared to the cosine, the dot product similarity is sensitive to\nthe norm of the embedding. That is, the larger the norm of an\nembedding, the higher the similarity (for items with an acute angle)\nand the more likely the item is to be recommended. This can affect\nrecommendations as follows:\n\n- Items that appear very frequently in the training set (for example,\n popular YouTube videos) tend to have embeddings with large norms.\n If capturing popularity information is desirable, then you should\n prefer dot product. However, if you're not careful, the popular\n items may end up dominating the recommendations. In practice, you\n can use other variants of similarity measures that put less emphasis\n on the norm of the item. For example, define\n \\\\(s(q, x) = \\\\\\|q\\\\\\|\\^\\\\alpha \\\\\\|x\\\\\\|\\^\\\\alpha \\\\cos(q, x)\\\\) for\n some \\\\(\\\\alpha \\\\in (0, 1)\\\\).\n\n- Items that appear very rarely may not be updated frequently during\n training. Consequently, if they are initialized with a large norm, the\n system may recommend rare items over more relevant items. To avoid this\n problem, be careful about embedding initialization, and use appropriate\n regularization. We will detail this problem in the first exercise."]]