@chroma-core/default-embed

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

Default embedding function for Chroma

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Configuration Options
  4. Features

Default Embedding Function for Chroma

This package provides a default embedding function for Chroma using Hugging Face Transformers.js. It runs entirely in-browser or Node.js without requiring external API calls.

Installation

npm install @chroma-core/default-embed

Usage

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,
});

Configuration Options

  • modelName: Hugging Face model name (default: Xenova/all-MiniLM-L6-v2)
  • revision: Model revision (default: main)
  • dtype: Data type for quantization (fp32, fp16, q8, uint8, etc.)
  • quantized: Deprecated, use dtype instead
  • wasm: Use WASM backend for ONNX Runtime

Features

  • No API Key Required: Runs locally without external dependencies
  • Browser Compatible: Works in both Node.js and browser environments
  • Quantization Support: Reduce model size with various quantization options
  • WASM Backend: Optional WASM support for better browser performance

The default model (Xenova/all-MiniLM-L6-v2) produces 384-dimensional embeddings and is suitable for most general-purpose semantic search tasks.

版本与发布记录

@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 是什么?

Default embedding function for 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 和提交记录判断。