0Pricing
NLP Academy · درس

البحث المتجهي باستخدام مخزن متجهات

استرجع المقاطع الأكثر صلة

البحث المتجهي باستخدام مخزن متجهات درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NLP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NLP Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

What a Vector Store Does

A vector store holds your chunk embeddings and finds the closest ones to a query fast, even across millions of vectors.

Searching by Similarity

Instead of matching keywords, you match meaning. The store returns chunks whose vectors sit nearest to the query vector.

Cosine Similarity

The common distance measure is cosine similarity. It compares the angle between two vectors, so closer in meaning scores higher.

Embed the Query the Same Way

The question must use the same model as your chunks. Mismatched embeddings live in different spaces and cannot be compared.

query_vec = model.encode(["How do I reset my password?"])

Top-K Retrieval

You rarely want every match. Ask the store for the top-k nearest chunks, where k is a small number like 3 or 5.

A Simple In-Memory Store

For small data, FAISS keeps vectors in memory and searches in milliseconds. You build an index, then add your vectors.

import faiss
index = faiss.IndexFlatIP(384)
index.add(vectors)

Running a Search

Call search with the query vector and k. It returns the scores and the indexes of the best-matching chunks.

scores, ids = index.search(query_vec, k=3)

Mapping Results Back to Text

The store gives you indexes, not text. Use them to look up the original chunks you stored alongside the vectors.

hits = [chunks[i] for i in ids[0]]

Persistent Vector Databases

For real apps, a vector database like Chroma or Pinecone stores vectors on disk, scales out, and survives restarts.

Filtering With Metadata

Attach tags such as author or date to each vector. Then you can filter the search, like only chunks from one document.

Why Approximate Search Helps

Exact search gets slow at scale. Approximate nearest-neighbor indexes trade a tiny bit of accuracy for huge speed gains.

Quick Check

Recall how a vector store finds relevant chunks.

Recap

A vector store embeds the query, finds the top-k nearest chunks by similarity, and maps results back to text. ✅

الأسئلة الشائعة

هل درس «البحث المتجهي باستخدام مخزن متجهات» مجاني؟

نعم — نص درس «البحث المتجهي باستخدام مخزن متجهات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة NLP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة NLP Academy 4 دروس في المجموع.

ماذا ستتعلم في «البحث المتجهي باستخدام مخزن متجهات»؟

استرجع المقاطع الأكثر صلة تتمرن على NLP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ NLP Academy؟

لا تُشترط خبرة سابقة. NLP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «البحث المتجهي باستخدام مخزن متجهات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس NLP Academy هذا؟

نعم. كل درس في NLP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. لماذا تحتاج LLMs إلى الاسترجاع
  2. تقسيم المستندات وتضمينها
  3. البحث المتجهي باستخدام مخزن متجهات
  4. دمج الاسترجاع في المطالبة
← العودة إلى NLP Academy