xiaohongshu
xiaohongshu
gemini-embeddings
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".
Full skill instructions
Generate high-quality text embeddings for semantic search, similarity analysis, clustering, and RAG (Retrieval Augmented Generation) applications through executable scripts.
Use this skill when you need to:
Purpose: Generate embeddings and calculate similarity
When to use:
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
python scripts/embed.py "What is the meaning of life?"
# 1. Generate embedding for query
python scripts/embed.py "best practices for coding" --task RETRIEVAL_QUERY > query.json
# 2. Generate embeddings for documents (batch)
python scripts/embed.py "Coding best practices include version control" "Clean code is essential" --task RETRIEVAL_DOCUMENT > docs.json
# 3. Compare and find most similar (calculate similarity separately)
RETRIEVAL_QUERY, RETRIEVAL_DOCUMENTpython scripts/embed.py "What is the meaning of life?" "What is the purpose of existence?" "How do I bake a cake?" --similarity
python scripts/embed.py "Text to embed" --dim 768
768, 1536, or 3072 (default)# 1. Generate embeddings for multiple documents
python scripts/embed.py "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.
CLUSTERING# 1. Create document embeddings (one-time setup)
python scripts/embed.py "Document 1 content" "Document 2 content" --task RETRIEVAL_DOCUMENT --dim 1536
# 2. For each query, find similar documents
python scripts/embed.py "User query here" --task RETRIEVAL_QUERY
# 3. Use retrieved documents in prompt to LLM (gemini-text)
python skills/gemini-text/scripts/generate.py "Context: [retrieved docs]. Answer: [user query]"
python scripts/embed.py "Text to process" --json
# 1. Create JSONL with documents
echo '{"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
| Task Type | Best For | When to Use |
|---|---|---|
SEMANTIC_SIMILARITY | Comparing text similarity | General comparison tasks |
RETRIEVAL_DOCUMENT | Embedding documents | Storing documents for retrieval |
RETRIEVAL_QUERY | Embedding search queries | Finding similar documents |
CLASSIFICATION | Text classification | Categorizing text |
CLUSTERING | Grouping similar texts | Document clustering |
| Dimensions | Use Case | Trade-off |
|---|---|---|
| 768 | High-volume, real-time | Lower accuracy, faster |
| 1536 | Balanced performance | Good accuracy/speed balance |
| 3072 | Highest accuracy | Slower, more storage |
| Score | Interpretation |
|---|---|
| 0.8 - 1.0 | Very similar (likely duplicates) |
| 0.6 - 0.8 | Highly related (same topic) |
| 0.4 - 0.6 | Moderately related |
| 0.2 - 0.4 | Weakly related |
| 0.0 - 0.2 | Unrelated |
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
[[0.123, -0.456, 0.789, ...], [0.234, -0.567, 0.890, ...]]
pip install google-genai numpy
pip install numpy
--similarity flag--dim parameter# Basic embedding
python scripts/embed.py "Your text here"
# Semantic search
python scripts/embed.py "Query" --task RETRIEVAL_QUERY
# Document embedding
python scripts/embed.py "Document text" --task RETRIEVAL_DOCUMENT
# Similarity comparison
python scripts/embed.py "Text 1" "Text 2" "Text 3" --similarity
# Dimensionality reduction
python scripts/embed.py "Text" --dim 768
# JSON output
python scripts/embed.py "Text" --json
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience