Skip to content

Commit

Permalink
Merge branch 'main' into billytrend-cohere-patch-6
Browse files Browse the repository at this point in the history
  • Loading branch information
billytrend-cohere authored Dec 16, 2024
2 parents 4cc3b67 + e239a4f commit b2ab348
Show file tree
Hide file tree
Showing 60 changed files with 1,417 additions and 413 deletions.
110 changes: 49 additions & 61 deletions cohere-openapi.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ redirects:
destination: "/docs/overview-rag-connectors"
permanent: true
- source: "/docs/reranking"
destination: "/docs/overview"
destination: "/docs/rerank-overview"
permanent: true
- source: "/reference/rerank-1"
destination: "/reference/rerank"
Expand Down
37 changes: 37 additions & 0 deletions fern/pages/changelog/2024-12-02-Rerank-v3.5-is-released.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "Announcing Rerank-v3.5"
slug: "changelog/rerank-v3.5"
createdAt: "Mon Dec 2 2024 00:00:00 (MST)"
hidden: false
description: >-
Release announcment for Rerank 3.5 - our new state of the art model for ranking.
---

We're pleased to announce the release of [Rerank 3.5](/docs/rerank-2) our newest and most performant foundational model for ranking. Rerank 3.5 has a context length of 4096, SOTA performance on Multilingual Retrieval tasks and Reasoning Capabilities. In addition, Rerank 3.5 has SOTA performance on BEIR and domains such as Finance, E-commerce, Hospitality, Project Management, and Email/Messaging Retrieval tasks.

In the rest of these release notes, we’ll provide more details about changes to the api.

## Technical Details

### API Changes:

Along with the model, we are releasing V2 of the Rerank API. It includes the following major changes:
- `model` is now a required parameter
- `max_chunks_per_doc` has been replaced by `max_tokens_per_doc`; `max_tokens_per_doc` will determine the maximum amount of tokens a document can have before truncation. The default value for `max_tokens_per_doc` is 4096.
- support for passing a list of objects for the `documents` parameter has been removed - if your documents contain structured data, for best performance we recommend formatting them as [YAML strings](/docs/rerank-overview#example-with-structured-data).

Example request

```Text cURL
POST https://api.cohere.ai/v2/rerank
{
"model": "rerank-v3.5",
"query": "What is the capital of the United States?",
"top_n": 3,
"documents": ["Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"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.",
"Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
"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."]
}
```
12 changes: 12 additions & 0 deletions fern/pages/changelog/2024-12-13-command-r-7b-is-here.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "Announcing Command R7b"
slug: "changelog/command-r-7b"
createdAt: "Fri Dec 13 2024 00:00:00 (MST)"
hidden: false
description: >-
Release announcment for Command R 7B - our fastest, lightest, and last Command R model.
---

We're thrilled to announce the release of Command R7B, the smallest, fastest, and final model in our R family of enterprise-focused [large language models](https://docs.cohere.com/docs/introduction-to-large-language-models) (LLMs). With a context window of 128K, Command R7B offers state-of-the-art performance across a variety of real-world tasks, and is designed for use cases in which speed, cost, and compute are important. Specifically, Command R7B is excellent for [retrieval-augmented generation](https://docs.cohere.com/docs/retrieval-augmented-generation-rag), [tool use](https://docs.cohere.com/docs/tool-use), and [agentic applications](https://docs.cohere.com/docs/multi-step-tool-use) where complex reasoning, multiple actions, and information-seeking are important for success.

Command R7B is available today on the [Cohere Platform](https://docs.cohere.com/docs/the-cohere-platform) as well as accessible on HuggingFace, or you can access it in the SDK with `command-r7b-12-2024`. For more information, check out our [dedicated blog post](cohere.com/blog/command-r7b).
8 changes: 4 additions & 4 deletions fern/pages/cookbooks/rerank-demo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Demo of Rerank
slug: /page/rerank-demo

description: "This page contains a basic tutorial on how Cohere's ReRank models work and how to use them."
image: "../../assets/images/f1cc130-cohere_meta_image.jpg"
image: "../../assets/images/f1cc130-cohere_meta_image.jpg"
keywords: "Cohere, ReRank"
---

Expand Down Expand Up @@ -70,7 +70,7 @@ docs = [
"Charlotte Amalie is the capital and largest city of the United States Virgin Islands. It has about 20,000 people. The city is on the island of Saint Thomas.",
"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. The President of the USA and many major national government offices are in the territory. This makes it the political center of the United States of America.",
"West Virginia is a state in the Appalachian region of the United States. Its capital and largest city is Charleston. It is often abbreviated W. Va. or simply WV.",
"Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment.",
"Capital punishment has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment.",
"North Dakota is a state in the United States. 672,591 people lived in North Dakota in the year 2010. The capital and seat of government is Bismarck.",
"Kentucky is a state in the United States. Its capital is Frankfort. It touches the states of Missouri (by the Mississippi River), Illinois, Indiana, Ohio, West Virginia (by the Ohio River), Tennessee and Virginia. There are many rivers in Kentucky",
"Micronesia, officially the Federated States of Micronesia, is an island nation in the Pacific Ocean, northeast of Papua New Guinea. The country is a sovereign state in free association with the United States. The capital city of Federated States of Micronesia is Palikir.",
Expand All @@ -97,7 +97,7 @@ Relevance Score: 1.00
Document Rank: 2, Document Index: 5
Document: Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment.
Document: Capital punishment has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment.
Relevance Score: 0.75
Expand Down Expand Up @@ -246,7 +246,7 @@ search(query = "What is the capital of the United States?")
```txt title="Output"
Input question: What is the capital of the United States?
Top-3 lexical search (BM25) hits
16.264 Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment.
16.264 Capital punishment has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states. The federal government (including the United States military) also uses capital punishment.
15.124 In 1783, it was the capital of the United States for a few months.
14.476 New York was the capital of the United States under the Articles of Confederation from 1785 to 1788. When the US Constitution was made, it stayed as the capital from 1789 until 1790. In 1789, the first President of the United States, George Washington, was inaugurated; the first United States Congress and the Supreme Court of the United States each met for the first time, and the United States Bill of Rights was written, all at Federal Hall on Wall Street. By 1790, New York grew bigger than Philadelphia, so it become the biggest city in the United States. By the end of 1790, because of the Residence Act, Philadelphia became the new capital.
Expand Down
99 changes: 94 additions & 5 deletions fern/pages/deployment-options/cohere-on-microsoft-azure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ updatedAt: "Wed May 01 2024 16:11:36 GMT+0000 (Coordinated Universal Time)"
---
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.

In this article, you learn how to use [Azure AI Studio](https://ai.azure.com/) to deploy both the Cohere Command models and the Cohere Embed models on Microsoft's Azure cloud computing platform.
In this article, you learn how to use [Azure AI Foundry](https://ai.azure.com/) to deploy both the Cohere Command models and the Cohere Embed models on Microsoft's Azure cloud computing platform. You can read more about Azure AI Foundry in its documentation[here](https://learn.microsoft.com/en-us/azure/ai-studio/what-is-ai-studio).

The following six models are available through Azure AI Studio with pay-as-you-go, token-based billing:

Expand All @@ -22,7 +22,7 @@ The following six models are available through Azure AI Studio with pay-as-you-g
- Embed v3 - English
- Embed v3 - Multilingual
- Cohere Rerank V3 (English)
- Cohere Rerank V3 (multilingual)
- Cohere Rerank V3 (Multilingual)

## Prerequisites

Expand Down Expand Up @@ -140,7 +140,7 @@ except urllib.error.HTTPError as error:
print(error.read().decode("utf8", "ignore"))
```

## ReRank
## Rerank

We currently exposes the `v1/rerank` endpoint for inference with both Rerank 3 - English and Rerank 3 - Multilingual. For more information on using the APIs, see the [reference](https://learn.microsoft.com/en-us/azure/ai-studio/how-to/deploy-models-cohere-rerank#rerank-api-reference-for-cohere-rerank-models-deployed-as-a-service) section.

Expand Down Expand Up @@ -199,8 +199,97 @@ response = co.rerank(
)
```

## A Note on SDKs
## Using the Cohere SDK

You should be aware that it's possible to use the cohere SDK client to consume Azure AI deployments. Here are example notes for [Command](https://github.com/Azure/azureml-examples/blob/main/sdk/python/foundation-models/cohere/cohere-cmdR.ipynb) and [Embed](https://github.com/Azure/azureml-examples/blob/main/sdk/python/foundation-models/cohere/cohere-embed.ipynb).
You can use the Cohere SDK client to consume Cohere models that are deployed via Azure AI Foundry. This means you can leverage the SDK's features such as RAG, tool use, structured outputs, and more.

The following are a few examples on how to use the SDK for the different models.

### Setup
```python PYTHON
# pip install cohere

import cohere

# For Command models
co_chat = cohere.Client(
api_key="AZURE_INFERENCE_CREDENTIAL",
base_url="AZURE_MODEL_ENDPOINT", # Example - https://Cohere-command-r-plus-08-2024-xyz.eastus.models.ai.azure.com/
)

# For Embed models
co_embed = cohere.Client(
api_key="AZURE_INFERENCE_CREDENTIAL",
base_url="AZURE_MODEL_ENDPOINT", # Example - hhttps://cohere-embed-v3-multilingual-xyz.eastus.models.ai.azure.com/
)

# For Rerank models
co_rerank = cohere.Client(
api_key="AZURE_INFERENCE_CREDENTIAL",
base_url="AZURE_MODEL_ENDPOINT", # Example - hhttps://cohere-rerank-v3-multilingual-xyz.eastus.models.ai.azure.com/
)
```

### Chat
```python PYTHON
message = "I'm joining a new startup called Co1t today. Could you help me write a short introduction message to my teammates."

response = co_chat.chat(message=message)

print(response)
```
### RAG
```python PYTHON
faqs_short = [
{
"text": "Reimbursing Travel Expenses: Easily manage your travel expenses by submitting them through our finance tool. Approvals are prompt and straightforward."
},
{
"text": "Health and Wellness Benefits: We care about your well-being and offer gym memberships, on-site yoga classes, and comprehensive health insurance."
},
]

query = "Are there fitness-related perks?"

response = co_chat.chat(message=query, documents=faqs_short)

print(response)
```

### Embed
```python PYTHON
docs = [
"Joining Slack Channels: You will receive an invite via email. Be sure to join relevant channels to stay informed and engaged.",
"Finding Coffee Spots: For your caffeine fix, head to the break room's coffee machine or cross the street to the café for artisan coffee.",
]

doc_emb = co_embed.embed(
input_type="search_document",
texts=docs,
).embeddings
```

### Rerank
```python PYTHON
faqs_short = [
{
"text": "Reimbursing Travel Expenses: Easily manage your travel expenses by submitting them through our finance tool. Approvals are prompt and straightforward."
},
{
"text": "Working from Abroad: Working remotely from another country is possible. Simply coordinate with your manager and ensure your availability during core hours."
},
{
"text": "Health and Wellness Benefits: We care about your well-being and offer gym memberships, on-site yoga classes, and comprehensive health insurance."
},
]

query = "Are there fitness-related perks?"

results = co_rerank.rerank(
query=query, documents=faqs_short, top_n=2, model="rerank-english-v3.0"
)
```

Here are some other examples for [Command](https://github.com/Azure/azureml-examples/blob/main/sdk/python/foundation-models/cohere/cohere-cmdR.ipynb) and [Embed](https://github.com/Azure/azureml-examples/blob/main/sdk/python/foundation-models/cohere/cohere-embed.ipynb).

The important thing to understand is that our new and existing customers can call the models from Azure while still leveraging their integration with the Cohere SDK.
Loading

0 comments on commit b2ab348

Please sign in to comment.