Cohere's embedding models are available via the Embed endpoint. This endpoint enables you to embed text documents (multilingual) and images into a vector space.

Semantic search, powered by embeddings, enables applications to perform information retrieval based on the context or meaning of a document.

This quickstart guide shows you how to perform semantic search with the Embed endpoint.

::::::steps{titleSize="h2"}
:::::step{title="Setup"}
First, install the Cohere Python SDK with the following command.

```bash
pip install -U cohere
```

Next, import the library and create a client.

::::tabs
:::tab{title="Cohere Platform"}
```python PYTHON
import cohere

co = cohere.Client(
    "COHERE_API_KEY"
)  # Get your free API key here: https://dashboard.cohere.com/api-keys
```
:::

:::tab{title="Private Deployment"}
```python PYTHON
import cohere

co = cohere.Client(
    api_key="",  # Leave this blank
    base_url="<YOUR_DEPLOYMENT_URL>",
)
```
:::

:::tab{title="Bedrock"}
```python PYTHON
import cohere

co = cohere.BedrockClient(
    aws_region="AWS_REGION",
    aws_access_key="AWS_ACCESS_KEY_ID",
    aws_secret_key="AWS_SECRET_ACCESS_KEY",
    aws_session_token="AWS_SESSION_TOKEN",
)

# Get the model name: https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html
```
:::

:::tab{title="SageMaker"}
```python PYTHON
import cohere

co = cohere.SagemakerClient(
    aws_region="AWS_REGION",
    aws_access_key="AWS_ACCESS_KEY_ID",
    aws_secret_key="AWS_SECRET_ACCESS_KEY",
    aws_session_token="AWS_SESSION_TOKEN",
)
```
:::

:::tab{title="Azure AI"}
```python PYTHON
import cohere

co = cohere.Client(
    api_key="AZURE_API_KEY",
    base_url="AZURE_ENDPOINT",  # example: "https://cohere-embed-v3-multilingual-xyz.eastus.models.ai.azure.com/"
)
```
:::
::::
:::::

:::::step{title="Document Embeddings"}
First, embed the list of available documents using the Embed endpoint by specifying the `input_type` as `search_document`.

::::tabs
:::tab{title="Cohere Platform"}
```python PYTHON
# Define the documents
documents = [
    "Joining Slack Channels: Be sure to join relevant channels to stay informed and engaged.",
    "Finding Coffee Spots: For your caffeine fix, cross the street to the café for artisan coffee.",
    "Working Hours Flexibility: While our core hours are 9 AM to 5 PM, we offer flexibility to adjust as needed.",
]

# Embed the documents
doc_emb = co.embed(
    model="embed-v4.0",
    input_type="search_document",
    texts=documents,
    embedding_types=["float"],
).embeddings.float

```
:::

:::tab{title="Private Deployment"}
```python PYTHON
# Define the documents
documents = [
    "Joining Slack Channels: Be sure to join relevant channels to stay informed and engaged.",
    "Finding Coffee Spots: For your caffeine fix, cross the street to the café for artisan coffee.",
    "Working Hours Flexibility: While our core hours are 9 AM to 5 PM, we offer flexibility to adjust as needed.",
]

# Embed the documents
doc_emb = co.embed(
    model="embed-v4.0",
    input_type="search_document",
    texts=documents,
    embedding_types=["float"],
).embeddings.float
```
:::

:::tab{title="Bedrock"}
```python PYTHON
# Define the documents
documents = [
    "Joining Slack Channels: Be sure to join relevant channels to stay informed and engaged.",
    "Finding Coffee Spots: For your caffeine fix, cross the street to the café for artisan coffee.",
    "Working Hours Flexibility: While our core hours are 9 AM to 5 PM, we offer flexibility to adjust as needed.",
]

# Embed the documents
doc_emb = co.embed(
    model="YOUR_MODEL_NAME",
    input_type="search_document",
    texts=documents,
    embedding_types=["float"],
).embeddings.float

```
:::

:::tab{title="SageMaker"}
```python PYTHON
# Define the documents
documents = [
    "Joining Slack Channels: Be sure to join relevant channels to stay informed and engaged.",
    "Finding Coffee Spots: For your caffeine fix, cross the street to the café for artisan coffee.",
    "Working Hours Flexibility: While our core hours are 9 AM to 5 PM, we offer flexibility to adjust as needed.",
]

# Embed the documents
doc_emb = co.embed(
    model="YOUR_ENDPOINT_NAME",
    input_type="search_document",
    texts=documents,
    embedding_types=["float"],
).embeddings.float
```
:::

:::tab{title="Azure AI"}
```python PYTHON
# Define the documents
documents = [
    "Joining Slack Channels: Be sure to join relevant channels to stay informed and engaged.",
    "Finding Coffee Spots: For your caffeine fix, cross the street to the café for artisan coffee.",
    "Working Hours Flexibility: While our core hours are 9 AM to 5 PM, we offer flexibility to adjust as needed.",
]

# Embed the documents
doc_emb = co.embed(
    input_type="search_document",
    texts=documents,
    embedding_types=["float"],
).embeddings.float

```
:::
::::
:::::

:::::step{title="Query Embedding"}
Next, embed the user query using the Embed endpoint by specifying the `input_type` as `search_query`.

::::tabs
:::tab{title="Cohere Platform"}
```python PYTHON
# Add the user query
query = "Ways to connect with my teammates"

# Embed the query
query_emb = co.embed(
    model="embed-v4.0",
    input_type="search_query",
    texts=[query],
    embedding_types=["float"],
).embeddings.float
```
:::

:::tab{title="Private Deployment"}
```python PYTHON
# Add the user query
query = "Ways to connect with my teammates"

# Embed the query
query_emb = co.embed(
    model="embed-v4.0",
    input_type="search_query",
    texts=[query],
    embedding_types=["float"],
).embeddings.float

```
:::

:::tab{title="Bedrock"}
```python PYTHON
# Add the user query
query = "Ways to connect with my teammates"

# Embed the query
query_emb = co.embed(
    model="YOUR_MODEL_NAME",
    input_type="search_query",
    texts=[query],
    embedding_types=["float"],
).embeddings.float
```
:::

:::tab{title="SageMaker"}
```python PYTHON
# Add the user query
query = "Ways to connect with my teammates"

# Embed the query
query_emb = co.embed(
    model="embed-v4.0",
    input_type="search_query",
    texts=[query],
    embedding_types=["float"],
).embeddings.float

```
:::

:::tab{title="Azure AI"}
```python PYTHON
# Add the user query
query = "Ways to connect with my teammates"

# Embed the query
query_emb = co.embed(
    model="embed-v4.0",
    input_type="search_query",
    texts=[query],
    embedding_types=["float"],
).embeddings.float
```
:::
::::
:::::

:::step{title="Semantic Search"}
Then, perform semantic search by computing the similarity between the query embedding and the document embeddings, and then returning the most similar documents.

```python PYTHON
import numpy as np


# Compute dot product similarity and display results
def return_results(query_emb, doc_emb, documents):
    n = 2  # customize your top N results
    scores = np.dot(query_emb, np.transpose(doc_emb))[0]
    max_idx = np.argsort(-scores)[:n]

    for rank, idx in enumerate(max_idx):
        print(f"Rank: {rank+1}")
        print(f"Score: {scores[idx]}")
        print(f"Document: {documents[idx]}\n")


return_results(query_emb, doc_emb, documents)
```

```mdx wordWrap
Rank: 1
Score: 0.262197161387274
Document: Joining Slack Channels: Be sure to join relevant channels to stay informed and engaged.

Rank: 2
Score: 0.1266074257723145
Document: Working Hours Flexibility: While our core hours are 9 AM to 5 PM, we offer flexibility to adjust as needed.
```
:::
::::::

## Further Resources

- [Embed endpoint API reference](/api)
- [Documentation on embeddings](/guides/embeddings-vectors-search-retrieval-v2-text-embeddings-embeddings)
- [LLM University module on semantic search](https://cohere.com/llmu#semantic-search)

## Related pages

- [Changelog](../changelog.md)
- [Cohere](../index.md)
- [Cohere API](./cohere-api-index.md)
- [Cohere Labs](./cohere-labs-index.md)
- [Cohere Platform](./cohere-platform-index.md)
- [Cookbooks](./cookbooks-index.md)
- [Deployment Options](./deployment-options-index.md)
- [Embeddings (Vectors, Search, Retrieval)](./embeddings-vectors-search-retrieval-index.md)
- [Get Started](./get-started-index.md)
- [Going to Production](./going-to-production-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
