Edit model card

Sionic AI Embedding API v1

About Sionic AI

Sionic AI delivers more accessible and cost-effective AI technology addressing the various needs to boost productivity and drive innovation.

The Large Language Model (LLM) is not for research and experimentation. We offer solutions that leverage LLM to add value to your business. Anyone can easily train and control AI.

How to get embeddings

Currently, we open the beta version of embedding APIs. To get embeddings, you should call API endpoint to send your text. You can send either a single sentence or multiple sentences. The embeddings that correspond to the inputs will be returned.

API Endpoint : https://api.sionic.ai/v1/embedding

Command line Example

Request:

curl https://api.sionic.ai/v1/embedding \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": ["first query", "second query", "third query"]
  }'

Response:

{
    "embedding": [
        [
            0.1380517,
            0.0749767,
            -0.0600897,
            0.6106221,
            -0.3284067,
            ...
        ],
        [
            -0.0237823,
            -0.103611, 
            -0.0491666, 
            0.671397, 
            -0.8827474, 
            ...
        ],
        [
            0.0137392,
            -0.1101281,
            -0.2256125,
            0.7899137,
            -0.8847492,
            ...
        ]
    ]
}

Python code Example

Get embeddings by directly calling Sionic's embedding API.

from typing import List
import numpy as np
import requests

def get_embedding(queries: List[str], url):
    response = requests.post(url=url, json={'inputs': queries})
    return np.asarray(response.json()['embedding'], dtype=np.float32)

url = "https://api.sionic.ai/v1/embedding"
inputs1 = ["first query", "second query"]
inputs2 = ["third query", "fourth query"]
embedding1 = get_embedding(inputs1, url=url)
embedding2 = get_embedding(inputs2, url=url)
cos_similarity = (embedding1 / np.linalg.norm(embedding1)) @ (embedding2 / np.linalg.norm(embedding1)).T
print(cos_similarity)

Using pre-defined SionicEmbeddingModel to obtain embeddings.

from model_api import SionicEmbeddingModel
import numpy as np

inputs1 = ["first query", "second query"]
inputs2 = ["third query", "fourth query"]
model = SionicEmbeddingModel(url="https://api.sionic.ai/v1/embedding",
                             dimension=2048)
embedding1 = model.encode(inputs1)
embedding2 = model.encode(inputs2)
cos_similarity = (embedding1 / np.linalg.norm(embedding1)) @ (embedding2 / np.linalg.norm(embedding1)).T
print(cos_similarity)

We apply the instruction to encode short queries for retrieval tasks. By using encode_queries(), you can use the instruction to encode queries which is prefixed to each query as the following example. The recommended instruction for both v1 and v2 models is "query: ".

from model_api import SionicEmbeddingModel
import numpy as np

query = ["first query", "second query"]
passage = ["This is a passage related to the first query", "This is a passage related to the second query"]
model = SionicEmbeddingModel(url="https://api.sionic.ai/v1/embedding",
                             instruction="query: ",
                             dimension=2048)
query_embedding = model.encode_queries(query)
passage_embedding = model.encode_corpus(passage)
cos_similarity = (query_embedding / np.linalg.norm(query_embedding)) @ (passage_embedding / np.linalg.norm(passage_embedding)).T
print(cos_similarity)

Massive Text Embedding Benchmark (MTEB) Evaluation

Both versions of Sionic AI's embedding show the state-of-the-art performances on the MTEB! You can find a code to evaluate MTEB datasets here.

Model Name Dimension Sequence Length Average (56)
sionic-ai/sionic-ai-v2 3072 512 65.23
sionic-ai/sionic-ai-v1 2048 512 64.92
bge-large-en-v1.5 1024 512 64.23
gte-large-en 1024 512 63.13
text-embedding-ada-002 1536 8191 60.99
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Spaces using sionic-ai/sionic-ai-v1 3

Evaluation results