diff --git a/fern/pages/deployment-options/cohere-on-aws/amazon-bedrock.mdx b/fern/pages/deployment-options/cohere-on-aws/amazon-bedrock.mdx index be5418e63..99c7af2c8 100644 --- a/fern/pages/deployment-options/cohere-on-aws/amazon-bedrock.mdx +++ b/fern/pages/deployment-options/cohere-on-aws/amazon-bedrock.mdx @@ -27,48 +27,40 @@ Note that the code snippets below are in Python, but you can find the equivalent Here are the steps you'll need to get set up in advance of running Cohere models on Amazon Bedrock. -- Subscribe to Cohere's models on Amazon Bedrock. For more details, [see here](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html). +- Subscribe to Cohere's models on Amazon Bedrock. [Check here](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) for more details. +- You may need to pip install `cohere`, `boto3`, and `botocore`. - You'll also have to configure your authentication credentials for AWS. This [document](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#configuration) has more information. ## Embeddings -You can use this code to invoke Cohere’s Embed English v3 model (`cohere.embed-english-v3`) or Embed Multilingual v3 model (`cohere.embed-multilingual-v3`) on Amazon Bedrock: +You can use this code to invoke Cohere’s Embed English v3 model (`embed-english-v3`) on Amazon Bedrock: ```python PYTHON import cohere -co = cohere.BedrockClient( - aws_region="us-east-1", +co = cohere.BedrockClientV2( + aws_region="...", aws_access_key="...", aws_secret_key="...", aws_session_token="...", ) -# Input parameters for embed. In this example we are embedding hacker news post titles. -texts = [ - "Interesting (Non software) books?", - "Non-tech books that have helped you grow professionally?", - "I sold my company last month for $5m. What do I do with the money?", - "How are you getting through (and back from) burning out?", - "I made $24k over the last month. Now what?", - "What kind of personal financial investment do you do?", - "Should I quit the field of software development?", -] -input_type = "clustering" -truncate = "NONE" # optional -model_id = ( - "cohere.embed-english-v3" # or "cohere.embed-multilingual-v3" -) - -# Invoke the model and print the response result = co.embed( - model=model_id, - input_type=input_type, - texts=texts, - truncate=truncate, -) # aws_client.invoke_model(**params) + model="cohere.embed-english-v3", + input_type="clustering", + embedding_types=["float"], + texts=[ + "Interesting (Non software) books?", + "Non-tech books that have helped you grow professionally?", + "I sold my company last month for $5m. What do I do with the money?", + "How are you getting through (and back from) burning out?", + "I made $24k over the last month. Now what?", + "What kind of personal financial investment do you do?", + "Should I quit the field of software development?", + ], +) -print(result) +print(result.embeddings.float) ``` Note that we've released multimodal embeddings models that are able to handle images in addition to text. Find [more information here](https://docs.cohere.com/docs/multimodal-embeddings). diff --git a/fern/pages/deployment-options/cohere-on-aws/amazon-sagemaker-setup-guide.mdx b/fern/pages/deployment-options/cohere-on-aws/amazon-sagemaker-setup-guide.mdx index 7e076fe04..c5996e1e8 100644 --- a/fern/pages/deployment-options/cohere-on-aws/amazon-sagemaker-setup-guide.mdx +++ b/fern/pages/deployment-options/cohere-on-aws/amazon-sagemaker-setup-guide.mdx @@ -77,6 +77,7 @@ result = co.embed( print(result) ``` + Cohere's embed models don't support batch transform operations. Note that we've released multimodal embeddings models that are able to handle images in addition to text. Find [more information here](https://docs.cohere.com/docs/multimodal-embeddings). diff --git a/fern/pages/v2/deployment-options/cohere-on-aws/amazon-bedrock.mdx b/fern/pages/v2/deployment-options/cohere-on-aws/amazon-bedrock.mdx index 985c82afc..db3e93d8e 100644 --- a/fern/pages/v2/deployment-options/cohere-on-aws/amazon-bedrock.mdx +++ b/fern/pages/v2/deployment-options/cohere-on-aws/amazon-bedrock.mdx @@ -12,6 +12,7 @@ updatedAt: 'Thu May 30 2024 16:00:53 GMT+0000 (Coordinated Universal Time)' The code examples in this section use the Cohere v1 API. The v2 API is not yet supported for cloud deployments and will be coming soon. + In an effort to make our language-model capabilities more widely available, we've partnered with a few major platforms to create hosted versions of our offerings. Here, you'll learn how to use Amazon Bedrock to deploy both the Cohere Command and the Cohere Embed models on the AWS cloud computing platform. The following models are available on Bedrock: @@ -29,51 +30,40 @@ Note that the code snippets below are in Python, but you can find the equivalent Here are the steps you'll need to get set up in advance of running Cohere models on Amazon Bedrock. -- Subscribe to Cohere's models on Amazon Bedrock. For more details, [see here](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html). +- Subscribe to Cohere's models on Amazon Bedrock. [Check here](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) for more details. +- You may need to pip install `cohere`, `boto3`, and `botocore`. - You'll also have to configure your authentication credentials for AWS. This [document](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#configuration) has more information. ## Embeddings -## Embeddings - You can use this code to invoke Cohere’s Embed English v3 model (`cohere.embed-english-v3`) or Embed Multilingual v3 model (`cohere.embed-multilingual-v3`) on Amazon Bedrock: ```python PYTHON import cohere -co = cohere.BedrockClient( - aws_region="us-east-1", +co = cohere.BedrockClientV2( + aws_region="...", aws_access_key="...", aws_secret_key="...", aws_session_token="...", ) -# Input parameters for embed. In this example we are embedding hacker news post titles. -texts = [ - "Interesting (Non software) books?", - "Non-tech books that have helped you grow professionally?", - "I sold my company last month for $5m. What do I do with the money?", - "How are you getting through (and back from) burning out?", - "I made $24k over the last month. Now what?", - "What kind of personal financial investment do you do?", - "Should I quit the field of software development?", -] -input_type = "clustering" -truncate = "NONE" # optional -model_id = ( - "cohere.embed-english-v3" # or "cohere.embed-multilingual-v3" -) - - -# Invoke the model and print the response result = co.embed( - model=model_id, - input_type=input_type, - texts=texts, - truncate=truncate, -) # aws_client.invoke_model(**params) + model="cohere.embed-english-v3", + input_type="clustering", + embedding_types=["float"], + texts=[ + "Interesting (Non software) books?", + "Non-tech books that have helped you grow professionally?", + "I sold my company last month for $5m. What do I do with the money?", + "How are you getting through (and back from) burning out?", + "I made $24k over the last month. Now what?", + "What kind of personal financial investment do you do?", + "Should I quit the field of software development?", + ], +) -print(result) +print(result.embeddings.float) ``` Note that we've released multimodal embeddings models that are able to handle images in addition to text. Find [more information here](https://docs.cohere.com/docs/multimodal-embeddings). @@ -108,7 +98,7 @@ You can use this code to invoke our latest Rerank models on Bedrock import cohere co = cohere.BedrockClientV2( - aws_region="us-west-2", # pick a region where the model is available + aws_region="...", aws_access_key="...", aws_secret_key="...", aws_session_token="...", @@ -121,13 +111,11 @@ docs = [ "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", ] - response = co.rerank( model="cohere.rerank-v3-5:0", query="What is the capital of the United States?", documents=docs, top_n=3, ) - print(response) ```