@anush008/tokenizers

中文文档
0.6.0发布于 2026/03/19MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 47.1万

Multi-arch builds of HuggingFace tokenizers

此软件包已被标记为弃用

This package has been archived. Please use the official and updated "huggingface/tokenizers" package.

原始使用文档
文档目录5 节
  1. Supports:
  2. Installation
  3. Features
  4. Basic example
  5. License

@anush008/tokenizers

The official Node bindings are in a jinx with limited support for Node versions and architectures. This package offers multi-arch bindings for @huggingface/tokenizers with Node v20.x supported.

Supports:

  • Windows x86_64
  • Linux x86_64 (glibc, musl/Alpine)
  • Linux aarch64 (glibc, musl/Alpine)
  • macOS x86_64
  • macOS aarch64 (Apple Silicon)
  • macOS Universal binary

Installation

npm install @anush008/tokenizers

Features

  • Train new vocabularies and tokenize using 4 pre-made tokenizers (Bert WordPiece and the 3 most common BPE versions).
  • Extremely fast (both training and tokenization), thanks to the Rust implementation. Takes less than 20 seconds to tokenize a GB of text on a server's CPU.
  • Easy to use, but also extremely versatile.
  • Designed for research and production.
  • Normalization comes with alignments tracking. It's always possible to get the part of the original sentence that corresponds to a given token.
  • Does all the pre-processing: Truncate, Pad, add the special tokens your model needs.

Basic example

import { Tokenizer } from "@anush008/tokenizers";

const tokenizer = await Tokenizer.fromFile("tokenizer.json");
const wpEncoded = await tokenizer.encode("Who is John?");

console.log(wpEncoded.getLength());
console.log(wpEncoded.getTokens());
console.log(wpEncoded.getIds());
console.log(wpEncoded.getAttentionMask());
console.log(wpEncoded.getOffsets());
console.log(wpEncoded.getOverflowing());
console.log(wpEncoded.getSpecialTokensMask());
console.log(wpEncoded.getTypeIds());
console.log(wpEncoded.getWordIds());

License

MIT

版本与发布记录

@anush008/tokenizers 共发布 4 个版本,首次发布于 2023/09/16;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.0latest2026/03/197 个月前
0.5.02026/03/147 个月前
0.2.0next2023/09/173 年前
0.0.02023/09/163 年前

关于 @anush008/tokenizers 的常见问题

@anush008/tokenizers 是什么?

Multi-arch builds of HuggingFace tokenizers注意:该包已被作者标记为弃用——This package has been archived. Please use the official and updated "huggingface/tokenizers" package.

如何安装 @anush008/tokenizers?

在项目目录运行 npm install @anush008/tokenizers,或使用 pnpm add / yarn add / bun add。

@anush008/tokenizers 支持 TypeScript 吗?

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

@anush008/tokenizers 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@anush008/tokenizers 需要什么版本的 Node.js?

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

@anush008/tokenizers 可以商用吗?

@anush008/tokenizers 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@anush008/tokenizers 的下载量有多少?

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

@anush008/tokenizers 还在维护吗?

最新版本 0.6.0 发布于 2026/03/19(7 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/09/16。作者已将其标记为弃用,新项目建议寻找替代方案。