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.

Quick install

  • Install with pip:
pip install coolprompt

Quick start

Import and initialize PromptTuner

from coolprompt.assistant import PromptTuner
  • with default LLM
prompt_tuner = PromptTuner(model=my_model)
  • Or initialize your own LLM by Langchain and use it
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-0.0.20.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

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

coolprompt-0.0.20-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for coolprompt-0.0.20.tar.gz
Algorithm Hash digest
SHA256 2e4918758c650738a174a981efc15d4308e08f087ab630ddea8adb4983bcb2c4
MD5 3cdb225c6c5d9287708a4beeccc405a1
BLAKE2b-256 48b1d6054939cdecbe1f08939741d5481d62d403cfb7241e937623528e10f226

See more details on using hashes here.

Provenance

The following attestation bundles were made for coolprompt-0.0.20.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-0.0.20-py3-none-any.whl.

File metadata

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

File hashes

Hashes for coolprompt-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 dea88537232eea2a0116491c9f9b0d3b6bcd3bd54ce09ffff5adf05be48238cb
MD5 1433406ca0b346915664f0f45134825d
BLAKE2b-256 37231ec64564335acf4d7dc3db857b6cfe8747f8eb10ad34bbcc460e57937679

See more details on using hashes here.

Provenance

The following attestation bundles were made for coolprompt-0.0.20-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