Skip to content

Commit

Permalink
V2 docs (#93)
Browse files Browse the repository at this point in the history
* add v2 docs - first batch

* add v2 docs

* update image paths

* temp remove param types docs

* misc updates

* add models section and update yml

* multi step tool use updates

* Update fern/pages/fine-tuning/chat-fine-tuning/chat-starting-the-training.mdx

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* Update fern/pages/fine-tuning/chat-fine-tuning/chat-starting-the-training.mdx

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* Update fern/pages/v2/models/the-command-family-of-models/command-r.mdx

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* Update fern/pages/v2/text-generation/chat-api.mdx

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* Update fern/pages/v2/text-generation/migrating-v1-to-v2.mdx

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* Update fern/pages/v2/text-generation/migrating-v1-to-v2.mdx

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* clean up migration guide

* update text gen docs

* update command model to latest

* add tool use param types docs

* ft updates

* update tool content to accept string

* update agent getting started nb

* safety mode

* update fern

* upd search query gen and web search for v2

* change RAG documents to top level param

* remove gen->chat migration, misc updates

* embedding types required

* update rag query generation

* chg term - preamble to system message

* update client to use v2 for misc endpoints

* multi step updates

* update getting started tutorials

* update migration guide title

* update migration guide

* Update preview-docs.yml (#143)

Signed-off-by: billytrend-cohere <[email protected]>

* update chat

* Revert "Update preview-docs.yml (#143)" (#144)

This reverts commit abfd2bd.

* update links

* Apply suggestions from code review

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* Apply suggestions from code review

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* chat api updates

* update web search and search query gen migration guide

* fix formatting

* search query gen upd

* add 2 missing pages

* v2 slug change

* Apply suggestions from code review

Co-authored-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>

* migration guide - simplify chat history

* update links to point to v2

* update RAG responses

* update streaming docs

* update deployment options and misc

* deployment options edits

* v1 usage notes

* fix formatting

* update meta desc

* update meta desc

* updates on tool use structure and migration guide, + misc

* make v2 default

* fix links

---------

Signed-off-by: Michael <[email protected]>
Signed-off-by: Meor Amer <[email protected]>
Signed-off-by: billytrend-cohere <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: billytrend-cohere <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 9d7e0b6 commit 5a419f4
Show file tree
Hide file tree
Showing 55 changed files with 10,057 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ create_response = co.finetuning.create_finetuned_model(
)
```

## Calling your Chat Model with co.chat()
## Calling your Chat Model with the Chat API

Once your model completes training, you can call it via [co.chat()](/docs/chat-api) and pass your custom model's `model_id`.
Once your model completes training, you can call it via the [Chat API](/docs/chat-api) and pass your custom model's ID via the `model` parameter.

Please note, the `model_id` is the `id` returned by the fine-tuned model object with the `"-ft"` suffix.

Expand Down
92 changes: 92 additions & 0 deletions fern/pages/v2/deployment-options/cohere-on-aws/amazon-bedrock.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
title: Amazon Bedrock
slug: v2/docs/amazon-bedrock
hidden: false
description: >-
This document provides a guide for using Cohere's models on Amazon Bedrock.
image: ../../../../assets/images/8dbcb80-cohere_meta_image.jpg
keywords: 'Cohere on AWS, language models on AWS, Amazon Bedrock, Amazon SageMaker'
createdAt: 'Thu Feb 01 2024 18:08:37 GMT+0000 (Coordinated Universal Time)'
updatedAt: 'Thu May 30 2024 16:00:53 GMT+0000 (Coordinated Universal Time)'
---
<Info title="Note">
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.
</Info>
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:

- Command R
- Command R+
- Command Light
- Command
- Embed - English
- Embed - Multilingual

## Prerequisites

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).
- You'll also need to install the AWS Python SDK and some related tooling. Run:
- `pip install cohere-aws` (or `pip install --upgrade cohere-aws` if you need to upgrade). You can also install from source with `python setup.py install`.
- For more details, see this [GitHub repo](https://github.com/cohere-ai/cohere-aws/) and [related notebooks](https://github.com/cohere-ai/cohere-aws/tree/main/notebooks/bedrock).
- Finally, you'll 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:

```python PYTHON
import cohere

co = cohere.BedrockClient(
aws_region="us-east-1",
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)

print(result)
```

## Text Generation

You can use this code to invoke either Command R (`cohere.command-r-v1:0`), Command R+ (`cohere.command-r-plus-v1:0`), Command (`cohere.command-text-v14`), or Command light (`cohere.command-light-text-v14`) on Amazon Bedrock:

```python PYTHON
import cohere

co = cohere.BedrockClient(
aws_region="us-east-1",
aws_access_key="...",
aws_secret_key="...",
aws_session_token="...",
)

result = co.chat(message="Write a LinkedIn post about starting a career in tech:",
model='cohere.command-r-plus-v1:0' # or 'cohere.command-r-v1:0'
)

print(result)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
title: "Amazon SageMaker"
slug: "v2/docs/amazon-sagemaker-setup-guide"

hidden: false
description: "This document will guide you through enabling development teams to access Cohere’s offerings on Amazon SageMaker."
image: "../../../../assets/images/6330341-cohere_meta_image.jpg"
keywords: "Amazon SageMaker, Generative AI on AWS"

createdAt: "Wed Jun 28 2023 14:29:11 GMT+0000 (Coordinated Universal Time)"
updatedAt: "Thu May 30 2024 16:01:40 GMT+0000 (Coordinated Universal Time)"
---
<Info title="Note">
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.
</Info>
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.

This document will guide you through enabling development teams to access [Cohere’s offerings on Amazon SageMaker](https://aws.amazon.com/marketplace/seller-profile?id=87af0c85-6cf9-4ed8-bee0-b40ce65167e0).

## Prerequisites

In order to successfully subscribe to Cohere’s offerings on Amazon SageMaker, the user will need the following **Identity and Access Management (IAM)** permissions:

- **AmazonSageMakerFullAccess**
- **aws-marketplace:ViewSubscriptions**
- **aws-marketplace:Subscribe**
- **aws-marketplace:Unsubscribe**

These permissions allow a user to manage your organization’s Amazon SageMaker subscriptions. Learn more about [managing Amazon’s IAM Permissions here](https://aws.amazon.com/iam/?trk=cf28fddb-12ed-4ffd-981b-b89c14793bf1&sc_channel=ps&ef_id=CjwKCAjwsvujBhAXEiwA_UXnAJ4JEQ3KgW0eFBzr5nuwt9L5S7w3A0f3wqensQJgUQ7Mf_ZEdArZRxoCjKQQAvD_BwE:G:s&s_kwcid=AL!4422!3!652240143562!e!!g!!amazon%20iam!19878797467!148973348604). Contact your AWS administrator if you have questions about account permissions.

You'll also need to install the AWS Python SDK and some related tooling. Run:

- `pip install cohere-aws` (or `pip install --upgrade cohere-aws` if you want to upgrade to the most recent version of the SDK).

## Cohere with Amazon SageMaker Setup

First, navigate to [Cohere’s SageMaker Marketplace](https://aws.amazon.com/marketplace/seller-profile?id=87af0c85-6cf9-4ed8-bee0-b40ce65167e0) to view the available product offerings. Select the product offering to which you are interested in subscribing.

Next, explore the tools on the **Product Detail** page to evaluate how you want to configure your subscription. It contains information related to:

- Pricing: This section allows you to estimate the cost of running inference on different types of instances.
- Usage: This section contains the technical details around supported data formats for each model, and offers links to documentation and notebooks that will help developers scope out the effort required to integrate with Cohere’s models.
- Subscribing: This section will once again present you with both the pricing details and the EULA for final review before you accept the offer. This information is identical to the information on Product Detail page.
- Configuration: The primary goal of this section is to retrieve the [Amazon Resource Name (ARN)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html) for the product you have subscribed to.

## Embeddings

You can use this code to invoke Cohere's embed model on Amazon SageMaker:

```python PYTHON
import cohere

co = cohere.SageMakerClient(
aws_region="us-east-1",
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 = "<YOUR ENDPOINT NAME>" # On SageMaker, you create a model name that you'll pass here.


# Invoke the model and print the response
result = co.embed(
model=model_id,
input_type=input_type,
texts=texts,
truncate=truncate)

print(result)
```

## Text Generation

You can use this code to invoke Cohere's Command models on Amazon SageMaker:

```python PYTHON
import cohere

co = cohere.SageMakerClient(
aws_region="us-east-1",
aws_access_key="...",
aws_secret_key="...",
aws_session_token="...",
)

# Invoke the model and print the response
result = co.chat(message="Write a LinkedIn post about starting a career in tech:",
model="<YOUR ENDPOINT NAME>") # On SageMaker, you create a model name that you'll pass here.

print(result)
```

## Next Steps

With your selected configuration and Product ARN available, you now have everything you need to integrate with Cohere’s model offerings on SageMaker.

Cohere recommends your next step be to find the appropriate notebook in [Cohere's list of Amazon SageMaker notebooks](https://github.com/cohere-ai/cohere-aws/tree/main/notebooks/sagemaker), and follow the instructions there, or provide the link to Cohere’s SageMaker notebooks to your development team to implement. The notebooks are thorough, developer-centric guides that will enable your team to begin leveraging Cohere’s endpoints in production for live inference.

If you have further questions about subscribing or configuring Cohere’s product offerings on Amazon SageMaker, please contact our team at [[email protected]](mailto:[email protected]).
Loading

0 comments on commit 5a419f4

Please sign in to comment.