You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `VoyageAIEmbeddingEncoder` class connects to the VoyageAI to obtain embeddings for pieces of text.
209
+
210
+
`embed_documents` will receive a list of Elements, and return an updated list which includes the `embeddings` attribute for each Element.
211
+
212
+
`embed_query` will receive a query as a string, and return a list of floats which is the embedding vector for the given query string.
213
+
214
+
`num_of_dimensions` is a metadata property that denotes the number of dimensions in any embedding vector obtained via this class.
215
+
216
+
`is_unit_vector` is a metadata property that denotes if embedding vectors obtained via this class are unit vectors.
217
+
218
+
The following code block shows an example of how to use `VoyageAIEmbeddingEncoder`. You will see the updated elements list (with the `embeddings` attribute included for each element), the embedding vector for the query string, and some metadata properties about the embedding model.
219
+
220
+
To use Voyage AI you will need to pass Voyage AI API Key (obtained from [https://dash.voyageai.com/](https://dash.voyageai.com/)) as the `api_key` parameter.
221
+
222
+
The `model_name` parameter is mandatory, please check the available models at [https://docs.voyageai.com/docs/embeddings](https://docs.voyageai.com/docs/embeddings)
223
+
224
+
```python
225
+
import os
226
+
227
+
from unstructured.documents.elements import Text
228
+
from unstructured.embed.voyageai import VoyageAIEmbeddingConfig, VoyageAIEmbeddingEncoder
229
+
230
+
embedding_encoder = VoyageAIEmbeddingEncoder(
231
+
config=VoyageAIEmbeddingConfig(
232
+
api_key=os.environ["VOYAGE_API_KEY"],
233
+
model_name="voyage-law-2"
234
+
)
235
+
)
236
+
elements = embedding_encoder.embed_documents(
237
+
elements=[Text("This is sentence 1"), Text("This is sentence 2")],
0 commit comments