fasttextembed
v1.0.2
Published
Fast, dependency-free text embeddings (BAAI/bge-small-en-v1.5) — pure C compiled to WASM
Maintainers
Readme
fasttextembed (Node / JS)
Fast, dependency-free text embeddings for BAAI/bge-small-en-v1.5 — the pure-C engine compiled to
WebAssembly (runs in Node and the browser). The model (~64 MB) downloads and caches on first use.
npm install fasttextembedconst { TextEmbedding } = require("fasttextembed");
const model = await TextEmbedding.create(); // downloads + caches the model on first call
const vectors = model.embed(["hello world", "fast"]); // array of 384-float vectors
const one = model.embedOne("hello world");embed(texts)— batch;embedOne(text)— single.WASM backend is single-threaded and portable; an optional native N-API addon is used automatically if present (multi-threaded, SIMD, ~2× faster — Node-only). Build it with:
npm run build:native # compiles native/ via node-gyp (needs a C compiler + Python)Once built,
require("fasttextembed")loads the native addon and transparently falls back to WASM if it isn't available.Env:
FTE_MODEL_DIR(localmodel.fte/vocab.tsv),FTE_MODEL_URL,FTE_CACHE.
In the browser, pass model bytes directly: TextEmbedding.create({ fte: Uint8Array, vocab: Uint8Array }).
