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

Contributing

  • We welcome and value any contributions and collaborations, so please contact us. For new code check out CONTRIBUTING.md.

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.2.tar.gz (33.3 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.2-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coolprompt-1.0.2.tar.gz
  • Upload date:
  • Size: 33.3 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.2.tar.gz
Algorithm Hash digest
SHA256 3ca5930536e5d6551cd187b2bc5a77c75bc915ec9c15472b2b5fe15bc32db418
MD5 585d0e606914aeccaebb8f98ac7baa56
BLAKE2b-256 b46c44d75e58de2c751d15a9e7bdd2dc1ee65696ac57dc2a5071efa1b9416633

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: coolprompt-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 40.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 84588b61647b6c04f1f12a85b9236d86c380cf6736c0d73b46db03bddf8ac948
MD5 c92a6ba9a9e8868a5172b1ae79322ce3
BLAKE2b-256 224289d78a4b7ebffed77d0f8628f6f67ad3823bdb93248dabdaaac79791a8ec

See more details on using hashes here.

Provenance

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