مقاييس التشابه
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
pick the distance measure that matches the embedding model.
الموضوعات المخطط لها
- Cosine distance: compares direction, ignores length. The common default for text embeddings.
- Inner product: fast; ranks like cosine when vectors are normalized to length 1.
- Euclidean (L2): straight-line distance; use it when the model was trained for it.
- Rule: use the measure the model documents. A wrong measure still returns results, just worse ones.
- The index must use the same measure as the query.
تفاصيل المخطط المبدئي
عرض عملي
| Measure | pgvector operator | Use when |
|---|---|---|
| Cosine distance | <=> | model recommends cosine |
| Inner product (negated) | <#> | vectors normalized |
| Euclidean | <-> | model trained for L2 |
اختبر فهمك
What happens if you use a measure the model was not trained for?
أظهر الإجابة
Queries run, but ranking quality drops silently.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.