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

@nvdigitalsolutions/nvoos-transformers-client

v0.1.0-alpha.3

Published

HuggingFace Transformers.js task wrapper (summarization, sentiment, NER, translation, QA, embeddings) - Extracted from NV Open Operator System

Readme

@nvdigitalsolutions/nvoos-transformers-client

Browser-native AI tasks via HuggingFace Transformers.js v3: summarization, sentiment analysis, named entity recognition, translation, question answering, and embeddings — with WebGPU acceleration and automatic WASM fallback.

Extracted from: NV Open Operator System (oOS) WordPress Plugin

Why This Package?

Transformers.js is powerful but boilerplate-heavy. You need to:

  • Detect WebGPU vs WASM
  • Pick correct quantization (dtype)
  • Lazy-load a pipeline per task
  • Cache pipelines across calls
  • Handle progress callbacks
  • Group sub-token NER outputs into entities

This package handles all of that and exposes one method per task. Pipelines are cached per (task, model) pair, so repeat calls cost only inference.

Installation

npm install @nvdigitalsolutions/nvoos-transformers-client

The @huggingface/transformers package is loaded at runtime (default: from a CDN) so the dependency is optional. If you want to bundle it yourself, install it as a peer:

npm install @huggingface/transformers

…and pass an importer (see Bundled Transformers.js below).

Quick Start

import { TransformersTasksClient } from '@nvdigitalsolutions/nvoos-transformers-client';

const client = new TransformersTasksClient();

// Summarization
const sum = await client.summarize('Your long article text here…');
console.log(sum.summary);

// Sentiment
const sent = await client.sentiment('I love this product!');
console.log(sent.label, sent.confidence);

// Named entities
const ents = await client.extractEntities('Barack Obama visited Paris.');
console.log(ents.entities);

// Translation
const tr = await client.translate('Hello world', {
  sourceLang: 'eng_Latn',
  targetLang: 'fra_Latn'
});
console.log(tr.translatedText);

// QA
const ans = await client.questionAnswering(
  'Where is Paris?',
  'Paris is the capital of France.'
);
console.log(ans.answer, ans.confidence);

// Embeddings (semantic search)
const embed = await client.embed(['hello', 'goodbye']);
console.log(embed.embeddings.length, embed.dimensions);

API

new TransformersTasksClient(options?)

  • options.transformersUrl (string): URL of the @huggingface/transformers ESM build. Defaults to the v3.8.1 jsdelivr CDN.
  • options.transformersImporter (function): () => Promise<module>. Lets you supply a bundled import — overrides transformersUrl when set.
  • options.device ('webgpu' | 'wasm' | null): force a backend. null (default) auto-detects.
  • options.dtype (string): quantization dtype. Default 'q8'.
  • options.models (object): override any of the default model identifiers.

.configure(options)

Update any of the constructor options after construction.

Task methods

All return { success: true, ... } and lazy-load their pipeline on first call.

| Method | Returns | |--------|---------| | summarize(text, { maxLength?, minLength? }) | { summary, originalLength, summaryLength } | | sentiment(text) | { label, score, confidence } | | extractEntities(text) | { entities: [{text, type, score}], count } | | translate(text, { sourceLang?, targetLang? }) | { translatedText, sourceLang, targetLang } | | questionAnswering(question, context) | { answer, score, confidence, start, end } | | embed(text \| string[]) | { embeddings: number[][], dimensions } |

Utility

  • .detectDevice() → 'webgpu' \| 'wasm'
  • .getPipeline(task, model) → Promise<pipeline>
  • .isTaskAvailable(task) → boolean
  • .getAvailableTasks() → string[]
  • .clearCache() → void

Default Models

| Task | Model | |------|-------| | summarization | Xenova/distilbart-cnn-6-6 | | sentiment | Xenova/distilbert-base-uncased-finetuned-sst-2-english | | ner | Xenova/bert-base-NER | | translation | Xenova/nllb-200-distilled-600M | | qa | Xenova/distilbert-base-uncased-distilled-squad | | embedding | Xenova/all-MiniLM-L6-v2 |

Override any of these via new TransformersTasksClient({ models: { sentiment: 'your/model' } }).

Bundled Transformers.js

If you'd rather bundle Transformers.js with your app:

import * as transformers from '@huggingface/transformers';
import { TransformersTasksClient } from '@nvdigitalsolutions/nvoos-transformers-client';

const client = new TransformersTasksClient({
  transformersImporter: async () => transformers
});

Browser Support

  • WebGPU acceleration on Chrome/Edge 113+
  • WASM fallback in any modern browser
  • Requires import() (dynamic imports)

From WordPress to Universal

  • ❌ Removed: window.WP_MCP_AI_TransformersTasksClient global initialisation
  • ❌ Removed: hard-coded jsdelivr import URL (still default, now configurable)
  • ✅ Added: transformersImporter for bundled installs
  • ✅ Added: configurable device, dtype, and per-task models
  • ✅ Added: configure() method
  • ✅ Added: ES module exports + TypeScript definitions

License

MIT © NV Digital Solutions

Links