An embedding is a vectorized numerical representation of data, where the relatedness between different pieces of information is captured through measurable distances. These embeddings are commonly used in applications such as recommendation systems, classification, and search.

The Mistral embedding model powers our system, providing high-quality vector representations for various applications.

For setup and integration:

  1. Get an API key from SambaNova Cloud portal.
  2. Review sample implementations in the documentation.
  3. Generate embeddings using provided examples.
  4. Integrate embeddings into your application workflows.

For a detailed breakdown of available parameters, see the Embedding endpoint API document.

Generating embeddings

The SambaNova Embeddings API is designed for seamless integration with existing applications and follows OpenAI’s embeddings API structure, simplifying migration and adoption.

The model takes in text as input and outputs a vector of floating-point numbers, which can be used for tasks like similarity searches.

Generating a single embedding

To generate an embedding for a single input text, use client.embeddings.create() with the model name and input string.

Example

import openai

client = openai.OpenAI(
    base_url="https://api.sambanova.ai/v1",
    api_key="<your-api-key>",
)

response = client.embeddings.create(
    model="E5-Mistral-7B-Instruct",
    input="The quick brown fox jumps over the lazy dog"
)

print(response)

Example response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [0.002843, -0.017531, ..., 0.012934],
      "index": 0
    }
  ],
  "model": "E5-Mistral-7B-Instruct",
  "usage": {
    "prompt_tokens": 10,
    "total_tokens": 10
  }
}

Generating multiple embeddings

To generate embeddings for multiple inputs in a single request, pass an array of input strings to the input parameter.

Example

import openai

client = openai.OpenAI(
    base_url="https://api.sambanova.ai/v1",
    api_key="<your-api-key>",
)

response = client.embeddings.create(
    model="E5-Mistral-7B-Instruct",
    input=[
        "Our solar system orbits the Milky Way galaxy at about 515,000 mph",
        "Jupiter's Great Red Spot is a storm that has been raging for at least 350 years."
    ]
)

print(response)

Example response

{
  "model": "E5-Mistral-7B-Instruct",
  "object": "list",
  "data": [
    {
      "index": 0,
      "object": "embedding",
      "embedding": [0.2633975, 0.13856208, ..., 0.04331574]
    },
    {
      "index": 1,
      "object": "embedding",
      "embedding": [-0.14496337, 0.21044481, ..., -0.16187587]
    }
  ]
}