Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
eb20e60
Feature/workflows (#8)
timo282 Oct 3, 2024
1f0119f
Fix/workflows (#11)
timo282 Oct 4, 2024
ba39fd6
Opro implementation (#7)
finitearth Oct 4, 2024
37591b7
Patch/pre commit config (#10)
finitearth Oct 4, 2024
5e2c0a9
Feature/prompt generation (#12)
finitearth Oct 4, 2024
689701a
Create LICENSE (#14)
mo374z Oct 5, 2024
f69bbb2
Refactor/remove deepinfra (#16)
mo374z Oct 9, 2024
1768297
Usability patches (#15)
finitearth Oct 12, 2024
65f02a5
Feature/examplar selection (#17)
finitearth Oct 13, 2024
e23dd74
Chore/docs release notes (#18)
timo282 Oct 13, 2024
25639c9
Merge branch dev accepting all incoming changes
finitearth Oct 13, 2024
2ac359b
revert Chore/docs release notes (#18)"
finitearth Oct 13, 2024
3e650cc
revert last commit
finitearth Oct 13, 2024
3f4c757
updated release notes and read me
finitearth Oct 13, 2024
ac2af13
Feature/read from df (#21)
finitearth Nov 4, 2024
7987f99
Update pyproject.toml
finitearth Nov 19, 2024
7217011
Update release-notes.md
finitearth Nov 19, 2024
2727b6e
merge
finitearth Nov 19, 2024
87fd54c
merge
finitearth Nov 19, 2024
aa6b7d7
Merge branch 'dev' of https://github.com/finitearth/promptolution int…
finitearth Nov 19, 2024
6e69b58
merges
finitearth Nov 19, 2024
e935fa2
resolve merge mistakes
finitearth Nov 19, 2024
68c67f3
delete duplicated lines
finitearth Nov 19, 2024
bee6d8d
Update release-notes.md (#24)
mo374z Nov 19, 2024
3ca7893
Fix/dependencies (#28)
finitearth Feb 21, 2025
d6203d6
Merge branch 'main' into dev
timo282 Feb 21, 2025
683d926
Add vllm as feature and a llm_test_run_script
mo374z Mar 3, 2025
69837fa
small fixes in vllm class
mo374z Mar 3, 2025
7563712
differentiate between vllm and api inference
mo374z Mar 3, 2025
af6f9f8
set up experiment over multiple tasks and prompts
mo374z Mar 3, 2025
bc9997a
change csv saving
mo374z Mar 3, 2025
7958b86
add base llm super class
mo374z Mar 4, 2025
e82db35
add changes from PR review
mo374z Mar 4, 2025
0045de7
change some VLLM params
mo374z Mar 5, 2025
0b3c7cb
fix tensor parallel size to 1
mo374z Mar 5, 2025
a73c378
experiment with batch size
mo374z Mar 5, 2025
1f68410
experiment with larger batch sizes
mo374z Mar 5, 2025
f5fe188
add continuous batch llm
mo374z Mar 5, 2025
1330a9e
remove arg
mo374z Mar 5, 2025
c6dbb7b
remove continuous batch inference try
mo374z Mar 5, 2025
42ab6c9
add batching to vllm
mo374z Mar 5, 2025
0be3d06
add batching in script
mo374z Mar 5, 2025
16514f4
Merge branch 'dev' of https://github.com/finitearth/promptolution int…
timo282 Mar 5, 2025
c5ac101
Add release notes and increase version number
timo282 Mar 5, 2025
0eb701b
remove llm_test_run.py script
mo374z Mar 5, 2025
f4f9722
Merge branch 'feature/vllm' of https://github.com/finitearth/promptol…
mo374z Mar 5, 2025
fae0113
change system prompt
mo374z Mar 5, 2025
b6440c7
Merge pull request #30 from finitearth/feature/vllm
mo374z Mar 5, 2025
b61c9ee
Fix/vllm (#33)
mo374z Mar 9, 2025
2f6f499
Merge branch 'main' into dev
mo374z Mar 9, 2025
b873ee0
implement changes from review
mo374z Mar 9, 2025
739e568
Merge branch 'dev' of https://github.com/finitearth/promptolution int…
mo374z Mar 9, 2025
ec5b709
add typing to token count callback
mo374z Mar 9, 2025
d2fecf7
Feature/deterministic (#35)
mo374z Mar 12, 2025
1f6a4f7
Fix/prompt creation (#36)
finitearth Mar 12, 2025
7858b49
Merge branch 'main' of https://github.com/finitearth/promptolution in…
mo374z Mar 12, 2025
89fa8b2
Merge branch 'dev' of https://github.com/finitearth/promptolution int…
mo374z Mar 12, 2025
7f5a26d
add arguements to test script
mo374z Mar 12, 2025
39b0779
added some feature notes
mo374z Mar 12, 2025
03fec71
Fix/template (#39)
finitearth Mar 20, 2025
02b6193
Fix/opro (#38)
finitearth Mar 20, 2025
3e86324
Merge branch 'main' of https://github.com/finitearth/promptolution in…
mo374z Mar 20, 2025
5d33d97
Refactor/generic api llm (#41)
finitearth Apr 17, 2025
2afa79e
Refactor/interfaces (#42)
finitearth Apr 20, 2025
cfbb22b
Merge branch 'main' into dev
finitearth Apr 20, 2025
3020c57
Remove obsolete Docstring
finitearth Apr 20, 2025
8bd84e3
remove redundant init
finitearth Apr 20, 2025
cfd9a67
remove redundant init
finitearth Apr 20, 2025
f11a7e1
resolve merge chaos
finitearth Apr 20, 2025
4d28bbf
formatting
finitearth Apr 20, 2025
2af0c97
alternated task to work for capo
finitearth May 10, 2025
0b39384
Merge branch 'dev' into feature/welcome_capo
finitearth May 10, 2025
6bce01b
bug fixes
finitearth May 10, 2025
e8eb52e
Merge branch 'feature/welcome_capo' of https://github.com/finitearth/…
finitearth May 10, 2025
3513d5a
formatting
finitearth May 10, 2025
84aaff7
update task interface and preds and eval cache
finitearth May 14, 2025
275c2d2
fix vllm and capo
finitearth May 14, 2025
22dbce4
fix nans when evaluate strategy
finitearth May 14, 2025
ffb7b02
fix tests
finitearth May 15, 2025
9002254
finalized testing
finitearth May 15, 2025
efee364
fix vllm tests
finitearth May 15, 2025
66925d5
fix vllm mocking
finitearth May 15, 2025
e429add
fix capo docstring
finitearth May 15, 2025
0e5b0bc
update getting_started notebook to include capo
finitearth May 15, 2025
c47bdc6
formatting
finitearth May 15, 2025
0639c3e
formatting
finitearth May 15, 2025
5e85170
formatting
finitearth May 15, 2025
2a443bc
formatting and docstring fix
finitearth May 16, 2025
95c261e
implemented comments
finitearth May 16, 2025
a9bd076
implemented comments
finitearth May 16, 2025
e948df4
fix tests
finitearth May 16, 2025
6a406ea
fix tests
finitearth May 16, 2025
58d7d5d
fix tests
finitearth May 16, 2025
027e07e
fixed docstrings and naming
finitearth May 17, 2025
a523e30
clear inits
finitearth May 17, 2025
45882f4
remove dummy classes
finitearth May 17, 2025
1474428
standardize logging
finitearth May 17, 2025
68b2c63
fix imports
finitearth May 17, 2025
2e23115
logging
finitearth May 17, 2025
ac5760d
merge
finitearth May 17, 2025
ada08da
fix imports once more
finitearth May 17, 2025
956cfb6
remove n_eval_samples argument from tests
mo374z May 17, 2025
8461804
resolve merge issues
mo374z May 17, 2025
d4fc71c
merge from main
finitearth May 18, 2025
82ce296
comments
finitearth May 18, 2025
2f810f8
comments
finitearth May 18, 2025
0cf9d2a
Update coverage badge in README [skip ci]
finitearth May 18, 2025
a16f1c0
added realese notes
finitearth May 18, 2025
a891ed3
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
finitearth May 18, 2025
4fede66
fix import bug
finitearth May 18, 2025
459d00b
release notes
finitearth May 18, 2025
c5436df
Update readme and fix imports
mo374z May 18, 2025
00346eb
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
mo374z May 18, 2025
f9e4a0a
fix release notes
mo374z May 18, 2025
ec7da81
changed v2.0.0.md
finitearth May 19, 2025
687b5be
merge
finitearth May 19, 2025
fe7b1a5
formatting
finitearth May 19, 2025
e3ca59a
Update coverage badge in README [skip ci]
finitearth May 19, 2025
b2e3187
fix imports once more
finitearth May 19, 2025
f9576b0
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
finitearth May 19, 2025
c759f26
apply pre-commit everywhere
finitearth May 19, 2025
4ce32b4
apply pre-commit everywwhere
finitearth May 19, 2025
aae962b
fix imports and typings
finitearth May 19, 2025
05be7c7
fix helpers
finitearth May 19, 2025
ec23db8
fix demo scripts
finitearth May 19, 2025
0804892
formatting
finitearth May 19, 2025
06361a4
Update coverage badge in README [skip ci]
finitearth May 19, 2025
440519b
fix tests
finitearth May 19, 2025
d440cd1
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
finitearth May 19, 2025
2e9d602
Update coverage badge in README [skip ci]
finitearth May 19, 2025
9922d76
remove convergence speed from read me
finitearth May 19, 2025
934b6a1
rename Opro to OPRO
finitearth May 19, 2025
d5cd78f
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
finitearth May 19, 2025
26e720d
changed imports in isort
finitearth May 19, 2025
f9c50dd
Update API reference in docs
timo282 May 19, 2025
1309c33
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
timo282 May 19, 2025
d64acf4
Update README.md
finitearth May 19, 2025
66bff5e
Update README.md
finitearth May 19, 2025
d07c5e6
Update README.md
finitearth May 19, 2025
61a0810
Update README.md
finitearth May 19, 2025
e7a926f
Update README.md
finitearth May 19, 2025
d1f4946
Update README.md
finitearth May 19, 2025
6128f82
fixed task description in notebook
finitearth May 19, 2025
9d809fa
Merge branch 'fix/naming_and_docs' of https://github.com/finitearth/p…
finitearth May 19, 2025
72ab156
Update v2.0.0.md
finitearth May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .coverage
Binary file not shown.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python and Poetry
uses: ./.github/actions/python-poetry
with:
groups: main,dev,test

- name: Run pre-commit
uses: pre-commit/action@v3.0.1

- name: Run tests with coverage
run: |
poetry run python -m pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=. tests/ | tee pytest-coverage.txt

- name: Generate coverage report & comment on PR
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
hide-report: true

- name: Update README with coverage badge
run: |
cat > update_readme.py << 'EOF'
Expand All @@ -54,15 +54,15 @@ jobs:
with open('README.md', 'r') as f:
content = f.read()
new_content = re.sub(
r'!\[Coverage\]\(https://img\.shields\.io/badge/Coverage-[^)]+\)',
badge_md,
r'!\[Coverage\]\(https://img\.shields\.io/badge/Coverage-[^)]+\)',
badge_md,
content
)
with open('README.md', 'w') as f:
f.write(new_content)
EOF
python update_readme.py

- name: Commit coverage updates to README
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand All @@ -77,15 +77,15 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python and Poetry
uses: ./.github/actions/python-poetry

- name: Build wheel
run: poetry build --format wheel

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: dist/
path: dist/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fail_fast: true
exclude: '^(?!(promptolution/|tests/)).*$|^promptolution/templates.py'
exclude: '^.*\.md$'
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.2
Expand Down Expand Up @@ -46,4 +46,4 @@ repos:
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
args: []
93 changes: 62 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
![promptolution](https://github.com/user-attachments/assets/84c050bd-61a1-4f2e-bc4e-874d9b4a69af)


![Coverage](https://img.shields.io/badge/Coverage-90%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-87%25-green)
[![CI](https://github.com/finitearth/promptolution/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/finitearth/promptolution/actions/workflows/ci.yml)
[![Docs](https://github.com/finitearth/promptolution/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/finitearth/promptolution/actions/workflows/docs.yml)
![Code Style](https://img.shields.io/badge/Code%20Style-black-black)
![Python Versions](https://img.shields.io/badge/Python%20Versions-≥3.9-blue)

# Promptolution

Promptolution is a library that provides a modular and extensible framework for implementing prompt tuning experiments. It offers a user-friendly interface to assemble the core components for various prompt optimization tasks.

This project was developed by [Timo Heiß](https://www.linkedin.com/in/timo-heiss/), [Moritz Schlager](https://www.linkedin.com/in/moritz-schlager/) and [Tom Zehle](https://www.linkedin.com/in/tom-zehle/).
Promptolution is a library that provides a modular and extensible framework for implementing prompt tuning for single tasks and larger experiments. It offers a user-friendly interface to assemble the core components for various prompt optimization tasks.

## Getting Started
Take a look at our getting started notebook: [getting_started.ipynb](https://github.com/finitearth/promptolution/blob/main/notebooks/getting_started.ipynb)
This project was developed by [Timo Heiß](https://www.linkedin.com/in/timo-heiss/), [Moritz Schlager](https://www.linkedin.com/in/moritz-schlager/) and [Tom Zehle](https://www.linkedin.com/in/tom-zehle/) as part of a study program at LMU Munich.

## Installation

Expand All @@ -30,7 +26,6 @@ If you want to run your prompt optimization locally, either via transformers or
pip install promptolution[vllm,transformers]
```


Alternatively, clone the repository, run

```
Expand All @@ -39,34 +34,28 @@ poetry install

to install the necessary dependencies. You might need to install [pipx](https://pipx.pypa.io/stable/installation/) and [poetry](https://python-poetry.org/docs/) first.

## Documentation

A comprehensive documentation with API reference is availabe at https://finitearth.github.io/promptolution/.

## Usage

Create API Keys for the models you want to use:
- OpenAI: store token in openaitoken.txt
- Anthropic: store token in anthropictoken.txt
- DeepInfra (for Llama): store token in deepinfratoken.txt
To get started right away, take a look at our [getting started notebook](https://github.com/finitearth/promptolution/blob/main/notebooks/getting_started.ipynb).
For more details, a comprehensive **documentation** with API reference is availabe at https://finitearth.github.io/promptolution/.

## Optimization Algorithms to choose from
| **Name** | **Paper** | **init prompts** | **Exploration** | **Costs** | **Convergence Speed** | **Parallelizable** | **Utilizes Fewshot Examples** |
|:--------:|:-------:|:--------------:|:---------------:|:---------:|:---------------------:|:------------------:|:---------------------:|
| `CAPO` | [Zehle et al.](https://arxiv.org/abs/2504.16005)| *required* | 👍 | 💲 | ⚡⚡ | ✅ | ✅ |
| `EvoPromptDE` | [Guo et al.](https://arxiv.org/abs/2309.08532) | *required* | 👍 | 💲💲 | ⚡⚡ | ✅ | ❌ |
| `EvoPromptGA` | [Guo et al.](https://arxiv.org/abs/2309.08532) | *required* | 👍 | 💲💲 | ⚡⚡ | ✅ | ❌ |
| `OPRO` | [Yang et al.](https://arxiv.org/abs/2309.03409)| *optional* | 👎 | 💲💲 | ⚡ | ❌ | ❌ |
### Featured Optimizers

## Core Components
| **Name** | **Paper** | **init prompts** | **Exploration** | **Costs** | **Parallelizable** | **Utilizes Fewshot Examples** |
| :-----------: | :----------------------------------------------: | :--------------: | :-------------: | :-------: | :-------------------: | :---------------------------: |
| `CAPO` | [Zehle et al.](https://arxiv.org/abs/2504.16005) | _required_ | 👍 | 💲 | ✅ | ✅ |
| `EvoPromptDE` | [Guo et al.](https://arxiv.org/abs/2309.08532) | _required_ | 👍 | 💲💲 | ✅ | ❌ |
| `EvoPromptGA` | [Guo et al.](https://arxiv.org/abs/2309.08532) | _required_ | 👍 | 💲💲 | ✅ | ❌ |
| `OPRO` | [Yang et al.](https://arxiv.org/abs/2309.03409) | _optional_ | 👎 | 💲💲 | ❌ | ❌ |

- Task: Encapsulates initial prompts, dataset features, targets, and evaluation methods.
- Predictor: Implements the prediction logic, interfacing between the Task and LLM components.
- LLM: Unifies the process of obtaining responses from language models, whether locally hosted or accessed via API.
- Optimizer: Implements prompt optimization algorithms, utilizing the other components during the optimization process.
- Exemplar Selectors: Implements algorithms for the search of few shot examples that are added to the prompt.
### Core Components

## Key Features
- `Task`: Encapsulates initial prompts, dataset features, targets, and evaluation methods.
- `Predictor`: Implements the prediction logic, interfacing between the `Task` and `LLM` components.
- `LLM`: Unifies the process of obtaining responses from language models, whether locally hosted or accessed via API.
- `Optimizer`: Implements prompt optimization algorithms, utilizing the other components during the optimization process.

### Key Features

- Modular and object-oriented design
- Extensible architecture
Expand All @@ -75,6 +64,48 @@ Create API Keys for the models you want to use:
- Integration with langchain for standardized LLM API calls
- Detailed logging and callback system for optimization analysis

## Changelog

Release notes for each version of the library can be found [here](https://finitearth.github.io/promptolution/release-notes/)

## Contributing

The first step to contributing is to open an issue describing the bug, feature, or enhancements. Ensure the issue is clearly described, assigned, and properly tagged. All work should be linked to an open issue.

### Code Style and Linting

We use Black for code formatting, Flake8 for linting, pydocstyle for docstring conventions (Google format), and isort to sort imports. All these checks are enforced via pre-commit hooks, which automatically run on every commit. Install the pre-commit hooks to ensure that all checks run automatically:

```
pre-commit install
```

To run all checks manually:

This project was developed for the "AutoML in the age of large pre-trained models" seminar at LMU Munich.
```
pre-commit run --all-files
```

### Branch Protection and Merging Guidelines

- The main branch is protected. No direct commits are allowed for non-administrators.
- Rebase your branch on main before opening a pull request.
- All contributions must be made on dedicated branches linked to specific issues.
- Name the branch according to {prefix}/{description} with one of the prefixes fix, feature, chore, or refactor.
- A pull request must have at least one approval from a code owner before it can be merged into main.
- CI checks must pass before a pull request can be merged.
- New releases will only be created by code owners.

### Testing

We use pytest to run tests, and coverage to track code coverage. Tests automatically run on pull requests and pushes to the main branch, but please ensure they also pass locally before pushing!
To run the tests with coverage locally, use the following commands or your IDE's test runner:

```
poetry run python -m coverage run -m pytest
```

To see the coverage report run:
```
poetry run python -m coverage report
```
7 changes: 0 additions & 7 deletions docs/api/config.md

This file was deleted.

5 changes: 5 additions & 0 deletions docs/api/exemplar_selectors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Exemplar Selectors

::: promptolution.exemplar_selectors
options:
show_submodules: true
4 changes: 2 additions & 2 deletions docs/api/callbacks.md → docs/api/helpers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Callbacks
# Helpers

::: promptolution.callbacks
::: promptolution.helpers
options:
show_submodules: true
5 changes: 5 additions & 0 deletions docs/api/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Utils

::: promptolution.utils
options:
show_root_heading: true
Loading
Loading