Embeddings
Embeddings turn text into vectors whose distance reflects meaning: the basis of semantic search, retrieval-augmented generation, clustering and deduplication.
API reference: Embeddings
The model
arklabsai/bge-m3 produces 1,024-dimensional vectors for more than 100 languages, Polish and the other EU languages included, from inputs of up to 8,192 tokens. Vectors are L2-normalised, so cosine similarity is a dot product.
Create embeddings
response = client.embeddings.create(
model="arklabsai/bge-m3",
input=[
"Umowa najmu lokalu użytkowego",
"Commercial lease agreement",
"Recipe for pierogi ruskie",
],
)
vectors = [item.embedding for item in response.data]
print(len(vectors), len(vectors[0])) # 3 1024const response = await client.embeddings.create({
model: "arklabsai/bge-m3",
input: ["Umowa najmu lokalu użytkowego", "Commercial lease agreement", "Recipe for pierogi ruskie"],
});
const vectors = response.data.map((d) => d.embedding);curl https://api.ark-labs.cloud/api/v1/embeddings \
-H "Authorization: Bearer $ARK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "arklabsai/bge-m3",
"input": ["Umowa najmu lokalu użytkowego", "Commercial lease agreement"]
}'{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, …] },
{ "object": "embedding", "index": 1, "embedding": [0.0119, -0.0398, …] }
],
"model": "arklabsai/bge-m3",
"usage": { "prompt_tokens": 22, "total_tokens": 22, "credits_used": 1, "credit_balance": 49987 }
}Parameters
Text to embed: one string, a list of up to 2,048 strings, or pre-tokenised input as token ids.
arklabsai/bge-m3.Return shorter vectors. The vector is truncated to this length and re-normalised. At most 1,024.
float (default) or base64: little-endian float32 bytes, about a quarter of the JSON size.Example: semantic search
import numpy as np
docs = ["Faktura VAT musi zawierać NIP sprzedawcy.", "The office is closed on public holidays.", "Invoices must show the seller's tax number."]
doc_vecs = np.array([d.embedding for d in client.embeddings.create(model="arklabsai/bge-m3", input=docs).data])
query = client.embeddings.create(model="arklabsai/bge-m3", input="What must an invoice contain?").data[0].embedding
scores = doc_vecs @ np.array(query) # vectors are normalised: dot product = cosine
for i in scores.argsort()[::-1]:
print(round(float(scores[i]), 3), docs[i])The Polish and English sentences about invoices score close to each other: bge-m3 maps languages into one space, which makes cross-lingual search work without translation.
Limits and usage
- An input longer than 8,192 tokens returns
400"This model's maximum context length is 8192 tokens." Split long documents into chunks. - A batch is processed as one block:
prompt_tokensis the number of inputs times the length of the longest input. Group inputs of similar length to use your credits well. A batch that is too large returns400"Batch too large"; send fewer or shorter inputs per request.