weco 0.2.7__py3-none-any.whl → 0.2.9__py3-none-any.whl
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/__init__.py +1 -1
- weco/api.py +3 -8
- weco/cli.py +34 -17
- weco/panels.py +12 -3
- {weco-0.2.7.dist-info → weco-0.2.9.dist-info}/METADATA +24 -130
- weco-0.2.9.dist-info/RECORD +11 -0
- {weco-0.2.7.dist-info → weco-0.2.9.dist-info}/WHEEL +1 -1
- weco-0.2.7.dist-info/RECORD +0 -11
- {weco-0.2.7.dist-info → weco-0.2.9.dist-info}/entry_points.txt +0 -0
- {weco-0.2.7.dist-info → weco-0.2.9.dist-info}/licenses/LICENSE +0 -0
- {weco-0.2.7.dist-info → weco-0.2.9.dist-info}/top_level.txt +0 -0
weco/__init__.py
CHANGED
weco/api.py
CHANGED
|
@@ -6,14 +6,9 @@ import sys
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def handle_api_error(e: requests.exceptions.HTTPError, console: rich.console.Console) -> None:
|
|
9
|
-
"""Extract and display error messages from API responses."""
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
error_message = error_data.get("detail", str(e))
|
|
13
|
-
console.print(f"[bold red]Server Error:[/] {error_message}")
|
|
14
|
-
except Exception:
|
|
15
|
-
# If we can't parse the JSON, just show the original error
|
|
16
|
-
console.print(f"[bold red]Server Error:[/] {str(e)}")
|
|
9
|
+
"""Extract and display error messages from API responses in a structured format."""
|
|
10
|
+
error_message = str(e) # Default message
|
|
11
|
+
console.print(f"[bold red]Error:[/] {error_message}")
|
|
17
12
|
sys.exit(1)
|
|
18
13
|
|
|
19
14
|
|
weco/cli.py
CHANGED
|
@@ -36,7 +36,7 @@ def main() -> None:
|
|
|
36
36
|
parser = argparse.ArgumentParser(
|
|
37
37
|
description="[bold cyan]Weco CLI[/]", formatter_class=argparse.RawDescriptionHelpFormatter
|
|
38
38
|
)
|
|
39
|
-
parser.add_argument("--source", type=str, required=True, help="Path to the
|
|
39
|
+
parser.add_argument("--source", type=str, required=True, help="Path to the source code (e.g. optimize.py)")
|
|
40
40
|
parser.add_argument(
|
|
41
41
|
"--eval-command", type=str, required=True, help="Command to run for evaluation (e.g. 'python eval.py --arg1=val1')"
|
|
42
42
|
)
|
|
@@ -57,6 +57,11 @@ def main() -> None:
|
|
|
57
57
|
type=str,
|
|
58
58
|
help="Description of additional instruction or path to a file containing additional instructions",
|
|
59
59
|
)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"--preserve-source",
|
|
62
|
+
action="store_true",
|
|
63
|
+
help="If set, do not overwrite the original source file; only save modified versions in the runs directory",
|
|
64
|
+
)
|
|
60
65
|
args = parser.parse_args()
|
|
61
66
|
|
|
62
67
|
try:
|
|
@@ -73,22 +78,23 @@ def main() -> None:
|
|
|
73
78
|
"debug_prob": 0.5,
|
|
74
79
|
"max_debug_depth": max(1, math.ceil(0.1 * steps)), # 10% of steps
|
|
75
80
|
}
|
|
81
|
+
# Read API keys
|
|
82
|
+
api_keys = read_api_keys_from_env()
|
|
83
|
+
# API request timeout
|
|
84
|
+
timeout = 800
|
|
85
|
+
|
|
76
86
|
# Read additional instructions
|
|
77
87
|
additional_instructions = read_additional_instructions(additional_instructions=args.additional_instructions)
|
|
78
88
|
# Read source code
|
|
79
89
|
source_fp = pathlib.Path(args.source)
|
|
80
90
|
source_code = read_from_path(fp=source_fp, is_json=False)
|
|
81
|
-
# Read API keys
|
|
82
|
-
api_keys = read_api_keys_from_env()
|
|
83
|
-
# API request timeout
|
|
84
|
-
timeout = 800
|
|
85
91
|
|
|
86
92
|
# Initialize panels
|
|
87
93
|
summary_panel = SummaryPanel(
|
|
88
94
|
maximize=maximize, metric_name=metric_name, total_steps=steps, model=args.model, runs_dir=args.log_dir
|
|
89
95
|
)
|
|
90
96
|
plan_panel = PlanPanel()
|
|
91
|
-
solution_panels = SolutionPanels(metric_name=metric_name)
|
|
97
|
+
solution_panels = SolutionPanels(metric_name=metric_name, source_fp=source_fp)
|
|
92
98
|
eval_output_panel = EvaluationOutputPanel()
|
|
93
99
|
tree_panel = MetricTreePanel(maximize=maximize)
|
|
94
100
|
layout = create_optimization_layout()
|
|
@@ -118,13 +124,14 @@ def main() -> None:
|
|
|
118
124
|
runs_dir = pathlib.Path(args.log_dir) / session_id
|
|
119
125
|
runs_dir.mkdir(parents=True, exist_ok=True)
|
|
120
126
|
|
|
121
|
-
# Save the original code (.runs/<session-id>/original
|
|
122
|
-
runs_copy_source_fp = runs_dir / "original.
|
|
127
|
+
# Save the original code (.runs/<session-id>/original.<extension>)
|
|
128
|
+
runs_copy_source_fp = runs_dir / f"original.{source_fp.suffix}"
|
|
123
129
|
write_to_path(fp=runs_copy_source_fp, content=source_code)
|
|
124
130
|
|
|
125
131
|
# Write the code string to the source file path
|
|
126
132
|
# Do this after the original code is saved
|
|
127
|
-
|
|
133
|
+
if not args.preserve_source:
|
|
134
|
+
write_to_path(fp=source_fp, content=session_response["code"])
|
|
128
135
|
|
|
129
136
|
# Update the panels with the initial solution
|
|
130
137
|
# Add session id now that we have it
|
|
@@ -191,20 +198,25 @@ def main() -> None:
|
|
|
191
198
|
)
|
|
192
199
|
|
|
193
200
|
for step in range(1, steps):
|
|
201
|
+
# Re-read instructions from the original source (file path or string) BEFORE each suggest call
|
|
202
|
+
current_additional_instructions = read_additional_instructions(
|
|
203
|
+
additional_instructions=args.additional_instructions
|
|
204
|
+
)
|
|
194
205
|
# Evaluate the current output and get the next solution
|
|
195
206
|
eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
|
|
196
207
|
console=console,
|
|
197
208
|
session_id=session_id,
|
|
198
209
|
execution_output=term_out,
|
|
199
|
-
additional_instructions=
|
|
210
|
+
additional_instructions=current_additional_instructions,
|
|
200
211
|
api_keys=api_keys,
|
|
201
212
|
timeout=timeout,
|
|
202
213
|
)
|
|
203
|
-
# Save next solution (.runs/<session-id>/step_<step
|
|
204
|
-
write_to_path(fp=runs_dir / f"step_{step}.
|
|
214
|
+
# Save next solution (.runs/<session-id>/step_<step>.<extension>)
|
|
215
|
+
write_to_path(fp=runs_dir / f"step_{step}{source_fp.suffix}", content=eval_and_next_solution_response["code"])
|
|
205
216
|
|
|
206
217
|
# Write the next solution to the source file
|
|
207
|
-
|
|
218
|
+
if not args.preserve_source:
|
|
219
|
+
write_to_path(fp=source_fp, content=eval_and_next_solution_response["code"])
|
|
208
220
|
|
|
209
221
|
# Get the optimization session status for
|
|
210
222
|
# the best solution, its score, and the history to plot the tree
|
|
@@ -283,12 +295,16 @@ def main() -> None:
|
|
|
283
295
|
transition_delay=0.1, # Slightly longer delay for evaluation results
|
|
284
296
|
)
|
|
285
297
|
|
|
298
|
+
# Re-read instructions before the final feedback step
|
|
299
|
+
current_additional_instructions = read_additional_instructions(
|
|
300
|
+
additional_instructions=args.additional_instructions
|
|
301
|
+
)
|
|
286
302
|
# Ensure we pass evaluation results for the last step's generated solution
|
|
287
303
|
eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
|
|
288
304
|
console=console,
|
|
289
305
|
session_id=session_id,
|
|
290
306
|
execution_output=term_out,
|
|
291
|
-
additional_instructions=
|
|
307
|
+
additional_instructions=current_additional_instructions,
|
|
292
308
|
api_keys=api_keys,
|
|
293
309
|
timeout=timeout,
|
|
294
310
|
)
|
|
@@ -351,11 +367,12 @@ def main() -> None:
|
|
|
351
367
|
)
|
|
352
368
|
best_solution_content = f"# Best solution from Weco with a score of {best_score_str}\n\n{best_solution_code}"
|
|
353
369
|
|
|
354
|
-
# Save best solution to .runs/<session-id>/best
|
|
355
|
-
write_to_path(fp=runs_dir / "best.
|
|
370
|
+
# Save best solution to .runs/<session-id>/best.<extension>
|
|
371
|
+
write_to_path(fp=runs_dir / f"best.{source_fp.suffix}", content=best_solution_content)
|
|
356
372
|
|
|
357
373
|
# write the best solution to the source file
|
|
358
|
-
|
|
374
|
+
if not args.preserve_source:
|
|
375
|
+
write_to_path(fp=source_fp, content=best_solution_content)
|
|
359
376
|
|
|
360
377
|
console.print(end_optimization_layout)
|
|
361
378
|
|
weco/panels.py
CHANGED
|
@@ -6,6 +6,7 @@ from rich.panel import Panel
|
|
|
6
6
|
from rich.syntax import Syntax
|
|
7
7
|
from typing import Dict, List, Optional, Union, Tuple
|
|
8
8
|
from .utils import format_number
|
|
9
|
+
import pathlib
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class SummaryPanel:
|
|
@@ -46,6 +47,8 @@ class SummaryPanel:
|
|
|
46
47
|
"""Create a summary panel with the relevant information."""
|
|
47
48
|
layout = Layout(name="summary")
|
|
48
49
|
summary_table = Table(show_header=False, box=None, padding=(0, 1))
|
|
50
|
+
|
|
51
|
+
summary_table.add_row("")
|
|
49
52
|
# Goal
|
|
50
53
|
if final_message is not None:
|
|
51
54
|
summary_table.add_row(f"[bold cyan]Result:[/] {final_message}")
|
|
@@ -256,13 +259,19 @@ class EvaluationOutputPanel:
|
|
|
256
259
|
class SolutionPanels:
|
|
257
260
|
"""Displays the current and best solutions side by side."""
|
|
258
261
|
|
|
259
|
-
def __init__(self, metric_name: str):
|
|
262
|
+
def __init__(self, metric_name: str, source_fp: pathlib.Path):
|
|
260
263
|
# Current solution
|
|
261
264
|
self.current_node = None
|
|
262
265
|
# Best solution
|
|
263
266
|
self.best_node = None
|
|
264
267
|
# Metric name
|
|
265
268
|
self.metric_name = metric_name.capitalize()
|
|
269
|
+
# Determine the lexer for the source file
|
|
270
|
+
self.lexer = self._determine_lexer(source_fp)
|
|
271
|
+
|
|
272
|
+
def _determine_lexer(self, source_fp: pathlib.Path) -> str:
|
|
273
|
+
"""Determine the lexer for the source file."""
|
|
274
|
+
return Syntax.from_path(source_fp).lexer
|
|
266
275
|
|
|
267
276
|
def update(self, current_node: Union[Node, None], best_node: Union[Node, None]):
|
|
268
277
|
"""Update the current and best solutions."""
|
|
@@ -280,7 +289,7 @@ class SolutionPanels:
|
|
|
280
289
|
# Current solution (without score)
|
|
281
290
|
current_title = f"[bold]💡 Current Solution (Step {current_step})"
|
|
282
291
|
current_panel = Panel(
|
|
283
|
-
Syntax(str(current_code),
|
|
292
|
+
Syntax(str(current_code), self.lexer, theme="monokai", line_numbers=True, word_wrap=False),
|
|
284
293
|
title=current_title,
|
|
285
294
|
border_style="yellow",
|
|
286
295
|
expand=True,
|
|
@@ -290,7 +299,7 @@ class SolutionPanels:
|
|
|
290
299
|
# Best solution
|
|
291
300
|
best_title = f"[bold]🏆 Best Solution ([green]{self.metric_name}: {f'{best_score:.4f}' if best_score is not None else 'N/A'}[/])"
|
|
292
301
|
best_panel = Panel(
|
|
293
|
-
Syntax(str(best_code),
|
|
302
|
+
Syntax(str(best_code), self.lexer, theme="monokai", line_numbers=True, word_wrap=False),
|
|
294
303
|
title=best_title,
|
|
295
304
|
border_style="green",
|
|
296
305
|
expand=True,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weco
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
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
|
|
@@ -9,7 +9,7 @@ Keywords: AI,Code Optimization,Code Generation
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: requests
|
|
@@ -20,13 +20,19 @@ Requires-Dist: build; extra == "dev"
|
|
|
20
20
|
Requires-Dist: setuptools_scm; extra == "dev"
|
|
21
21
|
Dynamic: license-file
|
|
22
22
|
|
|
23
|
-
# Weco
|
|
23
|
+
# Weco: The Evaluation-Driven AI Code Optimizer
|
|
24
24
|
|
|
25
25
|
[](https://www.python.org)
|
|
26
|
-
[](LICENSE)
|
|
27
26
|
[](https://badge.fury.io/py/weco)
|
|
27
|
+
[](https://arxiv.org/abs/2502.13138)
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Weco systematically optimizes your code, guided directly by your evaluation metrics.
|
|
30
|
+
|
|
31
|
+
Example applications include:
|
|
32
|
+
|
|
33
|
+
- **GPU Kernel Optimization**: Reimplement PyTorch functions using CUDA, Triton or Metal, optimizing for `latency`, `throughput`, or `memory_bandwidth`.
|
|
34
|
+
- **Model Development**: Tune feature transformations or architectures, optimizing for `validation_accuracy`, `AUC`, or `Sharpe Ratio`.
|
|
35
|
+
- **Prompt Engineering**: Refine prompts for LLMs, optimizing for `win_rate`, `relevance`, or `format_adherence`
|
|
30
36
|
|
|
31
37
|
https://github.com/user-attachments/assets/cb724ef1-bff6-4757-b457-d3b2201ede81
|
|
32
38
|
|
|
@@ -40,37 +46,6 @@ The `weco` CLI leverages a tree search approach guided by Large Language Models
|
|
|
40
46
|
|
|
41
47
|
---
|
|
42
48
|
|
|
43
|
-
## Example Use Cases
|
|
44
|
-
|
|
45
|
-
Here's how `weco` can be applied to common ML engineering tasks:
|
|
46
|
-
|
|
47
|
-
* **GPU Kernel Optimization:**
|
|
48
|
-
* **Goal:** Improve the speed or efficiency of low-level GPU code.
|
|
49
|
-
* **How:** `weco` iteratively refines CUDA, Triton, Metal, or other kernel code specified in your `--source` file.
|
|
50
|
-
* **`--eval-command`:** Typically runs a script that compiles the kernel, executes it, and benchmarks performance (e.g., latency, throughput).
|
|
51
|
-
* **`--metric`:** Examples include `latency`, `throughput`, `TFLOPS`, `memory_bandwidth`. Optimize to `minimize` latency or `maximize` throughput.
|
|
52
|
-
|
|
53
|
-
* **Feature Engineering:**
|
|
54
|
-
* **Goal:** Discover better data transformations or feature combinations for your machine learning models.
|
|
55
|
-
* **How:** `weco` explores different processing steps or parameters within your feature transformation code (`--source`).
|
|
56
|
-
* **`--eval-command`:** Executes a script that applies the features, trains/validates a model using those features, and prints a performance score.
|
|
57
|
-
* **`--metric`:** Examples include `accuracy`, `AUC`, `F1-score`, `validation_loss`. Usually optimized to `maximize` accuracy/AUC/F1 or `minimize` loss.
|
|
58
|
-
|
|
59
|
-
* **Model Development:**
|
|
60
|
-
* **Goal:** Tune hyperparameters or experiment with small architectural changes directly within your model's code.
|
|
61
|
-
* **How:** `weco` modifies hyperparameter values (like learning rate, layer sizes if defined in the code) or structural elements in your model definition (`--source`).
|
|
62
|
-
* **`--eval-command`:** Runs your model training and evaluation script, printing the key performance indicator.
|
|
63
|
-
* **`--metric`:** Examples include `validation_accuracy`, `test_loss`, `inference_time`, `perplexity`. Optimize according to the metric's nature (e.g., `maximize` accuracy, `minimize` loss).
|
|
64
|
-
|
|
65
|
-
* **Prompt Engineering:**
|
|
66
|
-
* **Goal:** Refine prompts used within larger systems (e.g., for LLM interactions) to achieve better or more consistent outputs.
|
|
67
|
-
* **How:** `weco` modifies prompt templates, examples, or instructions stored in the `--source` file.
|
|
68
|
-
* **`--eval-command`:** Executes a script that uses the prompt, generates an output, evaluates that output against desired criteria (e.g., using another LLM, checking for keywords, format validation), and prints a score.
|
|
69
|
-
* **`--metric`:** Examples include `quality_score`, `relevance`, `task_success_rate`, `format_adherence`. Usually optimized to `maximize`.
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
|
|
74
49
|
## Setup
|
|
75
50
|
|
|
76
51
|
1. **Install the Package:**
|
|
@@ -97,13 +72,20 @@ Here's how `weco` can be applied to common ML engineering tasks:
|
|
|
97
72
|
|
|
98
73
|
---
|
|
99
74
|
|
|
100
|
-
###
|
|
75
|
+
### Example: Optimizing Simple PyTorch Operations
|
|
76
|
+
|
|
77
|
+
This basic example shows how to optimize a simple PyTorch function for speedup.
|
|
101
78
|
|
|
102
|
-
**
|
|
79
|
+
For more advanced examples, including **[Metal/MLX](/examples/metal/README.md), [Triton](/examples/triton/README.md), [CUDA kernel optimization](/examples/cuda/README.md)**, and **[ML model optimization](/examples/spaceship-titanic/README.md)**, please see the `README.md` files within the corresponding subdirectories under the [`examples/`](./examples/) folder.
|
|
103
80
|
|
|
104
81
|
```bash
|
|
82
|
+
# Navigate to the example directory
|
|
105
83
|
cd examples/hello-kernel-world
|
|
106
|
-
|
|
84
|
+
|
|
85
|
+
# Install dependencies
|
|
86
|
+
pip install torch
|
|
87
|
+
|
|
88
|
+
# Run Weco
|
|
107
89
|
weco --source optimize.py \
|
|
108
90
|
--eval-command "python evaluate.py --solution-path optimize.py --device cpu" \
|
|
109
91
|
--metric speedup \
|
|
@@ -113,96 +95,7 @@ weco --source optimize.py \
|
|
|
113
95
|
--additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
|
|
114
96
|
```
|
|
115
97
|
|
|
116
|
-
Note
|
|
117
|
-
|
|
118
|
-
**Example 2: Optimizing MLX operations with instructions from a file**
|
|
119
|
-
|
|
120
|
-
Lets optimize a 2D convolution operation in [`mlx`](https://github.com/ml-explore/mlx) using [Metal](https://developer.apple.com/documentation/metal/). Sometimes, additional context or instructions are too complex for a single command-line string. You can provide a path to a file containing these instructions.
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
cd examples/metal
|
|
124
|
-
pip install mlx
|
|
125
|
-
weco --source optimize.py \
|
|
126
|
-
--eval-command "python evaluate.py --solution-path optimize.py" \
|
|
127
|
-
--metric speedup \
|
|
128
|
-
--maximize true \
|
|
129
|
-
--steps 30 \
|
|
130
|
-
--model gemini-2.5-pro-exp-03-25 \
|
|
131
|
-
--additional-instructions examples.rst
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**Example 3: Level Agnostic Optimization: Causal Self Attention with Triton & CUDA**
|
|
135
|
-
|
|
136
|
-
Given how useful causal multihead self attention is to transformers, we've seen its wide adoption across ML engineering and AI research. Its great to keep things at a high-level (in PyTorch) when doing research, but when moving to production you often need to write highly customized low-level kernels to make things run as fast as they can. The `weco` CLI can optimize kernels across a variety of different abstraction levels and frameworks. Example 2 uses Metal but lets explore two more frameworks:
|
|
137
|
-
|
|
138
|
-
1. [Triton](https://github.com/triton-lang/triton)
|
|
139
|
-
```bash
|
|
140
|
-
cd examples/triton
|
|
141
|
-
pip install torch triton
|
|
142
|
-
weco --source optimize.py \
|
|
143
|
-
--eval-command "python evaluate.py --solution-path optimize.py" \
|
|
144
|
-
--metric speedup \
|
|
145
|
-
--maximize true \
|
|
146
|
-
--steps 30 \
|
|
147
|
-
--model gemini-2.5-pro-exp-03-25 \
|
|
148
|
-
--additional-instructions "Use triton to optimize the code while ensuring a small max float diff. Maintain the same code format."
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
2. [CUDA](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html)
|
|
152
|
-
```bash
|
|
153
|
-
cd examples/cuda
|
|
154
|
-
pip install torch
|
|
155
|
-
weco --source optimize.py \
|
|
156
|
-
--eval-command "python evaluate.py --solution-path optimize.py" \
|
|
157
|
-
--metric speedup \
|
|
158
|
-
--maximize true \
|
|
159
|
-
--steps 30 \
|
|
160
|
-
--model gemini-2.5-pro-exp-03-25 \
|
|
161
|
-
--additional-instructions guide.md
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
**Example 4: Optimizing a Classification Model**
|
|
165
|
-
|
|
166
|
-
This example demonstrates optimizing a script for a Kaggle competition ([Spaceship Titanic](https://www.kaggle.com/competitions/spaceship-titanic/overview)) to improve classification accuracy. The additional instructions are provided via a separate file (`examples/spaceship-titanic/README.md`).
|
|
167
|
-
|
|
168
|
-
First, install the requirements for the example environment:
|
|
169
|
-
```bash
|
|
170
|
-
pip install -r examples/spaceship-titanic/requirements-test.txt
|
|
171
|
-
```
|
|
172
|
-
And run utility function once to prepare the dataset
|
|
173
|
-
```bash
|
|
174
|
-
python examples/spaceship-titanic/utils.py
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
You should see the following structure at `examples/spaceship-titanic`. You need to prepare the kaggle credentials for downloading the dataset.
|
|
178
|
-
```
|
|
179
|
-
.
|
|
180
|
-
├── baseline.py
|
|
181
|
-
├── evaluate.py
|
|
182
|
-
├── optimize.py
|
|
183
|
-
├── private
|
|
184
|
-
│ └── test.csv
|
|
185
|
-
├── public
|
|
186
|
-
│ ├── sample_submission.csv
|
|
187
|
-
│ ├── test.csv
|
|
188
|
-
│ └── train.csv
|
|
189
|
-
├── README.md
|
|
190
|
-
├── requirements-test.txt
|
|
191
|
-
└── utils.py
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Then, execute the optimization command:
|
|
195
|
-
```bash
|
|
196
|
-
weco --source examples/spaceship-titanic/optimize.py \
|
|
197
|
-
--eval-command "python examples/spaceship-titanic/optimize.py && python examples/spaceship-titanic/evaluate.py" \
|
|
198
|
-
--metric accuracy \
|
|
199
|
-
--maximize true \
|
|
200
|
-
--steps 10 \
|
|
201
|
-
--model gemini-2.5-pro-exp-03-25 \
|
|
202
|
-
--additional-instructions examples/spaceship-titanic/README.md
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
*The [baseline.py](examples/spaceship-titanic/baseline.py) is provided as a start point for optimization*
|
|
98
|
+
**Note:** If you have an NVIDIA GPU, change the device in the `--eval-command` to `cuda`. If you are running this on Apple Silicon, set it to `mps`.
|
|
206
99
|
|
|
207
100
|
---
|
|
208
101
|
|
|
@@ -215,9 +108,10 @@ weco --source examples/spaceship-titanic/optimize.py \
|
|
|
215
108
|
| `--metric` | The name of the metric you want to optimize (e.g., 'accuracy', 'speedup', 'loss'). This metric name should match what's printed by your `--eval-command`. | Yes |
|
|
216
109
|
| `--maximize` | Whether to maximize (`true`) or minimize (`false`) the metric. | Yes |
|
|
217
110
|
| `--steps` | Number of optimization steps (LLM iterations) to run. | Yes |
|
|
218
|
-
| `--model` | Model identifier for the LLM to use (e.g., `gpt-4o`, `claude-3.
|
|
111
|
+
| `--model` | Model identifier for the LLM to use (e.g., `gpt-4o`, `claude-3.7-sonnet`). Recommended models to try include `o4-mini`, and `gemini-2.5-pro-exp-03-25`.| Yes |
|
|
219
112
|
| `--additional-instructions` | (Optional) Natural language description of specific instructions OR path to a file containing detailed instructions to guide the LLM. | No |
|
|
220
113
|
| `--log-dir` | (Optional) Path to the directory to log intermediate steps and final optimization result. Defaults to `.runs/`. | No |
|
|
114
|
+
| `--preserve-source` | (Optional) If set, do not overwrite the original `--source` file. Modifications and the best solution will still be saved in the `--log-dir`. | No |
|
|
221
115
|
|
|
222
116
|
---
|
|
223
117
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
weco/__init__.py,sha256=8vfBL3OdlOveq9nYktaI3JQLXAeR7Pnwz8TRZ3xu0nA,124
|
|
2
|
+
weco/api.py,sha256=89lB2572jApAxkA0DDppDnJKBwvZTa3kH9jFpC0LFDQ,3313
|
|
3
|
+
weco/cli.py,sha256=iTecBQ0gAqyQixj7tNU9S6f9NW7TMSGZtH8nw-85_Oc,18276
|
|
4
|
+
weco/panels.py,sha256=R_df-VAbWyLoqCA9A6UzbIGZ9sm2IgJO4idnyjmrHQk,12701
|
|
5
|
+
weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
|
|
6
|
+
weco-0.2.9.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
7
|
+
weco-0.2.9.dist-info/METADATA,sha256=Fq37xE2H8Ia3brOv6AcjsleqDeDL_U6XiV3bJHZOhCY,9378
|
|
8
|
+
weco-0.2.9.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
|
9
|
+
weco-0.2.9.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
10
|
+
weco-0.2.9.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
11
|
+
weco-0.2.9.dist-info/RECORD,,
|
weco-0.2.7.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
weco/__init__.py,sha256=6ZYuD51wx6bytYdLFMvzihYrpBlSxiFbmuiEl0z_AFo,124
|
|
2
|
-
weco/api.py,sha256=8rIf2Fy3tN6GW7BG1CaggtfE9pW56I1erzwLCgawcVE,3511
|
|
3
|
-
weco/cli.py,sha256=h8FevpztBob7OziDTIKh4y9CSnehkHJp2ydts6V6DhM,17317
|
|
4
|
-
weco/panels.py,sha256=HHWmrnc2EJBJ8AEHb8mxlq30m-3q0j_4axc0r17sTnE,12349
|
|
5
|
-
weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
|
|
6
|
-
weco-0.2.7.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
7
|
-
weco-0.2.7.dist-info/METADATA,sha256=AlBfVky2jZ6C2MnB8k_WkSMyucTeTE1Ias3y3_4bVsE,14577
|
|
8
|
-
weco-0.2.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
9
|
-
weco-0.2.7.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
10
|
-
weco-0.2.7.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
11
|
-
weco-0.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|