prompt-optimizer  by vaibkumr

CLI tool to minimize LLM token complexity, reducing API costs

created 2 years ago
280 stars

Top 93.9% on sourcepulse

GitHubView on GitHub
Project Summary

This library offers a plug-and-play solution for minimizing Large Language Model (LLM) prompt token complexity, directly addressing API cost reduction and computational efficiency. It's designed for developers and businesses seeking to optimize LLM interactions without needing access to model weights or decoding algorithms, making it broadly applicable to various NLU systems.

How It Works

PromptOptimizer employs a suite of optimization methods that operate directly on prompt text. These techniques, such as synonym replacement, lemmatization, and punctuation removal, aim to reduce token count while preserving semantic meaning. The library allows for sequential chaining of these optimizers and includes "protected tags" to safeguard critical prompt sections, offering a flexible approach to prompt engineering.

Quick Start & Requirements

  • Install via pip: pip install prompt-optimizer
  • Requires Python.
  • See Docs for detailed usage.

Highlighted Details

  • Offers "Plug and Play Optimizers" applicable to virtually all NLU systems.
  • Supports Langchain and OpenAI JSON request formats.
  • Provides metrics for token reduction and semantic similarity.
  • Evaluated on LogiQA task, showing up to 26% token reduction with a 10% accuracy drop.

Maintenance & Community

  • Active development indicated by GitHub Actions badges for linting, testing, and link checking.
  • Contact available via Twitter handles.

Licensing & Compatibility

  • Licensed under the MIT License, permitting commercial use and closed-source linking.

Limitations & Caveats

A compression versus performance tradeoff exists; increased compression may lead to a loss in LLM performance, which can be mitigated by selecting appropriate optimizers and tuning hyperparameters. No single optimizer is universally optimal for all tasks.

Health Check
Last commit

1 year ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
8 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Stas Bekman Stas Bekman(Author of Machine Learning Engineering Open Book; Research Engineer at Snowflake), and
1 more.

tokenmonster by alasdairforsythe

0.7%
594
Subword tokenizer and vocabulary trainer for multiple languages
created 2 years ago
updated 1 year ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Andreas Jansson Andreas Jansson(Cofounder of Replicate), and
1 more.

lm-format-enforcer by noamgat

0.1%
2k
Format enforcer for language model outputs (JSON, regex, etc.)
created 1 year ago
updated 5 months ago
Feedback? Help us improve.