No project description provided
Project description
Voyage Python Library
Voyage AI provides cutting-edge embedding/vectorizations models.
Embedding models are neural net models (e.g., transformers) that convert unstructured and complex data, such as documents, images, audios, videos, or tabular data, into numerical vectors that capture their semantic meanings. These vectors serve as representations/indices for datapoints and are an essential building blocks for semantic search and retrieval-augmented generation stack (RAG), which is the dominating approach for domain-specific or company-specific chatbots.
Voyage AI provides API endpoints for embedding models that take in your data (e.g., documents or queries) and return their embeddings. The embedding models are a modular component that can used with any other components in the RAG stack, such as any vectorDB and any generative LLM.
Voyage’s embedding models are state-of-the-art in retrieval accuracy. Please read our announcing blog post for details. Please also check out a high-level introduction of embedding models, semantic search, and RAG, and our step-by-step quickstart tutorial on implementing a minimalist RAG chatbot using Voyage embeddings.
The Voyage Python library provides convenient access to the Voyage API (see our documentation).
Installation
Use pip
to install the package:
pip install voyageai
Test the installation by running this command:
python -c "import voyageai"
Authentication with API keys
Voyage AI utilizes API keys to monitor usage and manage permissions. To obtain your key, first create an account by clicking the "SIGN IN" button on our homepage. Once signed in, access your API key by clicking "View API key" in the dashboard.
Your API key is supposed to be secret -- please avoid sharing it or exposing it in browsers or apps. Please store your API key securely for future use, e.g., via the following bash command.
export VOYAGE_API_KEY = '[ Your VOYAGE API key ]'
Alternatively, the API key can be set in python (after you install the package):
import voyageai
voyageai.api_key = "[ Your VOYAGE API key ]"
Voyage Embeddings
Models and specifics
Voyage currently provides three embedding models. All models currently have context length = 4096 (tokens) and embedding dimension = 1024.
voyage-01
: the default choice with the best retrieval quality (e.g., better than OpenAI embedding models — see blog post for details.)voyage-lite-01
: 2x faster inference thanvoyage-01
with nearly the same retrieval quality.voyage-lite-01-instruct
: tweaked on top ofvoyage-lite-01
for classification and clustering tasks, which are the only recommended use cases.
More advanced and specialized models are coming soon and please contact contact@voyageai.com for early access.
voyage-xl-01
: coming soonvoyage-code-01
: coming soonvoyage-finance-01
: coming soon
Functions
he core functions are get_embedding
that takes a single document (or query), and get_embeddings
, which allows a batch of documents or queries. Before using the library, please first register for a Voyage API key.
get_embedding(text, model, input_type=None)
:link:
- Parameters
- text - A single document/query as a string, such as
"I like cats"
. - model - Name of the model. Options:
voyage-01
,voyage-lite-01
. - input_type - Type of the input text. Defalut to
None
, meaning the type is unspecified. Other options:query
,document
.
- text - A single document/query as a string, such as
- Returns
- An embedding vector (a list of floating-point numbers) for the document.
get_embeddings(list_of_text, model, input_type=None)
:link:
- Parameters
- list_of_text - A list of documents as a list of strings, such as
["I like cats", "I also like dogs"]
. The length of the list is at most 64. (Each Voyage API request takes at most 8 strings. This function makes one API request whenlen(list_of_text)<=8
, and makes multiple API requests in parallel when8<len(list_of_text)<=64
.) - model - Name of the model. Options:
voyage-01
,voyage-lite-01
. - input_type - Type of the input text. Defalut to
None
, meaning the type is unspecified. Other options:query
,document
.
- list_of_text - A list of documents as a list of strings, such as
- Returns
- A list of embedding vectors.
Example usage
Given a list of documents, obtain the embeddings from Voyage Python package.
import voyageai
from voyageai import get_embeddings
voyageai.api_key = "[ Your Voyage API KEY ]" # add you Voyage API KEY
documents = [
"The Mediterranean diet emphasizes fish, olive oil, and vegetables, believed to reduce chronic diseases.",
"Photosynthesis in plants converts light energy into glucose and produces essential oxygen.",
"20th-century innovations, from radios to smartphones, centered on electronic advancements.",
"Rivers provide water, irrigation, and habitat for aquatic species, vital for ecosystems.",
"Apple’s conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET.",
"Shakespeare's works, like 'Hamlet' and 'A Midsummer Night's Dream,' endure in literature."
]
# Embed the documents
embeddings = get_embeddings(documents, model="voyage-01", input_type="document")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file voyageai-0.1.5.tar.gz
.
File metadata
- Download URL: voyageai-0.1.5.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d601203bb53aa6a345191d592f83faa936fe7687871167d457fe9a35e7cedc2 |
|
MD5 | 9bbbdb2d275bd32f05c5bddbb4a701c2 |
|
BLAKE2b-256 | eb80bd7754bff9f6cf2c509008f1874fc9bf381986e32d3bb6ed5e23c3bb98de |
File details
Details for the file voyageai-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: voyageai-0.1.5-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cfeb14a2584468c717df83953e1d0f0f49870d38c22b941569cb9d724e146ef |
|
MD5 | 3fbdc9b4ce868b987cb5fdf3b39c62f1 |
|
BLAKE2b-256 | 74ac2932b809eed9025cc5df5fd6e46cf83369a65fdfcb54b588eb1f5322337f |