Skip to main content

Framework for automative prompting creation and optimization

Project description

CoolPrompt Logo

Release Notes PyPI - License PyPI - Downloads GitHub star chart Open Issues ITMO

English | Русский

CoolPrompt is a framework for automative prompting creation and optimization.

Practical cases

  • Automatic prompt engineering for solving tasks using LLM
  • (Semi-)automatic generation of markup for fine-tuning
  • Formalization of response quality assessment using LLM
  • Prompt tuning for agent systems

Quick install

  • Install with pip:
pip install coolprompt
  • Install with git:
git clone https://github.com/CTLab-ITMO/CoolPrompt.git

pip install -r requirements.txt

Quick start

Import and initialize PromptTuner

from coolprompt.assistant import PromptTuner
  • with default LLM
prompt_tuner = PromptTuner()
from langchain_community.llms import VLLM

my_model = VLLM(
    model="Qwen/Qwen2.5-Coder-32B-Instruct",
    trust_remote_code=True,
    dtype='bfloat16',
)

prompt_tuner = PromptTuner(model=my_model)

Running PromptTuner

  • Run PromptTuner instance with initial prompt
# Define an initial prompt
prompt = "Make a summarization of 2+2"

# Run a prompt optimisation
new_prompt = tuner.run(start_prompt=prompt)

# Get your new prompt
print(new_prompt)
  • including a dataset for prompt optimization and evaluation. A provided dataset will be split by trainset and testset.
sst2 = load_dataset("sst2")
class_dataset = sst2['train']['sentence']
class_targets = sst2['train']['label']

tuner.run(
    start_prompt=class_start_prompt,
    task="classification",
    dataset=class_dataset,
    target=class_targets,
    metric="accuracy"
)
  • to get a final prompt and prompt metrics
print("Final prompt:", tuner.final_prompt)
print("Start prompt metric:", tuner.init_metric)
print("Final prompt metric:", tuner.final_metric)
  • This also works for generation tasks

More about project

  • Explore the variety of autoprompting methods with PromptTuner: CoolPrompt currently support HyPE, DistillPrompt, ReflectivePrompt. You can choose method via corresponding argument method in tuner.run
  • See more examples in notebooks to familiarize yourself with our framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coolprompt-1.0.1.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coolprompt-1.0.1-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file coolprompt-1.0.1.tar.gz.

File metadata

  • Download URL: coolprompt-1.0.1.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for coolprompt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e54f6f1e5f3b71ba94a9028b1fe2b7c053dbafc651a0e6ae698e4b41f54d7d06
MD5 d1c76c755284328f14f49ae9c4d82245
BLAKE2b-256 d0c65971b80df1c89c18cbf4010331e8e69b12e4ccc2c01b4de124d23ff78864

See more details on using hashes here.

Provenance

The following attestation bundles were made for coolprompt-1.0.1.tar.gz:

Publisher: workflow.yml on CTLab-ITMO/CoolPrompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coolprompt-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: coolprompt-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for coolprompt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c37a4eaea89c0a5a027748b74a09009ed1368d4b4bcaa3583253ca704d5f6c5
MD5 ac267a21379b00cf84efb5263c0060af
BLAKE2b-256 ac2c722e75d404a5579f8811b6bc2643c4c67c3e0b05b892f109599f1ac16c99

See more details on using hashes here.

Provenance

The following attestation bundles were made for coolprompt-1.0.1-py3-none-any.whl:

Publisher: workflow.yml on CTLab-ITMO/CoolPrompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page