Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/vectorizer/quick-start-voyage.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,17 @@ Now you can create and run a vectorizer. A vectorizer is a pgai concept, it proc
```

**Available Voyage AI Models:**
- `voyage-3.5-lite`: Cost & latency optimized, 1024 dims (1M tokens/request) - **Recommended**

**Voyage 4 Series (Latest):**
- `voyage-4-lite`: Cost & latency optimized, 1024 dims (1M tokens/request) - **Recommended**
- `voyage-4`: General-purpose optimized, 1024 dims (320K tokens/request)
- `voyage-4-large`: Best retrieval quality, 1024 dims (120K tokens/request)

**Voyage 3.5 Series:**
- `voyage-3.5-lite`: Cost & latency optimized, 1024 dims (1M tokens/request)
- `voyage-3.5`: General-purpose optimized, 1024 dims (320K tokens/request)

**Voyage 3 Series:**
- `voyage-3-large`: Best for general-purpose & multilingual, 1024 dims (120K tokens/request)
- `voyage-code-3`: Specialized for code retrieval, 1024 dims (120K tokens/request)
- `voyage-finance-2`: Finance domain optimized, 1024 dims
Expand Down
8 changes: 4 additions & 4 deletions projects/extension/docs/model_calling/voyageai.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ as a [session level parameter]. For more options and details, consult the
`ai.voyage_api_key` is set for the duration of your psql session, you do not need to specify it for pgai functions.

```sql
SELECT * FROM ai.voyageai_embed('voyage-3-lite', 'sample text to embed');
SELECT * FROM ai.voyageai_embed('voyage-4-lite', 'sample text to embed');
```

## Usage
Expand All @@ -49,7 +49,7 @@ Generate [embeddings](https://docs.voyageai.com/docs/embeddings) using a specifi

```sql
SELECT ai.voyageai_embed
( 'voyage-3-lite'
( 'voyage-4-lite'
, 'the purple elephant sits on a red mushroom'
);
```
Expand All @@ -67,7 +67,7 @@ Generate [embeddings](https://docs.voyageai.com/docs/embeddings) using a specifi

```sql
SELECT ai.voyageai_embed
( 'voyage-3-lite'
( 'voyage-4-lite'
, array['Timescale is Postgres made Powerful', 'the purple elephant sits on a red mushroom']
);
```
Expand All @@ -80,7 +80,7 @@ Generate [embeddings](https://docs.voyageai.com/docs/embeddings) using a specifi

```sql
SELECT ai.voyageai_embed
( 'voyage-3-lite'
( 'voyage-4-lite'
, 'A query'
, input_type => 'query'
);
Expand Down
57 changes: 57 additions & 0 deletions projects/extension/tests/test_voyageai.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,63 @@ def test_voyageai_embed_with_multiple_inputs(cur, voyageai_api_key):
assert result == 2


def test_voyageai_embed_voyage_4(cur, voyageai_api_key):
"""Test voyage-4 model."""
cur.execute(
"""
select vector_dims
(
ai.voyageai_embed
( 'voyage-4'
, 'hello world'
, api_key=>%s
)
)
""",
(voyageai_api_key,),
)
actual = cur.fetchone()[0]
assert actual == 1024


def test_voyageai_embed_voyage_4_lite(cur, voyageai_api_key):
"""Test voyage-4-lite model."""
cur.execute(
"""
select vector_dims
(
ai.voyageai_embed
( 'voyage-4-lite'
, 'hello world'
, api_key=>%s
)
)
""",
(voyageai_api_key,),
)
actual = cur.fetchone()[0]
assert actual == 1024


def test_voyageai_embed_voyage_4_large(cur, voyageai_api_key):
"""Test voyage-4-large model."""
cur.execute(
"""
select vector_dims
(
ai.voyageai_embed
( 'voyage-4-large'
, 'hello world'
, api_key=>%s
)
)
""",
(voyageai_api_key,),
)
actual = cur.fetchone()[0]
assert actual == 1024


def test_voyageai_embed_voyage_3_5_lite(cur, voyageai_api_key):
"""Test voyage-3.5-lite model (current naming)."""
cur.execute(
Expand Down
10 changes: 5 additions & 5 deletions projects/pgai/pgai/vectorizer/embedders/voyageai.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
def voyage_max_tokens_per_batch(model: str) -> int:
# According to https://docs.voyageai.com/docs/embeddings:
# The total number of tokens in the list is at most:
# - 1M for voyage-3.5-lite and voyage-3-lite
# - 320K for voyage-3.5, voyage-3, and voyage-2
# - 120K for voyage-3-large, voyage-code-3, voyage-large-2-instruct, voyage-finance-2, voyage-multilingual-2, voyage-law-2, voyage-large-2, and voyage-3-lite
# - 1M for voyage-4-lite, voyage-3.5-lite, and voyage-3-lite
# - 320K for voyage-4, voyage-3.5, voyage-3, and voyage-2
# - 120K for voyage-4-large, voyage-3-large, voyage-code-3, voyage-large-2-instruct, voyage-finance-2, voyage-multilingual-2, voyage-law-2, voyage-large-2
match model:
case "voyage-3.5-lite" | "voyage-3-lite":
case "voyage-4-lite" | "voyage-3.5-lite" | "voyage-3-lite":
return 1_000_000
case "voyage-3.5" | "voyage-2" | "voyage-3":
case "voyage-4" | "voyage-3.5" | "voyage-2" | "voyage-3":
return 320_000
case _:
return 120_000 # Conservative default for specialized and older models
Expand Down