Feature Extraction
sentence-transformers
Safetensors
English
multilingual
qwen3
text-embeddings-inference
infinity
Instructions to use michaelfeil/zembed-1-infinity with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use michaelfeil/zembed-1-infinity with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("michaelfeil/zembed-1-infinity") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
File size: 1,130 Bytes
ad82189 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | """Supply zembed's saved prompt and terminal suffix to Infinity's /embed API."""
import json
import urllib.error
import urllib.request
def embed(texts, kind="document", base_url="http://localhost:7997", model="michaelfeil/zembed-1-infinity"):
if isinstance(texts, str):
texts = [texts]
texts = list(texts)
if kind not in ("query", "document") or not texts or any(not isinstance(text, str) for text in texts):
raise ValueError("Provide text strings and kind='query' or kind='document'")
body = {
"model": model,
"inputs": [text + "<|im_end|>\n" for text in texts],
"prompt_name": kind,
"normalize": True,
"truncate": False,
}
request = urllib.request.Request(
base_url.rstrip("/") + "/embed",
data=json.dumps(body).encode(),
headers={"Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(request, timeout=300) as response:
return json.load(response)
except urllib.error.HTTPError as error:
raise RuntimeError(f"HTTP {error.code}: {error.read().decode()}") from error
|