1. Learn
  2. /
  3. Kurser
  4. /
  5. OpenAI API के साथ Embeddings परिचय

Connected

övning

सबसे मिलते-जुलते प्रोडक्ट को खोजना

एम्बेडिंग्स के बीच similarity निकाल पाना, embeddings-आधारित एप्लिकेशनों का एक मुख्य चरण है। इस अभ्यास में, आप पहले इस्तेमाल की गई products list-of-dictionaries पर वापस आएँगे, जिसमें वे embedded short descriptions शामिल हैं जो आपने पहले बनाए थे.

आप किसी एक टेक्स्ट को इन embedded descriptions से तुलना करेंगे ताकि सबसे मिलती-जुलती description पहचान सकें.

numpy को np नाम से इम्पोर्ट किया गया है, और scipy.spatial से distance उपलब्ध है। आपके लिए एक create_embeddings() फंक्शन पहले से परिभाषित है, जिसे किसी एकल इनपुट से embeddings बनाने के लिए उपयोग कर सकते हैं.

Instruktioner

100 XP
  • अपने create_embeddings() custom फंक्शन का उपयोग करके "soap" टेक्स्ट को embed करें और embeddings की एक सिंगल list निकालें.
  • query_embedding और product में मौजूद embeddings के बीच cosine distance निकालें.
  • distances में उपलब्ध cosine distances का उपयोग करके सर्च टेक्स्ट के सबसे मिलते-जुलते प्रोडक्ट का 'short_description' ढूँढें और प्रिंट करें.