এম্বেডিং থেকে সাদৃশ্য পরিমাপ
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
আপনার কাছে এখন যেকোনো জোড়া উদাহরণের জন্য এম্বেডিং আছে। একটি তত্ত্বাবধানে থাকা সাদৃশ্য পরিমাপ এই এমবেডিংগুলি নেয় এবং তাদের মিল পরিমাপ করে একটি সংখ্যা প্রদান করে। মনে রাখবেন যে এমবেডিং হল সংখ্যার ভেক্টর। দুটি ভেক্টরের মধ্যে মিল খুঁজে বের করতে \(A = [a_1,a_2,...,a_n]\) এবং \(B = [b_1,b_2,...,b_n]\), এই তিনটি সাদৃশ্য পরিমাপের মধ্যে একটি বেছে নিন:
পরিমাপ | অর্থ | সূত্র | সাদৃশ্য বাড়ার সাথে সাথে এই পরিমাপ... |
---|
ইউক্লিডীয় দূরত্ব | ভেক্টরের প্রান্তের মধ্যে দূরত্ব | \(\sqrt{(a_1-b_1)^2+(a_2-b_2)^2+...+(a_N-b_N)^2}\) | কমে যায় |
কোসাইন | কোণের কোসাইন \(\theta\) ভেক্টরের মধ্যে | \(\frac{a^T b}{|a| \cdot |b|}\) | বাড়ে |
ডট পণ্য | কোসাইন উভয় ভেক্টরের দৈর্ঘ্য দ্বারা গুণিত | \(a_1b_1+a_2b_2+...+a_nb_n\) \(=|a||b|cos(\theta)\) | বাড়ে। এছাড়াও ভেক্টরের দৈর্ঘ্যের সাথে বৃদ্ধি পায়। |
একটি সাদৃশ্য পরিমাপ নির্বাচন
কোসাইনের বিপরীতে, ডট পণ্যটি ভেক্টর দৈর্ঘ্যের সমানুপাতিক। এটি গুরুত্বপূর্ণ কারণ যে উদাহরণগুলি প্রশিক্ষণ সেটে খুব ঘন ঘন দেখা যায় (উদাহরণস্বরূপ, জনপ্রিয় ইউটিউব ভিডিও) সেগুলি বড় দৈর্ঘ্যের সাথে এম্বেডিং ভেক্টর থাকে৷আপনি জনপ্রিয়তা ক্যাপচার করতে চান, তারপর ডট পণ্য নির্বাচন করুন. যাইহোক, ঝুঁকি হল যে জনপ্রিয় উদাহরণগুলি সাদৃশ্য মেট্রিককে তিরস্কার করতে পারে। এই তির্যক ভারসাম্য রাখতে, আপনি দৈর্ঘ্যকে সূচকে বাড়াতে পারেন \(\alpha\ < 1\) ডট পণ্য হিসাবে গণনা করতে \(|a|^{\alpha}|b|^{\alpha}\cos(\theta)\).
ভেক্টরের দৈর্ঘ্য কীভাবে সাদৃশ্য পরিমাপকে পরিবর্তন করে তা আরও ভালভাবে বোঝার জন্য, ভেক্টর দৈর্ঘ্যকে 1-এ স্বাভাবিক করুন এবং লক্ষ্য করুন যে তিনটি পরিমাপ একে অপরের সমানুপাতিক হয়ে গেছে।
a এবং b কে স্বাভাবিক করার পর এমন \(||a||=1\) এবং \(||b||=1\), এই তিনটি ব্যবস্থার সাথে সম্পর্কিত:
- ইউক্লিডীয় দূরত্ব = \(||a-b|| = \sqrt{||a||^2 + ||b||^2 - 2a^{T}b}
= \sqrt{2-2\cos(\theta_{ab})}\).
- ডট পণ্য = \( |a||b| \cos(\theta_{ab})
= 1\cdot1\cdot \cos(\theta_{ab}) = cos(\theta_{ab})\).
- কোসাইন = \(\cos(\theta_{ab})\).
এইভাবে, তিনটি সাদৃশ্য পরিমাপ সমতুল্য কারণ তারা সমানুপাতিক \(cos(\theta_{ab})\).
সাদৃশ্য ব্যবস্থা পর্যালোচনা
একটি সাদৃশ্য পরিমাপ অন্যান্য জোড়া উদাহরণের সাথে আপেক্ষিক উদাহরণগুলির একটি জোড়ার মধ্যে সাদৃশ্যকে পরিমাপ করে৷ দুটি প্রকার, ম্যানুয়াল এবং তত্ত্বাবধান, নীচে তুলনা করা হয়েছে:
টাইপ | কিভাবে তৈরি করতে হয় | জন্য সেরা | অন্তর্নিহিততা |
---|
ম্যানুয়াল | ম্যানুয়ালি বৈশিষ্ট্য ডেটা একত্রিত করুন। | একত্রিত করা সহজবোধ্য বৈশিষ্ট্য সহ ছোট ডেটাসেট। | সাদৃশ্য গণনার ফলাফলের অন্তর্দৃষ্টি দেয়। যদি বৈশিষ্ট্য ডেটা পরিবর্তিত হয়, তাহলে আপনাকে অবশ্যই মিলের পরিমাপ ম্যানুয়ালি আপডেট করতে হবে। |
তদারকি করেছে | একটি তত্ত্বাবধানে থাকা DNN দ্বারা উত্পন্ন এমবেডিংগুলির মধ্যে দূরত্ব পরিমাপ করুন৷ | হার্ড-টু-একত্রিত বৈশিষ্ট্য সহ বড় ডেটাসেট। | ফলাফলের কোন অন্তর্দৃষ্টি দেয় না। যাইহোক, একটি DNN স্বয়ংক্রিয়ভাবে বৈশিষ্ট্য ডেটা পরিবর্তনের সাথে মানিয়ে নিতে পারে। |
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-02-25 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-02-25 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eSupervised similarity measures leverage embeddings to quantify the similarity between data examples using Euclidean distance, cosine, or dot product.\u003c/p\u003e\n"],["\u003cp\u003eDot product incorporates vector length, reflecting popularity, while cosine similarity focuses solely on the angle between vectors, ignoring popularity.\u003c/p\u003e\n"],["\u003cp\u003eNormalizing vector lengths makes Euclidean distance, cosine, and dot product proportional, essentially measuring the same thing.\u003c/p\u003e\n"],["\u003cp\u003eSupervised similarity, using embeddings and a distance metric, is suitable for large, complex datasets, while manual similarity, relying on feature combinations, is better for small, straightforward datasets.\u003c/p\u003e\n"]]],[],null,["# Measuring similarity from embeddings\n\nYou now have embeddings for any pair of examples. A supervised similarity\nmeasure takes these embeddings and returns a number measuring their similarity.\nRemember that embeddings are vectors of numbers. To find the similarity between\ntwo vectors \\\\(A = \\[a_1,a_2,...,a_n\\]\\\\) and \\\\(B = \\[b_1,b_2,...,b_n\\]\\\\),\nchoose one of these three similarity measures:\n\n| Measure | Meaning | Formula | As similarity increases, this measure... |\n|--------------------|-----------------------------------------------|--------------------------------------------------------------|---------------------------------------------------|\n| Euclidean distance | Distance between ends of vectors | \\\\(\\\\sqrt{(a_1-b_1)\\^2+(a_2-b_2)\\^2+...+(a_N-b_N)\\^2}\\\\) | Decreases |\n| Cosine | Cosine of angle \\\\(\\\\theta\\\\) between vectors | \\\\(\\\\frac{a\\^T b}{\\|a\\| \\\\cdot \\|b\\|}\\\\) | Increases |\n| Dot product | Cosine multiplied by lengths of both vectors | \\\\(a_1b_1+a_2b_2+...+a_nb_n\\\\) \\\\(=\\|a\\|\\|b\\|cos(\\\\theta)\\\\) | Increases. Also increases with length of vectors. |\n\nChoosing a similarity measure\n-----------------------------\n\nIn contrast to the cosine, the dot product is proportional to the vector length.\nThis is important because examples that appear very frequently in the training\nset (for example, popular YouTube videos) tend to have embedding vectors with\nlarge lengths.\n\nIf you\nwant to capture popularity, then choose dot product. However, the risk is that\npopular examples may skew the similarity metric. To balance this skew, you can\nraise the length to an exponent \\\\(\\\\alpha\\\\ \\\u003c 1\\\\) to calculate the dot product\nas \\\\(\\|a\\|\\^{\\\\alpha}\\|b\\|\\^{\\\\alpha}\\\\cos(\\\\theta)\\\\).\n\nTo better understand how vector length changes the similarity measure, normalize\nthe vector lengths to 1 and notice that the three measures become proportional\nto each other. \nProof: Proportionality of Similarity Measures \nAfter normalizing a and b such that \\\\(\\|\\|a\\|\\|=1\\\\) and \\\\(\\|\\|b\\|\\|=1\\\\), these three measures are related as:\n\n- Euclidean distance = \\\\(\\|\\|a-b\\|\\| = \\\\sqrt{\\|\\|a\\|\\|\\^2 + \\|\\|b\\|\\|\\^2 - 2a\\^{T}b} = \\\\sqrt{2-2\\\\cos(\\\\theta_{ab})}\\\\).\n- Dot product = \\\\( \\|a\\|\\|b\\| \\\\cos(\\\\theta_{ab}) = 1\\\\cdot1\\\\cdot \\\\cos(\\\\theta_{ab}) = cos(\\\\theta_{ab})\\\\).\n- Cosine = \\\\(\\\\cos(\\\\theta_{ab})\\\\).\nThus, all three similarity measures are equivalent because they are proportional to \\\\(cos(\\\\theta_{ab})\\\\).\n\nReview of similarity measures\n-----------------------------\n\nA similarity measure quantifies the similarity between a pair of\nexamples, relative to other pairs of examples. The two types, manual and\nsupervised, are compared below:\n\n| Type | How to create | Best for | Implications |\n|------------|--------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|\n| Manual | Manually combine feature data. | Small datasets with features that are straightforward to combine. | Gives insight into results of similarity calculations. If feature data changes, you must manually update the similarity measure. |\n| Supervised | Measure distance between embeddings generated by a supervised DNN. | Large datasets with hard-to-combine features. | Gives no insight into results. However, a DNN can automatically adapt to changing feature data. |"]]