Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PR-20 - add improved candidate generation techniques and selector can take best of bread if not self refine is used for text generation #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This script applies Trace to optimize the workflow in TextGrad's solution_optimization.py.

from opto import trace
from opto.optimizers import OptoPrime, TextGrad
from opto.optimizers import OptoPrime, TextGrad, OptoPrimeMulti

import re
import json
Expand Down Expand Up @@ -162,6 +162,12 @@ def run_trace_test_time_training(sample):
if args.algo == "textgrad":
# This runs Trace's TextGrad optimizer
optimizer = TextGrad([instance_var], max_tokens=16383)
elif args.algo == 'opto_multi':
# This runs Trace's OptoPrimeMulti optimizer
optimizer = OptoPrimeMulti([instance_var],
prompt_symbols={'variables': '#Parameters'},
num_responses=3,
max_tokens=16383)
else: # This runs Trace's OptoPrime optimizer
optimizer = OptoPrime([instance_var],
prompt_symbols={'variables': '#Parameters'},
Expand Down Expand Up @@ -215,7 +221,7 @@ def backfill(regret, maxlen):


args = config()
assert args.algo in ["textgrad", "trace", "ttextgrad"], "ttextgrad is Trace's implementation textgrad"
assert args.algo in ["textgrad", "trace", "ttextgrad", 'opto_multi'], "ttextgrad is original implementation textgrad"

llm_engine = tg.get_engine(engine_name=args.engine)
tg.set_backward_engine(llm_engine, override=True)
Expand All @@ -228,7 +234,7 @@ def backfill(regret, maxlen):
with concurrent.futures.ThreadPoolExecutor(max_workers=args.num_threads) as executor:
futures = []
for i, sample in enumerate(test_set):
if args.algo in ["trace", 'textgrad']:
if args.algo in ["trace", 'textgrad', 'opto_multi']:
future = executor.submit(run_trace_test_time_training, sample)
else:
future = executor.submit(run_test_time_training, sample)
Expand Down
Loading