Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
evoprompt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grießhaber Daniel
evoprompt
Commits
bbce7ee4
Commit
bbce7ee4
authored
7 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Consider debug mode for paraphrasing
parent
662a11e8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
evoprompt/evolution.py
+1
-1
1 addition, 1 deletion
evoprompt/evolution.py
evoprompt/optimization.py
+5
-3
5 additions, 3 deletions
evoprompt/optimization.py
with
6 additions
and
4 deletions
evoprompt/evolution.py
+
1
−
1
View file @
bbce7ee4
...
...
@@ -98,7 +98,7 @@ class EvolutionAlgorithm(PromptOptimization, metaclass=ABCMeta):
self
.
population_size
=
3
num_iterations
=
2
self
.
init_run
(
self
.
population_size
,
num_iterations
)
self
.
init_run
(
self
.
population_size
,
num_iterations
,
debug
=
debug
)
# Algorithm 1 Discrete prompt optimization: EVOPROMPT
...
...
This diff is collapsed.
Click to expand it.
evoprompt/optimization.py
+
5
−
3
View file @
bbce7ee4
...
...
@@ -158,9 +158,11 @@ class PromptOptimization:
)
return
self
.
task
.
evaluate_validation
(
prompt
,
parent_histories
)
def
get_initial_prompts
(
self
,
num_initial_prompts
:
int
):
def
get_initial_prompts
(
self
,
num_initial_prompts
:
int
,
debug
:
bool
=
False
):
# this implements the para_topk algorothm from https://github.com/beeevita/EvoPrompt
base_prompts
=
self
.
task
.
base_prompts
if
debug
:
base_prompts
=
base_prompts
[:
2
]
# evaluate all base prompts
logger
.
info
(
"
Evaluating base prompts.
"
)
...
...
@@ -239,7 +241,7 @@ class PromptOptimization:
def
get_prompts
(
self
,
prompt_ids
:
list
[
str
]):
return
[
self
.
get_prompt
(
p_id
)
for
p_id
in
prompt_ids
]
def
init_run
(
self
,
num_initial_prompts
:
int
,
num_iterations
:
int
):
def
init_run
(
self
,
num_initial_prompts
:
int
,
num_iterations
:
int
,
debug
:
bool
=
False
):
# family_tree contains the relation of prompts to its parents
self
.
family_tree
:
dict
[
str
,
tuple
[
str
,
...]
|
None
]
=
{}
# all_prompts contains a list of Prompt objects that took part in the optimization
...
...
@@ -255,7 +257,7 @@ class PromptOptimization:
self
.
save_snapshot
()
# the initial prompts
initial_prompts
,
prompt_sources
=
self
.
get_initial_prompts
(
num_initial_prompts
)
initial_prompts
,
prompt_sources
=
self
.
get_initial_prompts
(
num_initial_prompts
,
debug
=
debug
)
self
.
P
.
append
([])
for
prompt
,
prompt_source
in
zip
(
initial_prompts
,
prompt_sources
):
prompt
=
self
.
add_prompt
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment