Socket
Book a DemoInstallSign in
Socket

@atjsh/llmlingua-2

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atjsh/llmlingua-2

JavaScript/TypeScript Implementation of LLMLingua-2

2.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

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.

ModelSizeProsConsPublic Model
TinyBERT57.1 MBVery small,
fast
Lower accuracy
than larger models
atjsh/llmlingua-2-js-tinybert-meetingbank
MobileBERT99.2 MBSmall,
optimized for mobile
Moderate accuracy,
tradeoff in depth
atjsh/llmlingua-2-js-mobilebert-meetingbank
BERT710 MBFaster,
smaller size
Lower accuracy
than XLM-RoBERTa
Arcoldd/llmlingua4j-bert-base-onnx
XLM-RoBERTa2240 MBHigh accuracySlower,
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:

Keywords

llmlingua

FAQs

Package last updated on 27 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.