embedding-optimization

A guide to improving vector embeddings, which are numeric representations of text used to find related meaning. It focuses on document retrieval, semantic search, model choice, text splitting, caching, cost, and speed.

In plain words
What is it for?
Use it to build or tune semantic search and retrieval-augmented generation systems, process large document collections, choose local or API models, and improve document chunking and retrieval quality.
Why use it?
It helps retrieval systems find more relevant passages while controlling processing time and embedding costs.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ancoleman/ai-design-components/embedding-optimization
Any agent
npx skills add ancoleman/ai-design-components --skill embedding-optimization
Clone the repo
git clone --depth 1 https://github.com/ancoleman/ai-design-components

Made for: Claude Code, Codex.

Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,058 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00049 $0.02058
Opus 5 $0.00024 $0.01029
Sonnet 5 $0.00010 $0.00412
Haiku 4.5 $0.00005 $0.00206

Measured 2d ago against content hash 69d60f1d596c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

embedding-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 6 executable files (examples/batch_processor.py, examples/benchmark_embeddings.py, examples/local_embedder.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/embedding-optimization/SKILL.md · 230 lines

How it starts

The opening of the file, as written. The whole thing — 230 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Embedding Optimization

Optimize embedding generation for cost, performance, and quality in RAG and semantic search systems.

When to Use This Skill

Trigger this skill when:

  • Building RAG (Retrieval Augmented Generation) systems
  • Implementing semantic search or similarity detection
  • Optimizing embedding API costs (reducing by 70-90%)
  • Improving document retrieval quality through better chunking
  • Processing large document corpora (thousands to millions of documents)
  • Selecting between API-based vs. local embedding models

Model Selection Framework

Choose the optimal embedding model based on requirements:

Quick Recommendations:

  • Startup/MVP: all-MiniLM-L6-v2 (local, 384 dims, zero API costs)
  • Production: text-embedding-3-small (API, 1,536 dims, balanced quality/cost)
  • High Quality: text-embedding-3-large (API, 3,072 dims, premium)
  • Multilingual: multilingual-e5-base (local, 768 dims) or Cohere embed-multilingual-v3.0

For detailed decision frameworks including cost comparisons, quality benchmarks, and data privacy considerations, see references/model-selection-guide.md.

Model Comparison Summary:

Model Type Dimensions Cost per 1M tokens Best For
all-MiniLM-L6-v2 Local 384 $0 (compute only) High volume, tight budgets
BGE-base-en-v1.5 Local 768 $0 (compute only) Quality + cost balance
text-embedding-3-small API 1,536 $0.02 General purpose production
text-embedding-3-large API 3,072 $0.13 Premium quality requirements
embed-multilingual-v3.0 API 1,024 $0.10 100+ language support

Chunking Strategies

Select chunking strategy based on content type and use case:

Content Type → Strategy Mapping:

  • Documentation: Recursive (heading-aware), 800 chars, 100 overlap
  • Code: Recursive (function-level), 1,000 chars, 100 overlap
  • Q&A/FAQ: Fixed-size, 500 chars, 50 overlap (precise retrieval)
  • Legal/Technical: Semantic (large), 1,500 chars, 200 overlap (context preservation)
  • Blog Posts: Semantic (paragraph), 1,000 chars, 100 overlap
  • Academic Papers: Recursive (section-aware), 1,200 chars, 150 overlap

Read the full file on GitHub · 230 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 230 lines · 49 tokens per session scan A 69d60f1d596c

Subscribe to this mod's changes

embedding-optimization is a skill published in the GitHub repository ancoleman/ai-design-components (517 stars, last pushed 8mo ago), licensed MIT. It adds 49 tokens to every session and 2,058 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

design-with-claude

Use when design work needs a product designer's eye: auditing a codebase for design-system gaps, fixing WCAG contrast and unlabeled inputs, choosing type scales or spacing steps, reviewing UI that looks generic or AI-generated, or designing forms, tables, dashboards, navigation, checkout, onboarding, dark mode, and…

imsaif/design-with-claude · 85 tokens

mimic-ai

Use when building, editing, or iterating on a Figma design via the Mimic AI MCP server (mimicstatus, mimicdiscoverds, figmacreateframe, figmainsertcomponent, mimicbuildtable, mimicbuildchart, etc. are available), or when the user asks to turn HTML, a prompt, or a Claude Design/Figma Make prototype into real Figma…

miapre/mimic-ai · 114 tokens

pencilplaybook

PencilPlaybook is the UI Skills / Taste-Skill for Pencil.dev + Claude Code — a design playbook that gives Claude real perceptual psychology and senior-level guardrails so it stops producing averaged-out AI slop.

stevembarclay/pencilplaybook · 50 tokens

best-in-world-strategy

Excellence-first strategic decision support. This skill should be used when users need to choose between options, pressure-test a plan, evaluate risk, or make a specific decision — across security, product, growth, operations, org design, and finance. Use when there is a decision with tradeoffs to score and a…

stevembarclay/pencilplaybook · 96 tokens

best-in-world-research

World-class practice research. This skill should be used when the user asks what the best in the world does about a specific problem, technique, or situation — covering product, engineering, design, marketing, compliance, operations, org design, and any other domain. Use when the goal is to understand elite-tier…

stevembarclay/pencilplaybook · 92 tokens

atlas

Architect the intelligence layer for agentic systems — RAG pipelines, model selection, embeddings, evaluation, and knowledge systems. Use when the user says "atlas", "ai data", "data arc". Produces data/ML architecture blueprints.

agenisea/ai-design-engineering-cc-plugins · 51 tokens