home / skills / lin-a1 / skills-agent / embedding_service

embedding_service skill

/services/embedding_service

This skill converts input text into high-dimensional embeddings for semantic search, clustering, and downstream analytics, enabling powerful NLP insights.

npx playbooks add skill lin-a1/skills-agent --skill embedding_service

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
931 B
---
name: embedding-service
description: 文本向量化(Embedding)基础服务。将自然语言转换为高维稠密向量,为语义搜索、聚类分析、推荐系统等下游任务提供核心数据支持。
---

## 功能
将输入文本转换为高维向量表示,用于语义相似度计算、聚类分析等下游任务。

## 调用方式
```python
from services.embedding_service.client import EmbeddingServiceClient

client = EmbeddingServiceClient()

# 单个文本向量化
vector = client.embed_query("人工智能")  # -> list[float]

# 多个文本向量化
texts = ["机器学习", "深度学习", "自然语言处理"]
vectors = client.embed_documents(texts)  # -> list[list[float]]
```

## 返回格式
```json
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [-0.031, -0.016, -0.007, ...]
    }
  ],
  "model": "Qwen/Qwen3-Embedding-0.6B"
}
```

Overview

This skill provides a lightweight embedding service that converts natural language text into high-dimensional dense vectors. It generates consistent vector outputs suitable for semantic similarity, clustering, and recommendation pipelines. The implementation exposes simple client methods for single and batch embedding calls.

How this skill works

The service accepts text inputs and returns numeric vector representations produced by a specified embedding model. Responses include an indexed list of embedding objects and the model identifier to ensure traceability. Clients can call methods for a single query or batch documents and receive lists of float vectors ready for downstream indexing or distance computations.

When to use it

  • Build semantic search indexes over documents, FAQs, or product catalogs.
  • Compute similarity scores for reranking or deduplication tasks.
  • Feed vectors into clustering algorithms for topic discovery.
  • Create content-based recommendation features for users or items.
  • Preprocess text for machine learning models requiring dense representations.

Best practices

  • Normalize and clean text (lowercase, remove noise) consistently before embedding.
  • Batch multiple documents to reduce RPC overhead and improve throughput.
  • Store returned model identifiers with vectors to track model drift over time.
  • Use cosine similarity or Euclidean distance depending on your indexing strategy.
  • Limit input length per request according to the embedding model's token limits.

Example use cases

  • Indexing customer support articles into a vector store for fast semantic search.
  • Detecting near-duplicate product descriptions during catalog ingestion.
  • Generating item embeddings to power a content-based recommender.
  • Clustering user feedback to surface common topics for product teams.
  • Reranking search results by semantic relevance after an initial keyword filter.

FAQ

What formats are returned by the service?

The service returns a JSON-like structure with an object list of embeddings, each containing an index and a float vector, along with the model name.

How do I embed multiple texts efficiently?

Use the batch embedding method to send a list of texts in one call; this reduces overhead and is more efficient than calling single-item embedding repeatedly.