@chroma-core/ollama

中文文档
0.1.8发布于 2025/11/13TypeScriptESM + CJS近 30 天下载 5198

Ollama embedding provider for Chroma

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Prerequisites
  4. Configuration Options
  5. Supported Models
  6. Browser Support

Ollama Embedding Function for Chroma

This package provides an Ollama embedding provider for Chroma, allowing you to use locally hosted Ollama models.

Installation

npm install @chroma-core/ollama

Usage

import { ChromaClient } from 'chromadb';
import { OllamaEmbeddingFunction } from '@chroma-core/ollama';

// Initialize the embedder
const embedder = new OllamaEmbeddingFunction({
  url: 'http://localhost:11434', // Default Ollama server URL
  model: 'chroma/all-minilm-l6-v2-f32', // Default model
});

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

Prerequisites

  1. Install Ollama from ollama.ai
  2. Start the Ollama server:
    ollama serve
    
  3. Pull an embedding model:
    ollama pull chroma/all-minilm-l6-v2-f32
    

Configuration Options

  • url: Ollama server URL (default: http://localhost:11434)
  • model: Model name to use for embeddings (default: chroma/all-minilm-l6-v2-f32)

Supported Models

Popular embedding models available through Ollama:

  • chroma/all-minilm-l6-v2-f32 (default, 384 dimensions)
  • nomic-embed-text (768 dimensions)
  • mxbai-embed-large (1024 dimensions)
  • snowflake-arctic-embed

Pull models using:

ollama pull <model-name>

Browser Support

This package works in both Node.js and browser environments, automatically detecting the runtime and using the appropriate Ollama client.

版本与发布记录

@chroma-core/ollama 共发布 3 个版本,首次发布于 2025/05/23;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.1.8latest2025/11/1311 个月前
0.1.72025/06/051.4 年前
0.1.52025/05/231.5 年前

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

@chroma-core/ollama 是什么?

Ollama embedding provider for Chroma

如何安装 @chroma-core/ollama?

在项目目录运行 npm install @chroma-core/ollama,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:chromadb(^3.1.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@chroma-core/ollama 支持 TypeScript 吗?

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

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

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

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

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

@chroma-core/ollama 可以商用吗?

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

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

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

@chroma-core/ollama 还在维护吗?

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