Skillpedia
الوكلاء40k · #7324

pinecone-rag

ما الذي تفعله

تساعد هذه المهارة على إنشاء أنظمة تمكّن وكلاء الذكاء الاصطناعي من تذكّر المعلومات المهمة، أو البحث في كميات كبيرة من المستندات. وتستخدم Pinecone، وهي قاعدة بيانات متخصصة في البحث السريع عن المعلومات المتشابهة.

متى تستخدمها

  • ✓عندما تريد أن يتذكر وكيل الذكاء الاصطناعي المحادثات السابقة.
  • ✓عندما تملك مستندات كثيرة (مثل ملفات PDF أو صفحات ويب) وتريد أن يجد الذكاء الاصطناعي الأجزاء الأكثر صلة.
  • ✓عندما تريد أن يجيب الذكاء الاصطناعي عن الأسئلة باستخدام معلومات محددة من مجموعة مستندات.

رابط المهارة

https://github.com/github/awesome-copilot/blob/main/skills/pinecone-rag/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/github/awesome-copilot/blob/main/skills/pinecone-rag/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أريد أن يجيب الذكاء الاصطناعي عن أسئلة حول مستندات عملي، ويتذكر ما سبق أن ناقشناه.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

أولاً، تُعدّ «قاعدة بيانات» في Pinecone. ثم تحوّل مستنداتك أو معلوماتك إلى صيغة يفهمها الذكاء الاصطناعي وترسلها إلى Pinecone. وأخيراً يستطيع الذكاء الاصطناعي البحث في هذه المعلومات واستخدامها للإجابة عن الأسئلة أو تذكّر الأشياء.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Pinecone RAG Skill

This skill guides you through building a production RAG pipeline or persistent agent memory system using Pinecone. Follow the workflow from start to finish — don't skip steps or jump to code before understanding what the user actually needs.

Before you start — ask one question

Before writing any code, identify which of these two use cases applies:

A — RAG over documents: User wants to index a corpus (PDFs, docs, code, web pages) and retrieve relevant chunks to ground LLM responses.

B — Agent memory: User wants an agent to remember facts, decisions, or context across sessions or across multiple agents sharing a knowledge base.

The setup is similar but the namespace strategy and retrieval patterns differ. If the user hasn't said, ask: "Is this for document retrieval, agent memory, or both?" Then follow the relevant workflow below.


Step 1 — Choose your index configuration

Pick the index type before writing any code. Getting this wrong means re-creating the index later.

Serverless (recommended for most cases)

from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="PINECONE_API_KEY")

if "my-index" not in pc.list_indexes().names():
    pc.create_index(
        name="my-index",
        dimension=1536,        # must match your embedding model exactly
        metric="cosine",
        spec=ServerlessSpec(cloud="aws", region="us-east-1")
    )
index = pc.Index("my-index")

Pod-based (for consistent high-throughput production)

from pinecone import PodSpec

pc.create_index(
    name="my-index-prod",
    dimension=1536,
    metric="cosine",
    spec=PodSpec(environment="us-east1-gcp", pod_type="p1.x1")
)

Dimension quick reference — match this exactly to your embedding model:

Model Dimension
text-embedding-3-small 1536
text-embedding-3-large 3072
voyage-3 / voyage-multimodal-3 1024
BAAI/bge-large-en-v1.5 1024
intfloat/multilingual-e5-large (Arabic, Malay, Chinese) 1024

Checkpoint: Index exists, dimension matches embedding model, index.describe_index_stats() returns without error.


Step 2 — Embed and upsert documents

Always batch upserts — never upsert one vector at a time.

from openai import OpenAI

client = OpenAI()

def embed(texts: list[str]) -> list[list[float]]:
    res = client.embeddings.create(model="text-embedding-3-small", input=texts)
    return [r.embedding for r in res.data]

def upsert_docs(index, docs: list[dict], namespace: str = "default"):
    """docs = [{"id": "...", "text": "...", "metadata": {...}}]"""
    BATCH = 100
    for i in range(0, len(docs), BATCH):
        batch = docs[i:i + BATCH]
        vecs = [
            {
                "id": d["id"],
                "values": emb,
                "metadata": {**d.get("metadata", {}), "text": d["text"]}
            }
            for d, emb in zip(batch, embed([d["text"] for d in batch]))
        ]
        index.upsert(vectors=vecs, namespace=namespace)

Always store the original text in metadata — this avoids a second lookup at retrieval time.

Checkpoint: index.describe_index_stats() shows vector count > 0 in the target namespace.


Step 3 — Choose retrieval strategy

Dense (semantic) search — use for most cases

def search(index, query: str, top_k: int = 5, namespace: str = "default",
           filter: dict = None) -> list[dict]:
    [q_emb] = embed([query])
    results = index.query(
        vector=q_emb, top_k=top_k, namespace=namespace,
        include_metadata=True, filter=filter
    )
    return [{"text": m.metadata["text"], "score": m.score, "id": m.id}
            for m in results.matches]

Hybrid search (semantic + BM25 keyword) — use when corpus has exact terminology

Use hybrid when the domain has precise terms that semantic search misses: legal citations, medical codes, product SKUs, API method names.

from pinecone_text.sparse import BM25Encoder

bm25 = BM25Encoder().default()
bm25.fit([d["text"] for d in docs])  # fit once on your corpus

def hybrid_search(index, query: str, top_k: int = 5, alpha: float = 0.7):
    """alpha=1.0 is pure dense; alpha=0.0 is pure sparse."""
    dense = [v * alpha for v in embed([query])[0]]
    sparse_raw = bm25.encode_queries(query)
    sparse = {
        "indices": sparse_raw["indices"],
        "values": [v * (1 - alpha) for v in sparse_raw["values"]]
    }

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

ما هي «قاعدة البيانات المتجهية» (vector database) مثل Pinecone؟

هي نوع خاص من قواعد البيانات مُحسَّن لإيجاد المعلومات بناءً على المعنى، لا على الكلمات المفتاحية وحدها. تحوّل النص إلى أرقام (متجهات) وتجد الأكثر تشابهاً.

ماذا تعني «RAG»؟

RAG اختصار لـ Retrieval-Augmented Generation (التوليد المعزز بالاسترجاع). وهي طريقة تجعل الذكاء الاصطناعي يبحث عن معلومات ذات صلة قبل توليد الإجابة، مما يجعلها أدق وأكثر اطلاعاً.

هل أحتاج إلى معرفة البرمجة لاستخدامها؟

صُممت المهارة للمساعدة في بناء هذه الأنظمة، لكن الاستخدام المباشر قد يحتاج إلى معرفة تقنية. والهدف هو تبسيط العملية لغير المبرمجين.

التفاصيل

الوصف الأصلي من المؤلف

Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions Pinecone, wants to index documents for semantic search, build a retrieval-augmented generation system, store agent memory across sessions, implement hybrid search, or connect an LLM to a searchable knowledge base — even if they don't say "Pinecone"

repo: github/awesome-copilot

الشعبية

نجوم GitHub
40k
الترتيب
#7324
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة