Tooluck logoTooluck
SKILL.md

pgvector-semantic-search

Agent skill fromtimescale/pg-aiguide

Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. **Trigger when user asks to:** - Store or search vector embeddings in PostgreSQL - Set up semantic search, similarity search, or nearest neighbor search - Create HNSW or IVFFlat indexes for vectors - Implement RAG (Retrieval Augmented Generation) with PostgreSQL - Optimize pgvector performance, recall, or memory usage - Use binary quantization for large vector datasets **Keywords:** pgvector, embeddings, semantic search, vector similarity, HNSW, IVFFlat, halfvec, cosine distance, nearest neighbor, RAG, LLM, AI search Covers: halfvec storage, HNSW index configuration (m, ef_construction, ef_search), quantization strategies, filtered search, bulk loading, and performance tuning.

How to install pgvector-semantic-search

install pgvector-semantic-search
# install the pg-aiguide pack with the skills CLI
npx skills add timescale/pg-aiguide

# or add only this skill to Claude Code: copy the folder

skills/pgvector-semantic-search/

# into

~/.claude/skills/pgvector-semantic-search/ (all projects)

.claude/skills/pgvector-semantic-search/ (one project)

skills/pgvector-semantic-search/SKILL.md

Apache-2.0Full file
1# pgvector for Semantic Search
2
3Semantic search finds content by meaning rather than exact keywords. An embedding model converts text into high-dimensional vectors, where similar meanings map to nearby points. pgvector stores these vectors in PostgreSQL and uses approximate nearest neighbor (ANN) indexes to find the closest matches quickly—scaling to millions of rows without leaving the database. Store your text alongside its embedding, then query by converting your search text to a vector and returning the rows with the smallest distance.
4
5This guide covers pgvector setup and tuning—not embedding model selection or text chunking, which significantly affect search quality. Requires pgvector 0.8.0+ for all features (`halfvec`, `binary_quantize`, iterative scan).
6
7## Golden Path (Default Setup)
8
9Use this configuration unless you have a specific reason not to.
10- Embedding column data type: `halfvec(N)` where `N` is your embedding dimension (must match everywhere). Examples use 1536; replace with your dimension `N`.
11- Distance: cosine (`<=>`)
12- Index: HNSW (`m = 16`, `ef_construction = 64`). Use `halfvec_cosine_ops` and query with `<=>`.
13- Query-time recall: `SET hnsw.ef_search = 100` (good starting point from published benchmarks, increase for higher recall at higher latency)
14- Query pattern: `ORDER BY embedding <=> $1::halfvec(N) LIMIT k`
15
16This setup provides a strong speed–recall tradeoff for most text-embedding workloads.
17
18## Core Rules
19…

Excerpt shown under the repository's Apache-2.0 license.

More skills in pg-aiguide

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates