Framework for automative prompting creation and optimization
Project description
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()
- or customize your own LLM using supported Langchain LLMs
- List of available LLMs: https://python.langchain.com/docs/integrations/llms/
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
methodintuner.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e54f6f1e5f3b71ba94a9028b1fe2b7c053dbafc651a0e6ae698e4b41f54d7d06
|
|
| MD5 |
d1c76c755284328f14f49ae9c4d82245
|
|
| BLAKE2b-256 |
d0c65971b80df1c89c18cbf4010331e8e69b12e4ccc2c01b4de124d23ff78864
|
Provenance
The following attestation bundles were made for coolprompt-1.0.1.tar.gz:
Publisher:
workflow.yml on CTLab-ITMO/CoolPrompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coolprompt-1.0.1.tar.gz -
Subject digest:
e54f6f1e5f3b71ba94a9028b1fe2b7c053dbafc651a0e6ae698e4b41f54d7d06 - Sigstore transparency entry: 273473768
- Sigstore integration time:
-
Permalink:
CTLab-ITMO/CoolPrompt@b412834616ece4cd28bfbfea0b8085087227004c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/CTLab-ITMO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@b412834616ece4cd28bfbfea0b8085087227004c -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c37a4eaea89c0a5a027748b74a09009ed1368d4b4bcaa3583253ca704d5f6c5
|
|
| MD5 |
ac267a21379b00cf84efb5263c0060af
|
|
| BLAKE2b-256 |
ac2c722e75d404a5579f8811b6bc2643c4c67c3e0b05b892f109599f1ac16c99
|
Provenance
The following attestation bundles were made for coolprompt-1.0.1-py3-none-any.whl:
Publisher:
workflow.yml on CTLab-ITMO/CoolPrompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coolprompt-1.0.1-py3-none-any.whl -
Subject digest:
2c37a4eaea89c0a5a027748b74a09009ed1368d4b4bcaa3583253ca704d5f6c5 - Sigstore transparency entry: 273473770
- Sigstore integration time:
-
Permalink:
CTLab-ITMO/CoolPrompt@b412834616ece4cd28bfbfea0b8085087227004c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/CTLab-ITMO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@b412834616ece4cd28bfbfea0b8085087227004c -
Trigger Event:
release
-
Statement type: