weco 0.2.17__tar.gz → 0.2.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {weco-0.2.17 → weco-0.2.18}/PKG-INFO +10 -39
- {weco-0.2.17 → weco-0.2.18}/README.md +8 -38
- {weco-0.2.17 → weco-0.2.18}/examples/prompt/README.md +0 -48
- {weco-0.2.17 → weco-0.2.18}/examples/spaceship-titanic/README.md +7 -32
- weco-0.2.18/examples/spaceship-titanic/data/sample_submission.csv +4278 -0
- weco-0.2.18/examples/spaceship-titanic/data/test.csv +4278 -0
- weco-0.2.18/examples/spaceship-titanic/data/train.csv +8694 -0
- {weco-0.2.17 → weco-0.2.18}/examples/spaceship-titanic/requirements-test.txt +1 -2
- {weco-0.2.17 → weco-0.2.18}/pyproject.toml +5 -7
- {weco-0.2.17 → weco-0.2.18}/weco/__init__.py +2 -1
- weco-0.2.18/weco/api.py +162 -0
- {weco-0.2.17 → weco-0.2.18}/weco/cli.py +161 -11
- {weco-0.2.17 → weco-0.2.18}/weco/panels.py +1 -1
- {weco-0.2.17 → weco-0.2.18}/weco/utils.py +32 -0
- {weco-0.2.17 → weco-0.2.18}/weco.egg-info/PKG-INFO +10 -39
- {weco-0.2.17 → weco-0.2.18}/weco.egg-info/SOURCES.txt +3 -2
- {weco-0.2.17 → weco-0.2.18}/weco.egg-info/requires.txt +1 -0
- weco-0.2.17/examples/spaceship-titanic/get_data.py +0 -16
- weco-0.2.17/examples/spaceship-titanic/submit.py +0 -14
- weco-0.2.17/weco/api.py +0 -86
- {weco-0.2.17 → weco-0.2.18}/.github/workflows/lint.yml +0 -0
- {weco-0.2.17 → weco-0.2.18}/.github/workflows/release.yml +0 -0
- {weco-0.2.17 → weco-0.2.18}/.gitignore +0 -0
- {weco-0.2.17 → weco-0.2.18}/.repomixignore +0 -0
- {weco-0.2.17 → weco-0.2.18}/LICENSE +0 -0
- {weco-0.2.17 → weco-0.2.18}/assets/example-optimization.gif +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/cuda/README.md +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/cuda/evaluate.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/cuda/guide.md +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/cuda/optimize.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/hello-kernel-world/evaluate.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/hello-kernel-world/optimize.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/prompt/eval.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/prompt/optimize.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/prompt/prompt_guide.md +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/spaceship-titanic/competition_description.md +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/spaceship-titanic/evaluate.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/triton/README.md +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/triton/evaluate.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/examples/triton/optimize.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/setup.cfg +0 -0
- {weco-0.2.17 → weco-0.2.18}/weco/auth.py +0 -0
- {weco-0.2.17 → weco-0.2.18}/weco.egg-info/dependency_links.txt +0 -0
- {weco-0.2.17 → weco-0.2.18}/weco.egg-info/entry_points.txt +0 -0
- {weco-0.2.17 → weco-0.2.18}/weco.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weco
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.18
|
|
4
4
|
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
5
|
Author-email: Weco AI Team <contact@weco.ai>
|
|
6
6
|
License: MIT
|
|
@@ -14,6 +14,7 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: requests
|
|
16
16
|
Requires-Dist: rich
|
|
17
|
+
Requires-Dist: packaging
|
|
17
18
|
Provides-Extra: dev
|
|
18
19
|
Requires-Dist: ruff; extra == "dev"
|
|
19
20
|
Requires-Dist: build; extra == "dev"
|
|
@@ -22,15 +23,13 @@ Dynamic: license-file
|
|
|
22
23
|
|
|
23
24
|
<div align="center">
|
|
24
25
|
|
|
25
|
-
# Weco: The
|
|
26
|
+
# Weco: The Platform for Self-Improving Code
|
|
26
27
|
|
|
27
28
|
[](https://www.python.org)
|
|
28
29
|
[](https://docs.weco.ai/)
|
|
29
30
|
[](https://badge.fury.io/py/weco)
|
|
30
31
|
[](https://arxiv.org/abs/2502.13138)
|
|
31
32
|
|
|
32
|
-
<code>pip install weco</code>
|
|
33
|
-
|
|
34
33
|
</div>
|
|
35
34
|
|
|
36
35
|
---
|
|
@@ -39,9 +38,9 @@ Weco systematically optimizes your code, guided directly by your evaluation metr
|
|
|
39
38
|
|
|
40
39
|
Example applications include:
|
|
41
40
|
|
|
42
|
-
- **GPU Kernel Optimization**: Reimplement PyTorch functions using CUDA or Triton optimizing for `latency`, `throughput`, or `memory_bandwidth`.
|
|
43
|
-
- **Model Development**: Tune feature transformations or
|
|
44
|
-
- **Prompt Engineering**: Refine prompts for LLMs, optimizing for `win_rate`, `relevance`, or `format_adherence`
|
|
41
|
+
- **GPU Kernel Optimization**: Reimplement PyTorch functions using [CUDA](/examples/cuda/README.md) or [Triton](/examples/triton/README.md), optimizing for `latency`, `throughput`, or `memory_bandwidth`.
|
|
42
|
+
- **Model Development**: Tune feature transformations, architectures or [the whole training pipeline](/examples/spaceship-titanic/README.md), optimizing for `validation_accuracy`, `AUC`, or `Sharpe Ratio`.
|
|
43
|
+
- **Prompt Engineering**: Refine prompts for LLMs (e.g., for [math problems](/examples/prompt/README.md)), optimizing for `win_rate`, `relevance`, or `format_adherence`
|
|
45
44
|
|
|
46
45
|

|
|
47
46
|
|
|
@@ -71,29 +70,9 @@ The `weco` CLI leverages a tree search approach guided by Large Language Models
|
|
|
71
70
|
- **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
|
|
72
71
|
- **Google DeepMind:** `export GEMINI_API_KEY="your_key_here"` (Google AI Studio has a free API usage quota. Create a key [here](https://aistudio.google.com/apikey) to use `weco` for free.)
|
|
73
72
|
|
|
74
|
-
The optimization process will fail if the necessary keys for the chosen model are not found in your environment.
|
|
75
|
-
|
|
76
|
-
3. **Log In to Weco (Optional):**
|
|
77
|
-
|
|
78
|
-
To associate your optimization runs with your Weco account and view them on the Weco dashboard, you can log in. `weco` uses a device authentication flow:
|
|
79
|
-
|
|
80
|
-
- When you first run `weco run`, you'll be prompted if you want to log in or proceed anonymously.
|
|
81
|
-
- If you choose to log in (by pressing `l`), you'll be shown a URL and `weco` will attempt to open it in your default web browser.
|
|
82
|
-
- You then authenticate in the browser. Once authenticated, the CLI will detect this and complete the login.
|
|
83
|
-
- This saves a Weco-specific API key locally (typically at `~/.config/weco/credentials.json`).
|
|
84
|
-
|
|
85
|
-
If you choose to skip login (by pressing Enter or `s`), `weco` will still function using the environment variable LLM keys, but the run history will not be linked to a Weco account.
|
|
86
|
-
|
|
87
|
-
To log out and remove your saved Weco API key, use the `weco logout` command.
|
|
88
|
-
|
|
89
73
|
---
|
|
90
74
|
|
|
91
|
-
##
|
|
92
|
-
|
|
93
|
-
The CLI has two main commands:
|
|
94
|
-
|
|
95
|
-
- `weco run`: Initiates the code optimization process.
|
|
96
|
-
- `weco logout`: Logs you out of your Weco account.
|
|
75
|
+
## Get Started
|
|
97
76
|
|
|
98
77
|
<div style="background-color: #fff3cd; border: 1px solid #ffeeba; padding: 15px; border-radius: 4px; margin-bottom: 15px;">
|
|
99
78
|
<strong>⚠️ Warning: Code Modification</strong><br>
|
|
@@ -102,10 +81,6 @@ The CLI has two main commands:
|
|
|
102
81
|
|
|
103
82
|
---
|
|
104
83
|
|
|
105
|
-
### `weco run` Command
|
|
106
|
-
|
|
107
|
-
This command starts the optimization process.
|
|
108
|
-
|
|
109
84
|
**Example: Optimizing Simple PyTorch Operations**
|
|
110
85
|
|
|
111
86
|
This basic example shows how to optimize a simple PyTorch function for speedup.
|
|
@@ -148,13 +123,9 @@ weco run --source optimize.py \
|
|
|
148
123
|
|
|
149
124
|
---
|
|
150
125
|
|
|
151
|
-
###
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
weco logout
|
|
157
|
-
```
|
|
126
|
+
### Weco Dashboard
|
|
127
|
+
To associate your optimization runs with your Weco account and view them on the Weco dashboard, you can log in. `weco` uses a device authentication flow
|
|
128
|
+

|
|
158
129
|
|
|
159
130
|
---
|
|
160
131
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
# Weco: The
|
|
3
|
+
# Weco: The Platform for Self-Improving Code
|
|
4
4
|
|
|
5
5
|
[](https://www.python.org)
|
|
6
6
|
[](https://docs.weco.ai/)
|
|
7
7
|
[](https://badge.fury.io/py/weco)
|
|
8
8
|
[](https://arxiv.org/abs/2502.13138)
|
|
9
9
|
|
|
10
|
-
<code>pip install weco</code>
|
|
11
|
-
|
|
12
10
|
</div>
|
|
13
11
|
|
|
14
12
|
---
|
|
@@ -17,9 +15,9 @@ Weco systematically optimizes your code, guided directly by your evaluation metr
|
|
|
17
15
|
|
|
18
16
|
Example applications include:
|
|
19
17
|
|
|
20
|
-
- **GPU Kernel Optimization**: Reimplement PyTorch functions using CUDA or Triton optimizing for `latency`, `throughput`, or `memory_bandwidth`.
|
|
21
|
-
- **Model Development**: Tune feature transformations or
|
|
22
|
-
- **Prompt Engineering**: Refine prompts for LLMs, optimizing for `win_rate`, `relevance`, or `format_adherence`
|
|
18
|
+
- **GPU Kernel Optimization**: Reimplement PyTorch functions using [CUDA](/examples/cuda/README.md) or [Triton](/examples/triton/README.md), optimizing for `latency`, `throughput`, or `memory_bandwidth`.
|
|
19
|
+
- **Model Development**: Tune feature transformations, architectures or [the whole training pipeline](/examples/spaceship-titanic/README.md), optimizing for `validation_accuracy`, `AUC`, or `Sharpe Ratio`.
|
|
20
|
+
- **Prompt Engineering**: Refine prompts for LLMs (e.g., for [math problems](/examples/prompt/README.md)), optimizing for `win_rate`, `relevance`, or `format_adherence`
|
|
23
21
|
|
|
24
22
|

|
|
25
23
|
|
|
@@ -49,29 +47,9 @@ The `weco` CLI leverages a tree search approach guided by Large Language Models
|
|
|
49
47
|
- **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
|
|
50
48
|
- **Google DeepMind:** `export GEMINI_API_KEY="your_key_here"` (Google AI Studio has a free API usage quota. Create a key [here](https://aistudio.google.com/apikey) to use `weco` for free.)
|
|
51
49
|
|
|
52
|
-
The optimization process will fail if the necessary keys for the chosen model are not found in your environment.
|
|
53
|
-
|
|
54
|
-
3. **Log In to Weco (Optional):**
|
|
55
|
-
|
|
56
|
-
To associate your optimization runs with your Weco account and view them on the Weco dashboard, you can log in. `weco` uses a device authentication flow:
|
|
57
|
-
|
|
58
|
-
- When you first run `weco run`, you'll be prompted if you want to log in or proceed anonymously.
|
|
59
|
-
- If you choose to log in (by pressing `l`), you'll be shown a URL and `weco` will attempt to open it in your default web browser.
|
|
60
|
-
- You then authenticate in the browser. Once authenticated, the CLI will detect this and complete the login.
|
|
61
|
-
- This saves a Weco-specific API key locally (typically at `~/.config/weco/credentials.json`).
|
|
62
|
-
|
|
63
|
-
If you choose to skip login (by pressing Enter or `s`), `weco` will still function using the environment variable LLM keys, but the run history will not be linked to a Weco account.
|
|
64
|
-
|
|
65
|
-
To log out and remove your saved Weco API key, use the `weco logout` command.
|
|
66
|
-
|
|
67
50
|
---
|
|
68
51
|
|
|
69
|
-
##
|
|
70
|
-
|
|
71
|
-
The CLI has two main commands:
|
|
72
|
-
|
|
73
|
-
- `weco run`: Initiates the code optimization process.
|
|
74
|
-
- `weco logout`: Logs you out of your Weco account.
|
|
52
|
+
## Get Started
|
|
75
53
|
|
|
76
54
|
<div style="background-color: #fff3cd; border: 1px solid #ffeeba; padding: 15px; border-radius: 4px; margin-bottom: 15px;">
|
|
77
55
|
<strong>⚠️ Warning: Code Modification</strong><br>
|
|
@@ -80,10 +58,6 @@ The CLI has two main commands:
|
|
|
80
58
|
|
|
81
59
|
---
|
|
82
60
|
|
|
83
|
-
### `weco run` Command
|
|
84
|
-
|
|
85
|
-
This command starts the optimization process.
|
|
86
|
-
|
|
87
61
|
**Example: Optimizing Simple PyTorch Operations**
|
|
88
62
|
|
|
89
63
|
This basic example shows how to optimize a simple PyTorch function for speedup.
|
|
@@ -126,13 +100,9 @@ weco run --source optimize.py \
|
|
|
126
100
|
|
|
127
101
|
---
|
|
128
102
|
|
|
129
|
-
###
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
weco logout
|
|
135
|
-
```
|
|
103
|
+
### Weco Dashboard
|
|
104
|
+
To associate your optimization runs with your Weco account and view them on the Weco dashboard, you can log in. `weco` uses a device authentication flow
|
|
105
|
+

|
|
136
106
|
|
|
137
107
|
---
|
|
138
108
|
|
|
@@ -11,54 +11,6 @@ This example uses `gpt-4o-mini` via the OpenAI API by default. Ensure your `OPEN
|
|
|
11
11
|
| `optimize.py` | Holds the prompt template (instructing the LLM to reason step-by-step and use `\\boxed{}` for the final answer) and the mutable `EXTRA_INSTRUCTIONS` string. Weco edits **only** this file during the search. |
|
|
12
12
|
| `eval.py` | Downloads a small slice of the 2024 AIME dataset, calls `optimize.solve` in parallel, parses the LLM output (looking for `\\boxed{}`), compares it to the ground truth, prints progress logs, and finally prints an `accuracy:` line that Weco reads. |
|
|
13
13
|
|
|
14
|
-
## Quick start
|
|
15
|
-
|
|
16
|
-
1. **Clone the repository and enter the folder.**
|
|
17
|
-
```bash
|
|
18
|
-
# If you cloned the main weco-cli repo already:
|
|
19
|
-
cd examples/prompt
|
|
20
|
-
|
|
21
|
-
# Otherwise:
|
|
22
|
-
# git clone https://github.com/WecoAI/weco-cli.git
|
|
23
|
-
# cd weco-cli/examples/prompt
|
|
24
|
-
```
|
|
25
|
-
2. **Install dependencies.**
|
|
26
|
-
```bash
|
|
27
|
-
# Ensure you have weco installed: pip install weco
|
|
28
|
-
pip install openai datasets # Add any other dependencies if needed
|
|
29
|
-
```
|
|
30
|
-
3. **Set your OpenAI API Key.**
|
|
31
|
-
```bash
|
|
32
|
-
export OPENAI_API_KEY="your_openai_api_key_here"
|
|
33
|
-
```
|
|
34
|
-
4. **Run Weco.** The command below iteratively modifies `EXTRA_INSTRUCTIONS` in `optimize.py`, runs `eval.py` to evaluate the prompt's effectiveness, reads the printed accuracy, and keeps the best prompt variations found.
|
|
35
|
-
```bash
|
|
36
|
-
weco run --source optimize.py \
|
|
37
|
-
--eval-command "python eval.py" \
|
|
38
|
-
--metric accuracy \
|
|
39
|
-
--maximize true \
|
|
40
|
-
--steps 40 \
|
|
41
|
-
--model gemini-2.5-pro-exp-03-25
|
|
42
|
-
```
|
|
43
|
-
*Note: You can replace `--model gemini-2.5-pro-exp-03-25` with another powerful model like `o3` if you have the respective API keys set.*
|
|
44
|
-
|
|
45
|
-
During each evaluation round, you will see log lines similar to the following:
|
|
46
|
-
|
|
47
|
-
```text
|
|
48
|
-
[setup] loading 20 problems from AIME 2024 …
|
|
49
|
-
[progress] 5/20 completed, accuracy: 0.0000, elapsed 7.3 s
|
|
50
|
-
[progress] 10/20 completed, accuracy: 0.1000, elapsed 14.6 s
|
|
51
|
-
[progress] 15/20 completed, accuracy: 0.0667, elapsed 21.8 s
|
|
52
|
-
[progress] 20/20 completed, accuracy: 0.0500, elapsed 28.9 s
|
|
53
|
-
accuracy: 0.0500# AIME 2024 Prompt‑Engineering Example
|
|
54
|
-
This example shows how **Weco** can iteratively improve a prompt for solving American Invitational Mathematics Examination (AIME) problems. The experiment runs locally, requires only two short Python files, and finishes in a few hours on a laptop.
|
|
55
|
-
|
|
56
|
-
## Files in this folder
|
|
57
|
-
|
|
58
|
-
| File | Purpose |
|
|
59
|
-
| :------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
60
|
-
| `optimize.py` | Holds the prompt template (instructing the LLM to reason step-by-step and use `\\boxed{}` for the final answer) and the function to call the LLM. Weco edits **only** this file during the search to refine the prompt template. |
|
|
61
|
-
| `eval.py` | Defines the LLM model to use (`MODEL_TO_USE`). Downloads a small slice of the 2024 AIME dataset, calls `optimize.solve` in parallel (passing the chosen model), parses the LLM output, compares it to the ground truth, prints progress logs, and finally prints an `accuracy:` line that Weco reads. |
|
|
62
14
|
|
|
63
15
|
## Quick start
|
|
64
16
|
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
# Example:
|
|
1
|
+
# Example: Solving a Kaggle Competition (Spaceship Titanic)
|
|
2
2
|
|
|
3
3
|
This example demonstrates using Weco to optimize a Python script designed for the [Spaceship Titanic Kaggle competition](https://www.kaggle.com/competitions/spaceship-titanic/overview). The goal is to improve the model's `accuracy` metric by directly optimizing the evaluate.py
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
7
|
1. Ensure you are in the `examples/spaceship-titanic` directory.
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
8
|
+
2. `pip install weco`
|
|
9
|
+
3. Set up LLM API Key, `export OPENAI_API_KEY="your_key_here"`
|
|
10
|
+
4. **Install Dependencies:** Install the required Python packages:
|
|
10
11
|
```bash
|
|
11
12
|
pip install -r requirements-test.txt
|
|
12
13
|
```
|
|
13
|
-
4. **Prepare Data:** Run the utility script once to download the dataset from Kaggle and place it in the expected `./data/` subdirectories:
|
|
14
|
-
```bash
|
|
15
|
-
python get_data.py
|
|
16
|
-
```
|
|
17
|
-
After running `get_data.py`, your directory structure should look like this:
|
|
18
|
-
```
|
|
19
|
-
.
|
|
20
|
-
├── competition_description.md
|
|
21
|
-
├── data
|
|
22
|
-
│ ├── sample_submission.csv
|
|
23
|
-
│ ├── test.csv
|
|
24
|
-
│ └── train.csv
|
|
25
|
-
├── evaluate.py
|
|
26
|
-
├── get_data.py
|
|
27
|
-
├── README.md # This file
|
|
28
|
-
├── requirements-test.txt
|
|
29
|
-
└── submit.py
|
|
30
|
-
```
|
|
31
14
|
|
|
32
15
|
## Optimization Command
|
|
33
16
|
|
|
@@ -38,20 +21,12 @@ weco run --source evaluate.py \
|
|
|
38
21
|
--eval-command "python evaluate.py --data-dir ./data" \
|
|
39
22
|
--metric accuracy \
|
|
40
23
|
--maximize true \
|
|
41
|
-
--steps
|
|
42
|
-
--model
|
|
24
|
+
--steps 20 \
|
|
25
|
+
--model o4-mini \
|
|
43
26
|
--additional-instructions "Improve feature engineering, model choice and hyper-parameters."
|
|
44
27
|
--log-dir .runs/spaceship-titanic
|
|
45
28
|
```
|
|
46
29
|
|
|
47
|
-
## Submit the solution
|
|
48
|
-
|
|
49
|
-
Once the optimization finished, you can submit your predictions to kaggle to see the results. Make sure `submission.csv` is present and then simply run the following command.
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
python submit.py
|
|
53
|
-
```
|
|
54
|
-
|
|
55
30
|
### Explanation
|
|
56
31
|
|
|
57
32
|
* `--source evaluate.py`: The script provides a baseline as root node and directly optimize the evaluate.py
|
|
@@ -64,4 +39,4 @@ python submit.py
|
|
|
64
39
|
* `--model gemini-2.5-pro-exp-03-25`: The LLM driving the optimization.
|
|
65
40
|
* `--additional-instructions "Improve feature engineering, model choice and hyper-parameters."`: A simple instruction for model improvement or you can put the path to [`comptition_description.md`](./competition_description.md) within the repo to feed the agent more detailed information.
|
|
66
41
|
|
|
67
|
-
Weco will iteratively modify the feature engineering or modeling code within `evaluate.py`, run the evaluation pipeline, and use the resulting `accuracy` to guide further improvements.
|
|
42
|
+
Weco will iteratively modify the feature engineering or modeling code within `evaluate.py`, run the evaluation pipeline, and use the resulting `accuracy` to guide further improvements.
|