ภาพรวมการสร้างผู้สมัคร
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การสร้างผู้สมัครเป็นคำแนะนำขั้นตอนแรก เมื่อมีข้อความค้นหา ฟิลด์
ระบบจะสร้างชุดตัวเลือกที่เกี่ยวข้อง ตารางต่อไปนี้แสดง
วิธีการสร้างผู้สมัครที่ใช้กันโดยทั่วไป:
ประเภท | คำจำกัดความ | ตัวอย่าง |
การกรองเนื้อหา |
ใช้ความคล้ายคลึงระหว่างไอเทมในการแนะนำรายการ
ที่คล้ายกับสิ่งที่ผู้ใช้ชอบ |
หากผู้ใช้ A ดูวิดีโอแมวน่ารักๆ 2 รายการ ระบบจะพบว่า
สามารถแนะนำวิดีโอสัตว์น่ารักๆ ให้กับผู้ใช้รายนั้นได้ |
การกรองแบบทำงานร่วมกัน |
ใช้ความคล้ายคลึงระหว่างคำค้นหาและรายการพร้อมกัน
เพื่อให้คำแนะนำ |
หากผู้ใช้ A คล้ายกับผู้ใช้ B และผู้ใช้ B ชอบวิดีโอ 1 ในกรณีนี้
ระบบจะสามารถแนะนำวิดีโอ 1 ให้กับผู้ใช้ A ได้ (แม้ว่าผู้ใช้ A จะ
เห็นวิดีโอที่คล้ายคลึงกับวิดีโอ 1) |
การฝังพื้นที่ทำงาน
การกรองทั้งตามเนื้อหาและตัวกรองแบบทำงานร่วมกันจะแมปแต่ละรายการและคำค้นหาแต่ละรายการ
(หรือบริบท) ไปยังเวกเตอร์ที่ฝังในพื้นที่การฝังทั่วไป
\(E = \mathbb R^d\)โดยปกติแล้วพื้นที่ที่ฝังจะมีมิติน้อย
(กล่าวคือ \(d\) เล็กกว่าขนาดของคอร์ปัสมาก) และจับภาพ
โครงสร้างที่แฝงอยู่บางอย่างของรายการหรือชุดข้อความค้นหา รายการที่คล้ายกัน เช่น YouTube
วิดีโอที่ปกติมักจะรับชมโดยผู้ใช้คนเดียวกัน ซึ่งมาอยู่ในระยะใกล้กันใน
ในพื้นที่ที่ฝัง มีความคิดเรื่อง "ความใกล้ชิด" กำหนดโดยการวัดความคล้ายคลึงกัน
การวัดความคล้ายคลึงกัน
การวัดความคล้ายคลึงกันคือฟังก์ชัน \(s : E \times E \to \mathbb R\) ที่
จะใช้การฝังคู่และส่งสเกลาร์เพื่อวัดความคล้ายคลึงกัน
การฝังคำขอสามารถใช้กับการสร้างผู้สมัครได้ด้วยวิธีต่อไปนี้
การฝังการค้นหา \(q \in E\)ระบบจะค้นหาการฝังรายการ
\(x \in E\) ที่ใกล้เคียงกับ \(q\)ซึ่งก็คือมีการฝังด้วย
ความคล้ายคลึงกัน \(s(q, x)\)
ระบบการแนะนำส่วนใหญ่จะพิจารณาระดับของความคล้ายคลึงกัน
ตามเกณฑ์ต่อไปนี้อย่างน้อยหนึ่งรายการ
- โคไซน์
- ผลิตภัณฑ์แบบจุด
- ระยะทางยุคลิด
โคไซน์
นี่เป็นเพียงโคไซน์ของมุมระหว่าง 2
เวกเตอร์ \(s(q, x) = \cos(q, x)\)
ผลิตภัณฑ์ Dot
ผลคูณแบบจุดของเวกเตอร์ 2 เวกเตอร์คือ
\(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\)

การเปรียบเทียบการวัดความคล้ายคลึงกัน
พิจารณาตัวอย่างในรูปทางด้านขวา เวกเตอร์สีดำแสดงถึง
การฝังการค้นหา เวกเตอร์ที่ฝังอีก 3 รายการ (รายการ A, รายการ B, รายการ C)
ซึ่งแสดงถึงรายการผู้สมัคร ขึ้นอยู่กับการวัดความคล้ายคลึงกันที่ใช้
การจัดอันดับสินค้าอาจแตกต่างออกไปได้
ใช้รูปภาพในการพิจารณาการจัดอันดับสินค้าโดยใช้ทั้ง 3 อย่าง
การวัดความคล้ายคลึงกัน ได้แก่ โคไซน์ ผลคูณเชิงจุด และระยะทางแบบยุคลิด
เฉลยคำตอบ
เป็นอย่างไรบ้าง
รายการ ก มีบรรทัดฐานใหญ่ที่สุด และได้รับการจัดอันดับสูงกว่าตาม
ดอท-ผลิตภัณฑ์ รายการ C มีมุมที่เล็กที่สุดกับข้อความค้นหา ดังนั้น
จัดอันดับก่อนตามความคล้ายคลึงกันของโคไซน์ รายการ B มีลักษณะทางกายภาพ
อยู่ใกล้กับข้อความค้นหามากที่สุด เพื่อให้ระยะทางแบบยุคลิดมากกว่าค่านี้

ความคล้ายคลึงกันเป็นตัววัดค่าใด
เมื่อเทียบกับโคไซน์ ความคล้ายคลึงกันของผลิตภัณฑ์จุดจะไวต่อ
บรรทัดฐานของการฝัง นั่นคือ ยิ่งเป็นบรรทัดฐานของ
การฝังยิ่งมีความคล้ายคลึงกันมากขึ้น (สำหรับรายการที่มีมุมแหลม)
และมีแนวโน้มที่จะได้รับการแนะนำ
สินค้ามากขึ้นเท่านั้น ซึ่งอาจส่งผลต่อ
ดังต่อไปนี้
รายการที่ปรากฏบ่อยมากในชุดการฝึก (เช่น
วิดีโอ YouTube ยอดนิยม) มักจะมีการฝังด้วยบรรทัดฐานใหญ่ๆ
หากคุณต้องการข้อมูลความนิยม คุณควร
ชอบผลิตภัณฑ์แบบจุด แต่หากไม่ระมัดระวัง ลิงก์
รายการอาจกลายเป็นวิดีโอแนะนำ ในทางปฏิบัติ คุณจะ
สามารถใช้ตัวแปรอื่นๆ ของการวัดความคล้ายคลึงกันซึ่งเน้นความสำคัญน้อยกว่า
ตามลักษณะของไอเทม เช่น ระบุ
\(s(q, x) = \|q\|^\alpha \|x\|^\alpha \cos(q, x)\) สำหรับ
\(\alpha \in (0, 1)\)
รายการที่ปรากฏน้อยมาก อาจไม่ได้อัปเดตบ่อยนักในช่วง
การฝึกอบรม ดังนั้น หากเริ่มต้นโดยใช้กลุ่มมาตรฐานขนาดใหญ่
ระบบอาจแนะนำแรร์ไอเทมมากกว่ารายการที่เกี่ยวข้องมากกว่า เพื่อหลีกเลี่ยงปัญหานี้
โปรดระวังเกี่ยวกับการฝังการเริ่มต้น และใช้
มาตรฐาน เราจะอธิบายรายละเอียดของโจทย์นี้ในแบบฝึกหัดแรก
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-07-26 UTC
[null,null,["อัปเดตล่าสุด 2024-07-26 UTC"],[[["\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."]]