CohereBackend
¶
Bases: BaseEmbedder
Cohere Embedding Model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
A |
required | |
embedding_model |
str
|
A Cohere model. Default is "large". For an overview of models see: https://docs.cohere.ai/docs/generation-card |
'large'
|
delay_in_seconds |
float
|
If a |
None
|
batch_size |
int
|
The size of each batch. |
None
|
embed_kwargs |
Mapping[str, Any]
|
Kwargs passed to |
{}
|
Examples:
import cohere
from bertopic.backend import CohereBackend
client = cohere.Client("APIKEY")
cohere_model = CohereBackend(client)
If you want to specify input_type
:
cohere_model = CohereBackend(
client,
embedding_model="embed-english-v3.0",
embed_kwargs={"input_type": "clustering"}
)
Source code in bertopic\backend\_cohere.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
embed(documents, verbose=False)
¶
Embed a list of n documents/words into an n-dimensional matrix of embeddings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
documents |
List[str]
|
A list of documents or words to be embedded |
required |
verbose |
bool
|
Controls the verbosity of the process |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
Document/words embeddings with shape (n, m) with |
ndarray
|
that each have an embeddings size of |
Source code in bertopic\backend\_cohere.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|