beer-sakthai/sak-family-agent/sakthai-hf-inference-client-embeddings-patterns

Claude Code and agent skill by beer-sakthai/sak-family-agent

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

name: SakThai-hf-inference-client-embeddings-patterns

Install

npx vskill@latest install beer-sakthai/sak-family-agent/sakthai-hf-inference-client-embeddings-patterns

SKILL.md

HF Inference Client — Embeddings Patterns (Serverless)

Overview

Generate text embeddings via the Hugging Face Inference API at zero cost using InferenceClient.feature_extraction() and InferenceClient.sentence_similarity(). Covers the serverless (hf-inference) provider, OpenAI-compatible endpoints, and practical patterns for semantic search, clustering, and RAG on a budget.

Key capabilities:

MethodReturnsUse Case
feature_extraction(text)np.ndarray (float32)Raw embeddings for vector DBs, clustering, similarity
sentence_similarity(sentence, other_sentences)list[float] (scores)Direct pairwise similarity comparison

Zero-cost: Serverless inference via hf-inference provider is free with a HF token. No GPU needed. See references/hf-learnings.md for full API reference, provider routing details, and advanced patterns.

Quick Start

python
from huggingface_hub import InferenceClient
client = InferenceClient() # uses HF_TOKEN from env
# Single text embedding
embedding = client.feature_extraction("Hello world")
# shape: (sequence_length, hidden_dim)
# Batch embedding
batch = client.feature_extraction(["Hello", "World", "Embed me"])
# shape: (3, sequence_length, hidden_dim)
# Sentence similarity
scores = client.sentence_similarity(
"I love machine learning",
other_sentences=["ML is great", "I hate math", "Deep learning rocks"]
)
# [0.91, 0.12, 0.88]

Best Practices

  1. Specify model explicitly — don't rely on default (currently facebook/bart-base); use BAAI/bge-small-en-v1.5 or sentence-transformers/all-MiniLM-L6-v2 for quality
  2. Pool embeddings — most sentence-transformers output per-token vectors; use mean or cls pooling for sentence-level embeddings
  3. Normalize — set normalize=True for cosine similarity
  4. Batch — pass list[str] to batch efficiently within payload size limits (check model max tokens)
  5. Use `sentence_similarity` instead of manual cosine for direct comparison — it's handled server-side

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
Repository forks
1
7-day trend score
8

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/beer-sakthai/sak-family-agent/sakthai-hf-inference-client-embeddings-patterns/badge)](https://verified-skill.com/skills/beer-sakthai/sak-family-agent/sakthai-hf-inference-client-embeddings-patterns)

Something wrong with this skill or its page? Tell us.