npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tencentdb-agent-memory/tcvdb-text

v0.1.1

Published

TypeScript port of tcvdb_text — BM25 sparse vector encoder for Tencent Cloud VectorDB

Readme

@tencentdb-agent-memory/tcvdb-text

TypeScript port of tcvdb_text — BM25 sparse vector encoder for Tencent Cloud VectorDB.

Encodes text into sparse vectors compatible with VectorDB's hybridSearch interface.

Installation

npm install @tencentdb-agent-memory/tcvdb-text

Usage

Use the built-in default model (recommended)

import { BM25Encoder } from "@tencentdb-agent-memory/tcvdb-text";

// Load pre-trained Chinese model
const encoder = BM25Encoder.default("zh"); // or "en" for English

// Encode a document (for indexing)
const docVector = encoder.encodeTexts("腾讯云向量数据库是一款全托管的向量检索服务");
// => [[tokenId, weight], ...]

// Encode a query (for searching)
const queryVector = encoder.encodeQueries("向量数据库");
// => [[tokenId, weight], ...]

// Batch encoding
const docVectors = encoder.encodeTexts(["文档一", "文档二"]);
const queryVectors = encoder.encodeQueries(["查询一", "查询二"]);

Train on your own corpus

import { BM25Encoder } from "@tencentdb-agent-memory/tcvdb-text";

const encoder = new BM25Encoder();

// Fit on your corpus
encoder.fitCorpus([
  "腾讯云向量数据库支持混合检索",
  "BM25 是一种经典的稀疏检索算法",
  "稀疏向量与稠密向量结合可以提升检索效果",
]);

// Save trained params to file
encoder.downloadParamsSync("./my_bm25_params.json");

// Load params later
const encoder2 = new BM25Encoder();
await encoder2.setParams("./my_bm25_params.json");

Custom tokenizer

import { BM25Encoder, JiebaTokenizer, Hash } from "@tencentdb-agent-memory/tcvdb-text";

const tokenizer = new JiebaTokenizer({
  hashFunction: Hash.mmh3Hash,
  stopWords: true,
  lowerCase: true,
});

const encoder = new BM25Encoder({ tokenizer, b: 0.75, k1: 1.2 });

API

BM25Encoder

| Method | Description | |--------|-------------| | BM25Encoder.default(name) | Load pre-trained model. name: "zh" (default) or "en" | | fitCorpus(corpus) | Train on a string or array of strings. Supports incremental training | | encodeTexts(texts) | Encode document(s) into sparse vectors (TF-weighted) | | encodeQueries(texts) | Encode query/queries into sparse vectors (IDF-weighted, normalized) | | downloadParamsSync(path) | Save trained params to a JSON file | | setParamsSync(path) | Load params from a JSON file (sync) | | setParams(path) | Load params from a JSON file (async) | | setDict(dictFile) | Load a custom Jieba dictionary |

SparseVector

type SparseVector = Array<[number, number]>; // [tokenId, weight]

Compatible with Tencent Cloud VectorDB hybridSearch match.data format.

Requirements

  • Node.js >= 18

License

MIT