الفهارس التقريبية: HNSW وIVFFlat
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
choose between HNSW and IVFFlat by recall, build time, and memory.
الموضوعات المخطط لها
- Exact search checks every row; approximate (ANN) indexes are faster but may miss true nearest neighbours. The share found is the recall.
- HNSW: graph index; better recall and speed trade-off, slower to build, more memory, can be created on an empty table.
- IVFFlat: groups vectors into lists; faster build, smaller; build it after the data is loaded; recall depends on
listsandprobes. - Tune at query time (
hnsw.ef_search,ivfflat.probes); verify parameter names and defaults for your pgvector version. - Always measure recall against an exact query on a sample before trusting an index.
تفاصيل المخطط المبدئي
عرض عملي
CREATE INDEX ON help_chunk USING hnsw (embedding vector_cosine_ops);
SET hnsw.ef_search = 80;
-- recall check: compare top-10 with the index vs. top-10 from an exact scanاختبر فهمك
Which index builds faster on a freshly loaded static corpus?
أظهر الإجابة
IVFFlat; HNSW costs more build time and memory but usually gives better recall.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.