Embedding generator

From eddiebelaval/squire · View interactive version

Embedding generator is an AI agent skill from the GitHub repository eddiebelaval/squire. Generate and manage text embeddings for semantic search, clustering, and similarity tasks

How to use this skill

Skill file

Embedding Generator

The Embedding Generator skill helps you create, manage, and utilize text embeddings for semantic search, similarity matching, clustering, and classification tasks. It guides you through selecting appropriate embedding models, preprocessing text for optimal vectorization, and storing/querying embeddings efficiently.

Text embeddings transform words, sentences, or documents into dense numerical vectors that capture semantic meaning. Similar concepts end up close together in vector space, enabling powerful AI applications like semantic search, recommendations, and content understanding.

This skill covers everything from choosing the right model (OpenAI, Cohere, sentence-transformers, etc.) to implementing production-ready embedding pipelines with proper batching, caching, and quality validation.

Core Workflows

Workflow 1: Generate Embeddings for Text Corpus

  1. Analyze the text corpus:
  1. Select embedding model:
  1. Preprocess text:
  1. Generate embeddings with batching
  2. Validate quality with spot checks
  3. Store in appropriate vector database

Workflow 2: Choose Embedding Model

  1. Gather requirements:
  1. Compare models:

| Model | Dims | Speed | Quality | Cost |

|-------|------|-------|---------|------|

| OpenAI text-embedding-3-small | 1536 | Fast | Good | $$ |

| OpenAI text-embedding-3-large | 3072 | Fast | Best | $$$ |

| Cohere embed-english-v3 | 1024 | Fast | Great | $$ |

| sentence-transformers | 384-768 | Varies | Good | Free |

| Voyage AI | 1024 | Fast | Great | $$ |

  1. Benchmark on representative samples
  2. Document decision rationale

Workflow 3: Implement Embedding Pipeline

  1. Design pipeline architecture:
  1. Implement core components:

```python

# Example pipeline structure

def embedding_pipeline(texts):

cleaned = preprocess(texts)

chunks = chunk_if_needed(cleaned)

batches = create_batches(chunks, batch_size=100)

embeddings = []

for batch in batches:

result = model.embed(batch)

embeddings.extend(result)

return embeddings

```

  1. Add monitoring and logging
  2. Test with edge cases
  3. Optimize for production scale

Quick Reference

| Action | Command/Trigger |

|--------|-----------------|

| Generate embeddings | "Generate embeddings for these texts" |

| Choose model | "Which embedding model for [use case]" |

| Compare models | "Compare embedding models" |

| Optimize pipeline | "Speed up embedding generation" |

| Validate quality | "Check embedding quality" |

| Chunk documents | "How to chunk for embeddings" |

Best Practices

Advanced Techniques

Hybrid Chunking Strategy

Combine semantic and size-based chunking:

def hybrid_chunk(text, max_tokens=512):
    # First: Split on semantic boundaries
    sections = split_on_headers_paragraphs(text)

    # Then: Split large sections on size
    chunks = []
    for section in sections:
        if token_count(section) > max_tokens:
            chunks.extend(split_with_overlap(section, max_tokens))
        else:
            chunks.append(section)
    return chunks

Query Expansion for Better Retrieval

Generate multiple query embeddings for robust search:

Original: "machine learning frameworks"
Expanded: [
  "machine learning frameworks",
  "ML libraries and tools",
  "deep learning software",
  "AI development platforms"
]

Dimensionality Reduction

When storage or speed is critical:

- PCA: Fast, linear reduction
- UMAP: Preserves local structure
- Matryoshka embeddings: Models with variable-size outputs

Cross-Lingual Embeddings

For multilingual applications:

- Use multilingual models (mBERT, XLM-R, Cohere multilingual)
- Translate queries to embedding language
- Align embedding spaces post-hoc

Common Pitfalls to Avoid

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.