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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@atjsh/llmlingua-2

v2.0.3

Published

JavaScript/TypeScript Implementation of LLMLingua-2

Readme

JavaScript/TypeScript Implementation of LLMLingua-2 (Experimental)

NPM Version License

LLMLingua-2, Originally developed and implemented in Python by Microsoft, is a small-size yet powerful prompt compression method.

  • Efficient: Compresses context prompts with BERT sized models.
  • Accurate: Achieves high accuracy then other methods while requiring less computational resources.

llmlingua-2-js, ported by atjsh, is a pure JavaScript/TypeScript implementation of LLMLingua-2, designed to run in web browsers and Node.js environments.

  • Performance: Everything can be done in the browser. If your environment supports WebGPU, you can use it. Server-side processing is not required by default.
  • Correctness: The original logic will be ported to TypeScript as accurately as possible.

Try Demo Online (No Installation Required)

You can try it on the GitHub Pages without any installation.

The source code for demo is available in the examples directory. You can run it locally using the following command:

cd examples/react-vite-webgpu
yarn install

Learn More: Demo source code

Getting Started

This implementation depends on the following libraries:

Especially, the @huggingface/transformers library utilizes various computational optimizations to achieve high performance. Please consult if the running environment supports the minimum requirements from these libraries.

Installation

You can use the library by downloading the library from npm and importing it into your JavaScript/TypeScript project.

First, install the dependencies:

npm install @huggingface/transformers @tensorflow/tfjs js-tiktoken

Then, install the library:

npm install @atjsh/llmlingua-2

Model Selection

You can choose between models based on your needs.

| Model | Size | Pros | Cons | Public Model | |-----------------|--------|----------------------------|----------------------------------------|--------------| | TinyBERT | 57.1 MB | Very small,fast | Lower accuracythan larger models | atjsh/llmlingua-2-js-tinybert-meetingbank | | MobileBERT | 99.2 MB | Small,optimized for mobile | Moderate accuracy,tradeoff in depth | atjsh/llmlingua-2-js-mobilebert-meetingbank | | BERT | 710 MB | Faster,smaller size | Lower accuracythan XLM-RoBERTa | Arcoldd/llmlingua4j-bert-base-onnx | | XLM-RoBERTa | 2240 MB | High accuracy | Slower,slightly larger in size | atjsh/llmlingua-2-js-xlm-roberta-large-meetingbank |

Learn More about the performance of each model (actual performance may vary).

The model files will be downloaded automatically by default.

API Reference

For more details on how to use the library, please refer to the API reference documentation.

Testing

Unit tests are not available at the moment.

E2E tests are partially available in following directories:

  • src/e2e
  • examples/**

License

See LICENSE for details.

Credits

This software includes other software related under the following licenses:

  • LLMLingua (https://github.com/microsoft/LLMLingua), Copyright (c) Microsoft Corporation. (The original logic and implementation was licensed under the MIT license. For licensing, see: https://github.com/microsoft/LLMLingua/blob/main/LICENSE )