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

leanvec

v0.2.0

Published

A small static embedding table + zero-dependency pure-JS runtime, pruned for Chinese + English + Russian + code retrieval.

Readme

leanvec

静态嵌入表 + 零依赖纯 JS 运行时。中文 / 英文 / 俄文 / 代码可用,向量已 L2 归一化。

import { loadLeanvec } from 'leanvec'

const lv = loadLeanvec({
  table: 'node_modules/leanvec/dist/leanvec.f32',
  tokenizer: 'node_modules/leanvec/dist/leanvec.tokenizer.json',
})

lv.size                                     // 86832
lv.dim                                      // 256
lv.embed('文本')                             // Float32Array(256),已归一化;空文本 → null
lv.cosine(a, b)                             // 余弦
lv.rank(['文本 A', '文本 B'], '查询', 5)      // [{ index, score, text }]

只要分词:import { normalizeText, metaspace, makeUnigram } from 'leanvec/tokenizer'。

数据产物由上游多语言静态嵌入模型裁剪而来:只丢弃词表行,保留的向量逐字节不变。 未量化、未降维、未重新训练。随包发布,安装不需要脚本、不联网。

运行时不读整表:loadLeanvec 只打开 fd,embed() 用到的 token 才按行读(一行 1 KB), 最近用过的行按 cacheBytes 做 LRU(默认 0 = 不缓存;批量建索引建议 4–16 MB)。 所以 85 MB 的表不会进 RSS——实测加载常驻 87 MB,且主要是 2.2 MB 词表 JSON 解析后的对象图 (V8 堆开销),不再有 85 MB 的常驻 Buffer。用完调 close() 释放 fd。

体积与语言覆盖是显式取舍:86,832 行 / 84.8 MiB。汉字全留,中英/代码按词频留头部, 俄语(西里尔)留上游全局词频最高的 8,000 个词/子词(tools/add-cyrillic.mjs,纯追加, 原有行不动)。希腊/希伯来/阿拉伯/泰文等未覆盖:这些文字的 embed() 返回 null (只剩词边界标记时没有内容 token,给向量就是撒谎),调用方应退回纯词法。

许可

代码 MIT(见 LICENSE)。数据产物是上游模型的裁剪派生,上游以 MIT 发布; 再分发必须保留 NOTICE。