Langsung ke konten
Skillpedia
Agen40k ยท #7324

pinecone-rag

Fungsinya

Alat ini membantu membuat sistem yang memungkinkan kecerdasan buatan (agent) mengingat informasi penting atau mencari di dalam kumpulan dokumen yang besar. Alat ini menggunakan Pinecone, database khusus untuk pencarian informasi serupa secara cepat.

Kapan dipakai

  • โœ“Ketika Anda ingin agent AI mengingat percakapan sebelumnya.
  • โœ“Ketika Anda punya banyak dokumen (seperti PDF atau halaman web) dan ingin AI menemukan bagian yang paling relevan.
  • โœ“Ketika Anda ingin AI menjawab pertanyaan menggunakan informasi spesifik dari sekumpulan dokumen.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/github/awesome-copilot/blob/main/skills/pinecone-rag/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œSaya ingin AI bisa menjawab pertanyaan tentang dokumen kerja saya, sekaligus mengingat apa yang sudah kita bahas.โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Pertama, Anda menyiapkan 'database' di Pinecone. Kemudian, Anda mengubah dokumen atau informasi Anda ke dalam format yang bisa dipahami AI dan mengirimkannya ke Pinecone. Terakhir, AI dapat mencari dan menggunakan informasi ini untuk menjawab pertanyaan atau mengingat hal-hal tertentu.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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"]]
    }

โ€ฆ
Pertanyaan umum

Apa itu 'vector database' seperti Pinecone?

Itu adalah jenis database khusus yang dioptimalkan untuk mencari informasi berdasarkan makna, bukan hanya kata kunci yang sama persis. Database ini mengubah teks menjadi angka (vector) dan menemukan yang paling mirip.

Apa arti 'RAG'?

RAG adalah singkatan dari 'Retrieval-Augmented Generation'. Intinya, ini adalah cara agar AI mencari informasi yang relevan sebelum membuat jawaban, sehingga jawabannya lebih akurat dan berwawasan.

Apakah saya harus bisa coding untuk menggunakan ini?

Alat ini dirancang untuk membantu membangun sistem tersebut, tetapi penggunaan langsungnya mungkin memerlukan pengetahuan teknis. Tujuannya adalah menyederhanakan proses bagi yang bukan programmer.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
40k
Peringkat
#7324
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa