Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Cohere ai Cohere python EmbedByTypeResponseEmbeddings Model

From Leeroopedia
Knowledge Sources
Domains SDK, Embeddings
Last Updated 2026-02-15 14:00 GMT

Overview

EmbedByTypeResponseEmbeddings is a Pydantic model containing embedding arrays in multiple numeric formats (float, int8, uint8, binary, ubinary, base64), used as the embeddings container within EmbedByTypeResponse.

Description

The EmbedByTypeResponseEmbeddings class holds the actual embedding vectors returned by the Cohere Embed API when multiple embedding types are requested. Each field corresponds to a different numeric representation:

  • float_ (aliased from float): Standard float embeddings as List[List[float]]
  • int8: Signed 8-bit integer embeddings with values between -128 and 127
  • uint8: Unsigned 8-bit integer embeddings with values between 0 and 255
  • binary: Packed signed binary embeddings at 1/8 the length of float embeddings, values between -128 and 127
  • ubinary: Packed unsigned binary embeddings at 1/8 the length of float embeddings, values between 0 and 255
  • base64: Base64-encoded string representations of float embedding bytes

The length of each embedding type array matches the number of input texts or images provided. Only the embedding types that were requested in the API call will be populated; the rest will be None.

The class extends UncheckedBaseModel and is auto-generated by the Fern API definition toolchain.

Usage

Use EmbedByTypeResponseEmbeddings when accessing the embeddings from an EmbedByTypeResponse. The quantized formats (int8, uint8, binary, ubinary) are useful for reducing storage requirements and improving retrieval performance, while base64 is convenient for serialization.

Code Reference

Source Location

  • Repository: Cohere Python SDK
  • File: src/cohere/types/embed_by_type_response_embeddings.py

Signature

class EmbedByTypeResponseEmbeddings(UncheckedBaseModel):
    float_: typing.Optional[typing.List[typing.List[float]]] = None  # aliased from "float"
    int8: typing.Optional[typing.List[typing.List[int]]] = None
    uint8: typing.Optional[typing.List[typing.List[int]]] = None
    binary: typing.Optional[typing.List[typing.List[int]]] = None
    ubinary: typing.Optional[typing.List[typing.List[int]]] = None
    base64: typing.Optional[typing.List[str]] = None

Import

from cohere.types import EmbedByTypeResponseEmbeddings

I/O Contract

Fields

Field Type Required Default Description
float_ Optional[List[List[float]]] No None An array of float embeddings (Python attribute aliased from float)
int8 Optional[List[List[int]]] No None An array of signed int8 embeddings; each value is between -128 and 127
uint8 Optional[List[List[int]]] No None An array of unsigned int8 embeddings; each value is between 0 and 255
binary Optional[List[List[int]]] No None Packed signed binary embeddings at 1/8 the float embedding length; values between -128 and 127
ubinary Optional[List[List[int]]] No None Packed unsigned binary embeddings at 1/8 the float embedding length; values between 0 and 255
base64 Optional[List[str]] No None Base64-encoded string representations of float embedding bytes

Usage Examples

Accessing Different Embedding Types

import cohere

co = cohere.Client()

response = co.embed(
    texts=["Hello world", "Cohere embeddings are great"],
    model="embed-english-v3.0",
    input_type="search_document",
    embedding_types=["float", "int8", "binary"],
)

embeddings = response.embeddings

# Access float embeddings (note the trailing underscore due to Python keyword conflict)
if embeddings.float_:
    print(f"Number of float embeddings: {len(embeddings.float_)}")
    print(f"Float embedding dimension: {len(embeddings.float_[0])}")

# Access int8 embeddings for compact storage
if embeddings.int8:
    print(f"Int8 embedding dimension: {len(embeddings.int8[0])}")
    print(f"Int8 value range sample: min={min(embeddings.int8[0])}, max={max(embeddings.int8[0])}")

# Access binary embeddings (1/8 the float dimension)
if embeddings.binary:
    print(f"Binary embedding dimension: {len(embeddings.binary[0])}")

Using Base64 Embeddings for Serialization

import cohere
import json

co = cohere.Client()

response = co.embed(
    texts=["Serialize this embedding"],
    model="embed-english-v3.0",
    input_type="search_document",
    embedding_types=["base64"],
)

if response.embeddings.base64:
    # Base64 strings are convenient for JSON serialization
    payload = json.dumps({"embedding": response.embeddings.base64[0]})
    print(f"Serialized embedding length: {len(payload)} characters")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment