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
c203cb79
Commit
c203cb79
authored
3 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Consider limit for annotations per evolution
parent
0e697c53
No related branches found
Branches containing commit
No related tags found
1 merge request
!11
Add human feedback
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
evoprompt/evolution/evolution.py
+22
-5
22 additions, 5 deletions
evoprompt/evolution/evolution.py
with
22 additions
and
5 deletions
evoprompt/evolution/evolution.py
+
22
−
5
View file @
c203cb79
...
...
@@ -43,7 +43,13 @@ SYSTEM_MESSAGE = "Please carefully follow the instruction step-by-step."
class
EvolutionAnnotationHandler
:
def
__init__
(
self
,
*
,
strategy
,
max_annotations
=
5
,
max_annotations_per_evolution
=
1
):
def
__init__
(
self
,
*
,
strategy
:
str
,
max_annotations
:
int
=
5
,
max_annotations_per_evolution
:
int
=
1
,
):
# TODO: we could also distribute the max_annotations over the different evolution steps
self
.
annotation_handlers
:
dict
[
int
,
AnnotationHandler
]
=
defaultdict
(
partial
(
...
...
@@ -65,10 +71,14 @@ class EvolutionAnnotationHandler:
if
self
.
strategy
is
None
:
# disable annotation
return
False
if
len
(
self
)
<
self
.
max_annotations
:
if
self
.
strategy
==
"
simple
"
:
# for the simple strategy, we do annotations until we reach the limit
return
True
if
self
.
strategy
==
"
simple
"
:
# for the simple strategy, we do annotations until we reach the limit, and optionally limit the number of annotations per evolution
if
len
(
self
)
<
self
.
max_annotations
:
if
self
.
max_annotations_per_evolution
is
None
or
(
len
(
self
.
get_annotations_for_evolution
(
generation
,
update_step
))
<
self
.
max_annotations_per_evolution
):
return
True
return
False
def
add_annotation
(
...
...
@@ -92,6 +102,13 @@ class EvolutionAnnotationHandler:
return
self
.
annotation_handlers
[
evolution_step
].
get_annotations
()
raise
NotImplementedError
(
f
"
Strategy
'
{
self
.
strategy
}
'
is not implemented.
"
)
def
get_annotations_for_evolution
(
self
,
generation
:
int
,
update_step
:
int
):
return
[
sample
for
handler
in
self
.
annotation_handlers
.
values
()
for
sample
in
handler
.
annotated_samples
[(
generation
,
update_step
)]
]
class
EvolutionAlgorithm
(
PromptOptimization
,
metaclass
=
ABCMeta
):
shorthand
:
str
...
...
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