Generate text embeddings using Gemini Embedding API via scripts/. Use for creating vector representations of text, semantic search, similarity matching, clustering, and RAG applications. Triggers on "embeddings", "semantic search", "vector search", "text similarity", "RAG", "retrieval".
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Generate text embeddings using Gemini Embedding API via scripts/. Use for creating vector representations of text, semantic search, similarity matching, clustering, and RAG applications. Triggers on "embeddings", "semantic search", "vector search", "text similarity", "RAG", "retrieval".
Generate high-quality text embeddings for semantic search, similarity analysis, clustering, and RAG (Retrieval Augmented Generation) applications through executable scripts.
When to Use This Skill
Use this skill when you need to:
Find semantically similar documents or texts
Build semantic search engines
Implement RAG (Retrieval Augmented Generation)
Cluster or group similar documents
Calculate text similarity scores
Power recommendation systems
Enable semantic document retrieval
Create vector databases for AI applications
Available Scripts
scripts/embed.js
Purpose: Generate embeddings and calculate similarity
When to use:
Creating vector representations of text
Comparing text similarity
Building semantic search systems
Implementing RAG pipelines
Clustering documents
Key parameters:
Parameter
Description
Example
texts
Text(s) to embed (required)
"Your text here"
--model, -m
Embedding model
gemini-embedding-001
--task, -t
Task type
SEMANTIC_SIMILARITY
--dim, -d
Output dimensionality
768, 1536, 3072
--similarity, -s
Calculate pairwise similarity
Flag
--json, -j
Output as JSON
Flag
Output: Embedding vectors or similarity scores
Workflows
Workflow 1: Single Text Embedding
node scripts/embed.js "What is the meaning of life?"
Best for: Basic embedding generation
Output: Vector with 3072 dimensions (default)
Use when: Storing single document vectors
Workflow 2: Semantic Search
# 1. Generate embedding for query
node scripts/embed.js "best practices for coding" --task RETRIEVAL_QUERY > query.json
# 2. Generate embeddings for documents (batch)
node scripts/embed.js "Coding best practices include version control""Clean code is essential" --task RETRIEVAL_DOCUMENT > docs.json
# 3. Compare and find most similar (calculate similarity separately)
Best for: Building search functionality
Task types: RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT
Combines with: Similarity calculation for ranking
Workflow 3: Text Similarity Comparison
node scripts/embed.js "What is the meaning of life?""What is the purpose of existence?""How do I bake a cake?" --similarity
Best for: Comparing multiple texts, finding duplicates
Output: Pairwise similarity scores (0-1)
Use when: Need to rank text similarity
Workflow 4: Dimensionality Reduction for Efficiency
node scripts/embed.js "Text to embed" --dim 768
Best for: Faster storage and comparison
Options: 768, 1536, or 3072 (default)
Trade-off: Lower dimensions = less accuracy but faster
Workflow 5: Document Clustering
# 1. Generate embeddings for multiple documents
node scripts/embed.js "Machine learning is AI""Deep learning is a subset""Neural networks power AI" --json > embeddings.jsonl
# 2. Process embeddings with clustering algorithm (your code)# Use scikit-learn, KMeans, etc.
Best for: Grouping similar documents, topic discovery
# 1. Create document embeddings (one-time setup)
node scripts/embed.js "Document 1 content""Document 2 content" --task RETRIEVAL_DOCUMENT --dim 1536
# 2. For each query, find similar documents
node scripts/embed.js "User query here" --task RETRIEVAL_QUERY
# 3. Use retrieved documents in prompt to LLM (gemini-text)
node skills/gemini-text/scripts/generate.js "Context: [retrieved docs]. Answer: [user query]"
Best for: Building knowledge-based AI systems
Combines with: gemini-text for generation with context
Workflow 7: JSON Output for API Integration
node scripts/embed.js "Text to process" --json
Best for: API responses, database storage
Output: JSON array of embedding vectors
Use when: Programmatic processing required
Workflow 8: Batch Document Processing
# 1. Create JSONL with documentsecho'{"text": "Document 1"}' > docs.jsonl
echo'{"text": "Document 2"}' >> docs.jsonl
# 2. Process with script or custom code
python3 << 'EOF'
import json
from google import genai
client = genai.Client()
texts = []
with open("docs.jsonl") as f:
for line in f:
texts.append(json.loads(line)["text"])
response = client.models.embed_content(
model="gemini-embedding-001",
contents=texts,
task_type="RETRIEVAL_DOCUMENT"
)
embeddings = [e.values for e in response.embeddings]
print(f"Generated {len(embeddings)} embeddings")
EOF
Pairwise Similarity:
'What is the meaning of life?...' <-> 'What is the purpose of existence?...': 0.8742
'What is the meaning of life?...' <-> 'How do I bake a cake?...': 0.1234