跳到主要内容
版本:V1.1.0

默认嵌入式函数

向量函数将文本文档转换为向量嵌入,用于相似搜索。seekdb-js 支持内置和自定义向量函数。

默认向量函数使用本地模型 (Xenova/all-MiniLM-L6-v2),无需 API 密钥。适合快速开发和测试。

// 使用默认配置 (自动使用默认向量函数)
const collection = await client.createCollection({
name: "local_embed_collection"
});

首次进行向量化时会自动下载模型,预计 3-5 分钟,根据网络情况上下浮动,请耐心等待。

seekdb-js 也支持手动导入内置模型,命令如下:

npm install @seekdb/default-embed

使用内置函数示例如下:

import { DefaultEmbeddingFunction } from "@seekdb/default-embed";

const defaultEmbed = new DefaultEmbeddingFunction({
// 如果遇到下载问题,尝试切换区域, 默认为 'cn'
// region: 'intl'
});

const collection = await client.createCollection({
name: "local_embed_collection",
embeddingFunction: defaultEmbed
});

相关操作

如果您需要使用其他内置函数或者自定义函数,可以参考以下文档创建和使用自定义函数: