Toolkit-for-Prompt-Compression: A Unified Toolkit for LLM Prompt Compression

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Toolkit-for-Prompt-Compression: A Unified Toolkit for LLM Prompt Compression

Summary

PCToolkit is a unified, plug-and-play toolkit designed for efficient prompt compression in Large Language Models (LLMs). It provides state-of-the-art compression methods, diverse datasets, and comprehensive metrics for evaluating performance. This modular toolkit simplifies the process of condensing input prompts while preserving crucial information.

Repository Information

Analyzed by OSRepos on December 13, 2025

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

PCToolkit is a unified, plug-and-play prompt compression toolkit for Large Language Models (LLMs). Prompt compression is an innovative method for efficiently condensing input prompts while preserving essential information, crucial for optimizing LLM inference efficiency. This toolkit offers a comprehensive solution, featuring cutting-edge prompt compressors, diverse datasets, and metrics for thorough performance evaluation.

Key features of PCToolkit include:

  • State-of-the-art and reproducible methods: It encompasses five distinct mainstream compression techniques: Selective Context, LLMLingua, LongLLMLingua, SCRL, and Keep it Simple.
  • User-friendly interfaces: Designed for portability and easy adaptation, allowing for simple integration of new compressors, datasets, and metrics.
  • Modular design: Organized into Compressor, Dataset, Metric, and Runner modules, simplifying transitions between different methods and evaluation components.

PCToolkit includes 5 compression methods, 11 datasets, and over 5 metrics, evaluated across various natural language tasks like reconstruction, summarization, mathematical problem-solving, and question answering.

Installation

To get started with PCToolkit, follow these steps:

First, clone the repository:

git clone https://github.com/3DAgentWorld/Toolkit-for-Prompt-Compression.git

Navigate into the cloned directory:

cd Toolkit-for-Prompt-Compression

Then, install the required dependencies:

pip install -r requirements.txt

Please note that while most models can be automatically downloaded from Huggingface Hub, models for the SCRL method require manual download. Refer to the guidance within the /models folder for detailed instructions.

Examples

PCToolkit provides straightforward interfaces for both prompt compression and evaluation.

Prompt Compression

To perform prompt compression, you can use the PromptCompressor class:

from pctoolkit.compressors import PromptCompressor

compressor = PromptCompressor(type='SCCompressor', device='cuda')

test_prompt = "test prompt"
ratio = 0.3
result = compressor.compressgo(test_prompt, ratio)
print(result)

Evaluation

For evaluating compressor performance, follow this example:

from pctoolkit.runners import run
from pctoolkit.datasets import load_dataset
from pctoolkit.metrics import load_metrics
from pctoolkit.compressors import PromptCompressor

compressor = PromptCompressor(type='SCCompressor', device='cuda')
dataset_name = 'arxiv'
dataset = load_dataset(dataset_name)

run(compressor=compressor, dataset=dataset, metrics=load_metrics, ratio=0.1)

Hint: Remember to fill in your Huggingface Tokens and API keys for OpenAI in pctoolkit/runners.py. You can also modify the URLs if you are using other OpenAI APIs. If you wish to change the metrics, specifically for the LongBench dataset, modify pctoolkit/metrics.py.

Why Use PCToolkit?

PCToolkit offers a robust and versatile solution for anyone working with Large Language Models and seeking to optimize prompt efficiency. Its key advantages include:

  • Comprehensive Coverage: Integrates five state-of-the-art prompt compression methods, providing a wide range of options for different use cases.
  • Ease of Use: Features user-friendly interfaces that simplify the process of applying compression techniques and evaluating their impact.
  • Modularity and Extensibility: Its modular design allows for easy integration of new datasets, metrics, and even custom compression methods, making it highly adaptable.
  • Extensive Evaluation: Comes with support for 11 diverse datasets and over 5 metrics, enabling thorough and reproducible evaluation across various NLP tasks.
  • Research and Development Ready: Ideal for researchers and developers looking to experiment with, compare, and build upon existing prompt compression techniques.

Links

Related repositories

Similar repositories that may be relevant next.

AMD Skills: Empowering AI Agents with AMD's Optimized Software Stack

AMD Skills: Empowering AI Agents with AMD's Optimized Software Stack

August 16, 2026

AMD Skills is the official catalog of AI agent skills from AMD, designed to empower AI agents with optimized software for AMD hardware. This repository provides knowledge, scripts, and conventions for working with AMD's stack, enabling seamless integration with major coding agents like Cursor, Claude Code, OpenAI Codex, and Gemini CLI.

PythonAI AgentsMachine Learning
agent-tackle-box: A Terminal Debugger for LangGraph & LangChain Agents

agent-tackle-box: A Terminal Debugger for LangGraph & LangChain Agents

August 15, 2026

agent-tackle-box is a comprehensive toolkit for developing AI agents, featuring the powerful `agent-debugger`. This terminal debugger provides deep insights into LangGraph and LangChain agents. It allows developers to inspect state, monitor tool calls, and step through Python code, all within a unified Textual UI.

agent-debuggerai-agentslangchain
ADR: Uber's Enterprise Security System for AI Agents

ADR: Uber's Enterprise Security System for AI Agents

August 14, 2026

ADR (Agentic AI Detection and Response) is an enterprise security system developed by Uber to secure AI agents. It offers critical capabilities like observability, security benchmarking, and threat detection, ensuring the safe operation of both employee and customer-facing AI applications. This open-source project is deployed in production at Uber and was accepted to MLSys 2026.

PythonAI SecurityAgent Security
SkillOpt: Optimizing Self-Evolving Agent Skills for LLMs

SkillOpt: Optimizing Self-Evolving Agent Skills for LLMs

August 11, 2026

SkillOpt is an innovative text-space optimizer from Microsoft that enables the training of reusable natural-language skills for frozen LLM agents. It approaches skill development with the rigor of deep-learning optimization, using trajectory-driven edits and validation-gated updates. This results in deployable `best_skill.md` artifacts that significantly boost agent performance across various benchmarks and models without modifying model weights.

agent-skillsself-evolving-agentsPython

Source repository

Open the original repository on GitHub.

10 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️