Copy-paste examples for common vector search patterns.
Each example uses the veep Python SDK.
from veep import Client, samples
vp = Client.login() # browser OAuth; or Client(api_key="veep_live_...")
docs = [
"Vector databases store embeddings and search them by meaning.",
"RAG retrieves relevant context before the model answers.",
"Vector Panda bills for storage only; queries are free.",
]
vp.collections.create("rag-notes", tier="hot")
vp.vectors.upsert("rag-notes", vectors=[
{"id": f"doc-{i}", "vector": samples.encode(d), "metadata": {"text": d}}
for i, d in enumerate(docs)
])
question = "How does RAG improve an LLM's answers?"
hits = vp.vectors.query("rag-notes", samples.encode(question), top_k=2)
context = "\n".join(h.metadata["text"] for h in hits)
# Hand the assembled prompt to whichever LLM you use
prompt = f"Context:\n{context}\n\nQuestion: {question}"
print(prompt)
import json, pathlib, tarfile, urllib.request
from PIL import Image
from sentence_transformers import SentenceTransformer
from veep import Client
urllib.request.urlretrieve(
"https://next.vectorpanda.com/data/example-met-famous.tar.gz",
"met-famous.tar.gz",
)
with tarfile.open("met-famous.tar.gz") as tf:
tf.extractall(".")
model = SentenceTransformer("clip-ViT-B-32") # text and images share one space
vp = Client.login()
meta = json.loads(pathlib.Path("met-famous/metadata.json").read_text())
vp.collections.create("artworks", tier="hot")
vp.vectors.upsert("artworks", vectors=[
{"id": str(row["object_id"]),
"vector": model.encode(Image.open(f"met-famous/{row['image_file']}")).tolist(),
"metadata": {"title": row["title"], "artist": row["artist"]}}
for row in meta
])
q = model.encode("a swirling night sky over a quiet village").tolist()
for r in vp.vectors.query("artworks", q, top_k=3):
print(f"{r.metadata['title']} — {r.metadata['artist']} score={r.score:.3f}")
from veep import Client, samples
vp = Client.login()
catalog = [
("shoe-1", "Lightweight mesh running shoe with a cushioned sole", "footwear", 89.99),
("shoe-2", "Rugged trail runner with a rock plate and deep lugs", "footwear", 129.99),
("shoe-3", "Leather dress shoe with a stitched welt", "footwear", 149.00),
("jacket-1", "Waterproof shell jacket with pit zips", "outerwear", 159.00),
]
vp.collections.create("products", tier="hot")
vp.vectors.upsert("products", vectors=[
{"id": pid, "vector": samples.encode(desc),
"metadata": {"name": desc, "category": cat, "price": price}}
for pid, desc, cat, price in catalog
])
# "More like what the user is viewing," constrained to the same category
viewing = samples.encode("Lightweight mesh running shoe with a cushioned sole")
for r in vp.vectors.query("products", viewing, top_k=3, filter={"category": "footwear"}):
print(f"{r.metadata['name']} ${r.metadata['price']}")
from veep import Client, samples
vp = Client.login()
tickets = [
"App crashes when I upload a CSV bigger than 2 GB",
"Uploading a large CSV (over 2GB) crashes the app",
"Dark mode toggle does nothing on the settings page",
]
vp.collections.create("tickets", tier="hot")
vp.vectors.upsert("tickets", vectors=[
{"id": f"t-{i}", "vector": samples.encode(t), "metadata": {"text": t}}
for i, t in enumerate(tickets)
])
# Any pair scoring above the threshold is a duplicate candidate
THRESHOLD = 0.85
for i, t in enumerate(tickets):
for r in vp.vectors.query("tickets", samples.encode(t), top_k=3, min_score=THRESHOLD):
if r.key != f"t-{i}":
print(f"t-{i} duplicates {r.key} score={r.score:.3f}")
$5 in monthly usage credits, free to start. No card required for your first 90 days.
Quickstart Guide