recommend voyage-code-3

This commit is contained in:
Nate 2024-12-05 12:48:38 -08:00
parent 3a7b5f9b3c
commit e9f85b6b33
7 changed files with 19 additions and 14 deletions

View file

@ -7,7 +7,7 @@ class VoyageEmbeddingsProvider extends OpenAIEmbeddingsProvider {
static defaultOptions: Partial<EmbedOptions> | undefined = {
apiBase: "https://api.voyageai.com/v1/",
model: "voyage-code-2",
model: "voyage-code-3",
};
}

View file

@ -19,7 +19,7 @@ The free trial supports embeddings (provider: `free-trial`)
## Recommended embedding models
If you have the ability to use any model, we recommend `voyage-code-2`, which is listed below along with the rest of the options for embeddings models.
If you have the ability to use any model, we recommend `voyage-code-3`, which is listed below along with the rest of the options for embeddings models.
If you want to generate embeddings locally, we recommend using `nomic-embed-text` with [Ollama](../model-providers/top-level/ollama.md#embeddings-model).
@ -31,7 +31,7 @@ After obtaining an API key from [here](https://www.voyageai.com/), you can confi
{
"embeddingsProvider": {
"provider": "voyage",
"model": "voyage-code-2",
"model": "voyage-code-3",
"apiKey": "<VOYAGE_API_KEY>"
}
}

View file

@ -4,7 +4,7 @@ While Continue comes with [@Codebase](../deep-dives/codebase.md) out of the box,
## Step 1: Choose an embeddings model
If possible, we recommend using [`voyage-code-2`](https://docs.voyageai.com/docs/embeddings), which will give the most accurate answers of any existing embeddings model for code. You can obtain an API key [here](https://dash.voyageai.com/api-keys). Because their API is [OpenAI-compatible](https://docs.voyageai.com/reference/embeddings-api), you can use any OpenAI client by swapping out the URL.
If possible, we recommend using [`voyage-code-3`](https://docs.voyageai.com/docs/embeddings), which will give the most accurate answers of any existing embeddings model for code. You can obtain an API key [here](https://dash.voyageai.com/api-keys). Because their API is [OpenAI-compatible](https://docs.voyageai.com/reference/embeddings-api), you can use any OpenAI client by swapping out the URL.
## Step 2: Choose a vector database
@ -16,7 +16,7 @@ There are a number of available vector databases, but because most vector databa
Most embeddings models can only handle a limited amount of text at once. To get around this, we "chunk" our code into smaller pieces.
If you use `voyage-code-2`, it has a maximum context length of 16,000 tokens, which is enough to fit most files. This means that in the beginning you can get away with a more naive strategy of truncating files that exceed the limit. In order of easiest to most comprehensive, 3 chunking strategies you can use are:
If you use `voyage-code-3`, it has a maximum context length of 16,000 tokens, which is enough to fit most files. This means that in the beginning you can get away with a more naive strategy of truncating files that exceed the limit. In order of easiest to most comprehensive, 3 chunking strategies you can use are:
1. Truncate the file when it goes over the context length: in this case you will always have 1 chunk per file.
2. Split the file into chunks of a fixed length: starting at the top of the file, add lines you your current chunk until it reaches the limit, then start a new chunk.
@ -40,7 +40,7 @@ from lancedb.embeddings import get_registry
db = lancedb.connect("/tmp/db")
func = get_registry().get("openai").create(
name="voyage-code-2",
name="voyage-code-3",
base_url="https://api.voyageai.com/v1/",
api_key=os.environ["VOYAGE_API_KEY"],
)
@ -48,7 +48,7 @@ func = get_registry().get("openai").create(
class CodeChunks(LanceModel):
filename: str
text: str = func.SourceField()
# 1536 is the embedding dimension of the `voyage-code-2` model.
# 1536 is the embedding dimension of the `voyage-code-3` model.
vector: Vector(1536) = func.VectorField()
table = db.create_table("code_chunks", schema=CodeChunks, mode="overwrite")

View file

@ -11,7 +11,7 @@ sidebar_position: 3
## 推荐的嵌入模型
如果你有使用任何模型的能力,我们推荐 `voyage-code-2` ,它独立列在下面,和其他的嵌入模型选项一起。
如果你有使用任何模型的能力,我们推荐 `voyage-code-3` ,它独立列在下面,和其他的嵌入模型选项一起。
如果你想本地生成嵌入,我们推荐通过 [Ollama](../model-providers/top-level/ollama.md#嵌入模型) 使用 `nomic-embed-text` 。
@ -23,7 +23,7 @@ sidebar_position: 3
{
"embeddingsProvider": {
"provider": "voyage",
"model": "voyage-code-2",
"model": "voyage-code-3",
"apiKey": "<VOYAGE_API_KEY>"
}
}

View file

@ -4,7 +4,7 @@
## 步骤 1 :选择嵌入模型
如果可能,我们推荐使用 [`voyage-code-2`](https://docs.voyageai.com/docs/embeddings) ,它将给出最准确的答案,关于任何已存的代码嵌入模型。你可以在 [这里](https://dash.voyageai.com/api-keys) 获取 API key 。因为他门的 API 是 [OpenAI-兼容的](https://docs.voyageai.com/reference/embeddings-api) ,你可以使用任何 OpenAI 客户端换出 URL 。
如果可能,我们推荐使用 [`voyage-code-3`](https://docs.voyageai.com/docs/embeddings) ,它将给出最准确的答案,关于任何已存的代码嵌入模型。你可以在 [这里](https://dash.voyageai.com/api-keys) 获取 API key 。因为他门的 API 是 [OpenAI-兼容的](https://docs.voyageai.com/reference/embeddings-api) ,你可以使用任何 OpenAI 客户端换出 URL 。
## 步骤 2 :选择向量模型
@ -16,7 +16,7 @@
大多数嵌入模型只能一次处理有限的文本数量。为了解决这个问题,我们 "分块" 我们的代码到较小的部分。
如果你使用 `voyage-code-2` ,它可以有最大 16,000 token 上下文长度,足够容纳大多数文件。这意味着,在开始的时候,你可以使用更朴素的策略避免超过限制。为了最简单到最综合,你可以使用 3 分块策略:
如果你使用 `voyage-code-3` ,它可以有最大 16,000 token 上下文长度,足够容纳大多数文件。这意味着,在开始的时候,你可以使用更朴素的策略避免超过限制。为了最简单到最综合,你可以使用 3 分块策略:
1. 截断文件,当它超过上下文长度:在这种情况下,你总是每个文件有 1 个分块。
2. 拆分文件到一个固定长度的分块:从文件的最上面开始,添加你当前分块的行,直到它到达限制,然后开始一个新的分块。
@ -42,7 +42,7 @@ from lancedb.embeddings import get_registry
db = lancedb.connect("/tmp/db")
func = get_registry().get("openai").create(
name="voyage-code-2",
name="voyage-code-3",
base_url="https://api.voyageai.com/v1/",
api_key=os.environ["VOYAGE_API_KEY"],
)
@ -50,7 +50,7 @@ func = get_registry().get("openai").create(
class CodeChunks(LanceModel):
filename: str
text: str = func.SourceField()
# 1536 is the embedding dimension of the `voyage-code-2` model.
# 1536 is the embedding dimension of the `voyage-code-3` model.
vector: Vector(1536) = func.VectorField()
table = db.create_table("code_chunks", schema=CodeChunks, mode="overwrite")

View file

@ -6,6 +6,11 @@ export const Voyage: ModelProvider = {
model: "voyage-code-2",
displayName: "Voyage Code 2",
contextLength: 8096,
},
{
model: "voyage-code-3",
displayName: "Voyage Code 3",
contextLength: 8096,
recommendedFor: ["embed"],
},
{

View file

@ -303,7 +303,7 @@ const EMBEDDINGS_TESTS: LlmApiConfig[] = [
},
{
provider: "openai",
model: "voyage-code-2",
model: "voyage-code-3",
apiKey: process.env.VOYAGE_API_KEY!,
apiBase: "https://api.voyageai.com/v1/",
},