agentleFS
NikoxkxNikoxkx/Agent-Skills/skills/ai-ml/embeddings-builder/SKILL.md

embeddings-builder

Skill1 starsChanged 5 months agoApache-2.0View on GitHub

Creates, stores, and queries text embeddings for semantic search, clustering, or similarity. Use when building semantic search, recommendation systems, or clustering text data.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always batch (100-500 texts per call depending on model).

    line 38
  2. Distinctive:

    Create collection/index with dimension matching the model.

    line 43
  3. Distinctive:

    All runnable and with comments.

    line 76
  4. Distinctive:

    Update a document — old vector is replaced, new search reflects the change.

    line 89

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Overview

Builds production-grade text embedding pipelines: model selection (OpenAI, Cohere, Voyage, BGE, Snowflake, etc.), batch embedding, normalization, vector database upsert/query patterns, metadata filtering, approximate nearest neighbor tradeoffs, dimensionality reduction for visualization, and complete semantic search examples.

When to Use This Skill

  • Adding semantic search to a product (docs, products, messages, code).
  • Building recommendation or duplicate detection systems.
  • Clustering or topic modeling text data.
  • The user says "semantic search", "find similar", "embeddings", or "vector search".

Prerequisites

  • Text data to embed.
  • Embedding model API key or local model (sentence-transformers, etc.).
  • Vector database (Chroma, Qdrant, Pinecone, Weaviate, pgvector, Milvus).

Steps

  1. Model selection:
    • Quality vs cost vs latency vs max tokens vs language support.
    • Hosted (OpenAI text-embedding-3-large, Voyage, Cohere) vs self-hosted (BGE, Snowflake Arctic, UAE-Large).
    • Benchmark on your domain if possible (MTEB leaderboard is a starting point).
  2. Batch embedding:
    • Always batch (100-500 texts per call depending on model).
    • Handle rate limits and retries.
    • Normalize embeddings to unit length if the DB or similarity metric requires it (most cosine-based do).
  3. Vector DB setup:
    • Create collection/index with dimension matching the model.
    • Choose distance metric (cosine, dot product, Euclidean).
    • Design metadata schema (filterable fields: date, source, category, user_id, etc.).
  4. Upsert pattern:
    • Generate stable IDs (hash of content + metadata or use your own IDs).
    • Upsert in batches with metadata.
    • Handle updates/deletes (delete old vector, insert new).
  5. Query / search:
    • Embed the query with the same model.
    • Top-k + metadata filters.
    • Hybrid search when supported (vector + keyword).
    • Rerank top results with a cross-encoder for better precision.
  6. Dimensionality reduction & visualization (optional):
    • UMAP or t-SNE on a sample for exploration.
    • Plotly or matplotlib for 2D/3D scatter with labels.
  7. Output:
    • Embedding function (with batching + retry).
    • Vector DB client code for upsert and query (examples for top 2-3 DBs).
    • Semantic search demo script.
    • Normalization and ID strategy notes.
    • Cost/latency estimates for your data volume.

Examples

Complete code for:

  • Embedding a corpus of documents with Voyage-2 or OpenAI text-embedding-3-small.
  • Upserting to Qdrant and pgvector with rich metadata.
  • Performing filtered semantic search.
  • A small UMAP visualization of the embedding space. All runnable and with comments.

Edge Cases & Error Handling

  • Very long documents: Chunk first (see RAG skill), embed chunks, then aggregate or search at chunk level.
  • Multilingual: Choose a multilingual model or separate indexes per language.
  • Embedding drift: Re-embed on model upgrades; keep old embeddings for comparison or re-index.

Verification

  1. Embed a small set — vectors have the expected dimension and are normalized (if required).
  2. Semantic search for a query returns intuitively similar items (manual inspection).
  3. Metadata filters work (e.g., only results from 2024).
  4. Update a document — old vector is replaced, new search reflects the change.
  5. Visualization (if done) shows reasonable clusters.
  6. Success: Semantic search returns relevant results with good precision, and the pipeline scales to the target corpus size.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.