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 AwsEmbeddings

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

Overview

Defines data structures for vector embeddings returned from Cohere embedding models deployed on AWS infrastructure.

Description

The AwsEmbeddings module provides the Embedding and Embeddings classes that wrap numerical vector representations returned by Cohere embedding models running on AWS SageMaker or Amazon Bedrock. The Embedding class holds a single float vector and supports iteration and length queries, while the Embeddings container class holds a collection of Embedding objects with the same iterable interface. Both classes inherit from CohereObject for consistent string representation.

Usage

Use these classes when processing embedding vectors returned from Cohere embedding models deployed on AWS. They are typically instantiated internally by the AWS client after invoking an embed endpoint and are not usually constructed directly by end users.

Code Reference

Source Location

  • Repository: Cohere Python SDK
  • File: src/cohere/manually_maintained/cohere_aws/embeddings.py

Signature

class Embedding(CohereObject):
    def __init__(self, embedding: List[float]) -> None: ...
    def __iter__(self) -> Iterator: ...
    def __len__(self) -> int: ...

class Embeddings(CohereObject):
    def __init__(self, embeddings: List[Embedding]) -> None: ...
    def __iter__(self) -> Iterator: ...
    def __len__(self) -> int: ...

Import

from cohere.manually_maintained.cohere_aws.embeddings import Embedding, Embeddings

I/O Contract

Embedding

Parameter Type Description
embedding List[float] A list of floating-point numbers representing a single vector embedding.
Method Return Type Description
__iter__() Iterator Iterates over the individual float values in the embedding vector.
__len__() int Returns the dimensionality (number of elements) of the embedding vector.

Embeddings

Parameter Type Description
embeddings List[Embedding] A list of Embedding objects representing multiple vector embeddings.
Method Return Type Description
__iter__() Iterator Iterates over the contained Embedding objects.
__len__() int Returns the number of embeddings in the collection.

Usage Examples

from cohere.manually_maintained.cohere_aws.embeddings import Embedding, Embeddings

# Create individual embeddings
emb1 = Embedding([0.1, 0.2, 0.3, 0.4])
emb2 = Embedding([0.5, 0.6, 0.7, 0.8])

# Query single embedding properties
print(len(emb1))          # 4 (vector dimensionality)
for val in emb1:
    print(val)             # 0.1, 0.2, 0.3, 0.4

# Create a collection of embeddings
batch = Embeddings([emb1, emb2])
print(len(batch))          # 2 (number of embeddings)

# Iterate over all embeddings in the batch
for embedding in batch:
    print(list(embedding))  # [0.1, 0.2, 0.3, 0.4], then [0.5, 0.6, 0.7, 0.8]

Related Pages

Page Connections

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