@chroma-core/default-embed

中文文档
0.1.9发布于 2025/11/13TypeScriptESM + CJS近 30 天下载 6.9万

Chroma 的默认嵌入功能

中文使用文档
文档目录4 节
  1. 安装
  2. 使用量
  3. 配置选项
  4. 特征

Chroma 默认嵌入函数

此软件包为使用Hugging Face Transformers.js的Chroma提供了默认嵌入功能. 它完全运行于内浏览器或节点.js而不需要外部API呼叫.

安装

npm install @chroma-core/default-embed

使用量

import { ChromaClient } from 'chromadb';
import { DefaultEmbeddingFunction } from '@chroma-core/default-embed';

// Initialize with default settings
const embedder = new DefaultEmbeddingFunction();

// Or customize the configuration
const customEmbedder = new DefaultEmbeddingFunction({
  modelName: 'Xenova/all-MiniLM-L6-v2', // Default model
  revision: 'main',
  dtype: 'fp32', // or 'uint8' for quantization
  wasm: false, // Set to true to use WASM backend
});

// Create a new ChromaClient
const client = new ChromaClient({
  path: 'http://localhost:8000',
});

// Create a collection with the embedder
const collection = await client.createCollection({
  name: 'my-collection',
  embeddingFunction: embedder,
});

// Add documents
await collection.add({
  ids: ["1", "2", "3"],
  documents: ["Document 1", "Document 2", "Document 3"],
});

// Query documents
const results = await collection.query({
  queryTexts: ["Sample query"],
  nResults: 2,
});

配置选项

  • 模型Name: hugging Face模型名(默认: Xenova/all-MiniLM-L6-v2(中文(简体) )
  • 订正: 模型修订(默认: main(中文(简体) )
  • d 类型: 量化的数据类型(fp32, (中文(简体) ), fp16, (中文(简体) ), q8, (中文(简体) ), uint8页:1
  • 数量: 折旧,使用 dtype 换成
  • 原声: 为 ONNX 运行时使用 WASM 后端

特征

  • 不需要 API 密钥: 无外部依赖的本地运行
  • 浏览器兼容性: 在节点和浏览器环境中工作
  • 量化支持: 使用各种量化选项来缩小模型大小
  • WASM 后端软件: 可选 WASM 支持更好的浏览器性能

默认模式( E)Xenova/all-MiniLM-L6-v2)产生384维嵌入并适合大多数通用语义搜索任务.

版本与发布记录

@chroma-core/default-embed 共发布 5 个版本,首次发布于 2025/05/21;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.1.9latest2025/11/1311 个月前
0.1.82025/06/051.4 年前
0.1.72025/06/051.4 年前
0.1.52025/05/221.5 年前
0.1.02025/05/211.5 年前

关于 @chroma-core/default-embed 的常见问题

@chroma-core/default-embed 是什么?

Chroma 的默认嵌入功能

如何安装 @chroma-core/default-embed?

在项目目录运行 npm install @chroma-core/default-embed,或使用 pnpm add / yarn add / bun add。

@chroma-core/default-embed 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chroma-core/default-embed 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@chroma-core/default-embed 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chroma-core/default-embed 可以商用吗?

@chroma-core/default-embed 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@chroma-core/default-embed 的下载量有多少?

根据 npm 官方下载统计,@chroma-core/default-embed 在 2026/10/10 – 2026/11/08 这 30 天内被下载 68,592 次,日均约 2,286 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chroma-core/default-embed 还在维护吗?

最新版本 0.1.9 发布于 2025/11/13(11 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/05/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。