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
64a960e6
Commit
64a960e6
authored
6 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Skipping prompts will no longer result in logging old prompts
parent
e7d464d6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
evoprompt/evolution/evolution.py
+14
-7
14 additions, 7 deletions
evoprompt/evolution/evolution.py
evoprompt/task/task.py
+1
-1
1 addition, 1 deletion
evoprompt/task/task.py
with
15 additions
and
8 deletions
evoprompt/evolution/evolution.py
+
14
−
7
View file @
64a960e6
...
...
@@ -214,7 +214,9 @@ class EvolutionAlgorithm(PromptOptimization, metaclass=ABCMeta):
self
.
log_prompt
(
evolved_prompt
,
t
,
i
)
new_evolutions
.
append
(
evolved_prompt
)
self
.
save_snapshot
()
else
:
new_evolutions
.
append
(
None
)
self
.
save_snapshot
()
# Line 6: Update based on the evaluation scores
# Pt ← {Pt−1, p′i} and St ← {St−1, s′i}
new_population
=
self
.
update
(
new_evolutions
,
prompts_current_evolution
)
...
...
@@ -337,6 +339,8 @@ class GeneticAlgorithm(EvolutionAlgorithm):
retained_prompts
:
list
[
Prompt
]
=
[]
min_retained_score
=
0
for
prompt
in
prompts_current_evolution
+
new_evolutions
:
if
prompt
is
None
:
continue
if
len
(
retained_prompts
)
<
self
.
population_size
:
retained_prompts
.
append
(
prompt
)
min_retained_score
=
min
(
min_retained_score
,
prompt
.
score
)
...
...
@@ -415,9 +419,9 @@ class DifferentialEvolution(EvolutionAlgorithm):
)
if
judgement
.
skip
:
# user asked to skip this prompt
, for DE this means using the basic prompt
# user asked to skip this prompt
return
(
prompts_current_evolution
[
current_iteration
].
content
,
None
,
[
judgement
],
usage
,
)
...
...
@@ -428,9 +432,9 @@ class DifferentialEvolution(EvolutionAlgorithm):
if
evolved_prompt
is
None
:
logger
.
info
(
f
"
Could not extract prompt from response:
{
evolved_prompt
}
"
)
# no prompt was returned (e.g., evolved prompt could not be extracted)
, therefore, for DE, we use the basic prompt
# no prompt was returned (e.g., evolved prompt could not be extracted)
return
(
prompts_current_evolution
[
current_iteration
].
content
,
None
,
[
judgement
],
usage
,
)
...
...
@@ -453,7 +457,11 @@ class DifferentialEvolution(EvolutionAlgorithm):
# for DE we keep the evolved prompt if it is better than the basic prompt, and use the basic prompt otherwise
assert
len
(
prompts_current_evolution
)
==
len
(
new_evolutions
)
population
=
[
(
new_prompt
if
new_prompt
.
score
>
current_prompt
.
score
else
current_prompt
)
(
new_prompt
if
new_prompt
is
not
None
and
new_prompt
.
score
>
current_prompt
.
score
else
current_prompt
)
for
current_prompt
,
new_prompt
in
zip
(
prompts_current_evolution
,
new_evolutions
)
...
...
@@ -553,7 +561,6 @@ class DifferentialEvolutionWithCot(DifferentialEvolution):
response
,
)
# TODO use serialized messages as prompt or use previous evolution steps as history?
input
(
f
"
{
len
(
evolutions_steps
)
}
,
\n
{
evolutions_steps
}
"
)
judgement
=
self
.
judge_and_correct_step
(
filled_prompt
,
response
,
...
...
This diff is collapsed.
Click to expand it.
evoprompt/task/task.py
+
1
−
1
View file @
64a960e6
...
...
@@ -411,7 +411,7 @@ class Task(metaclass=ABCMeta):
system_message
,
prompt_for_datum
=
self
.
build_prompt_input
(
datum
,
instruction
,
use_prediction_prefix
=
self
.
force_task_prediction_prefix
)
logger
.
debug
(
f
"
Prompt for datum:
\n
{
prompt_for_datum
}
"
)
logger
.
debug
(
f
"
==== Task Prediction ====
\n
System message:
\n\t
{
system_message
}
\n
Prompt for datum:
\n
\t
{
prompt_for_datum
}
\n
History:
\n\t
{
history
}
"
)
response
,
_
,
_
,
usage
=
self
.
model
.
create_completion
(
system_message
=
system_message
,
messages
=
prompt_for_datum
,
...
...
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