Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
JavaScript NLP libraries analyze text in Node.js and the browser, from splitting it into tokens to tagging words and detecting its language. Local libraries process text with rules, statistics, or pretrained models instead of a hosted API. These libraries let apps and AI agents count model tokens, classify text, and tag parts of speech.
Popularity
OpenAI Node has the most monthly downloads in this comparison, at 223.6M, a count that covers every use of the OpenAI API rather than text analysis alone.
async (event) => {
// Retrieve the translation pipeline. When called for the first time, // this will load the pipeline and save it for future use. const translator = await MyTranslationPipeline.getInstance((x) => {
// We also add a progress callback to the pipeline so that we can // track model loading. self.postMessage(x);
});
// Capture partial output as it streams from the pipeline const streamer = new TextStreamer(translator.tokenizer, {
skip_prompt: true,
skip_special_tokens: true,
callback_function: function (text) {
self.postMessage({
status: "update",
output: text,
});
},
});
// Actually perform the translation const output = await translator(event.data.text, {
tgt_lang: event.data.tgt_lang,
src_lang: event.data.src_lang,
// Allows for partial output streamer,
});
// Send the output back to the main thread self.postMessage({
status: "complete",
output,
});
}
gpt-tokenizer
Encodes text as BPE tokens for OpenAI models in pure JavaScript.
import nlp from 'compromise'
const doc = nlp('she sells seashells by the seashore.')
const past = doc.verbs().toPastTense().text()
FAQ
compromise suits rule-based English tagging and text transformation. Natural suits tokenizers, stemmers, and classifiers in Node.js. Transformers.js suits pretrained models for tasks such as translation and token classification.
The OpenAI moderation API classifies text into predefined moderation categories. OpenAI Node calls it as a hosted service rather than running a local model.
js-tiktoken and gpt-tokenizer encode text into the BPE token IDs that OpenAI models read. Both run locally in pure JavaScript.
Transformers.js runs pretrained NLP pipelines and tokenizers locally in the browser or Node.js. The available tasks and languages depend on the model.
franc-min identifies the language of a text from statistical evidence across the whole text. It returns a language code rather than tags for each word.
For coding agents
Found your NLP library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.