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
316ee981
Commit
316ee981
authored
1 year ago
by
Grießhaber Daniel
Browse files
Options
Downloads
Patches
Plain Diff
use prompt ids in family tree
parent
85a06fd2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+8
-6
8 additions, 6 deletions
main.py
with
8 additions
and
6 deletions
main.py
+
8
−
6
View file @
316ee981
from
functools
import
lru_cache
import
os
from
functools
import
lru_cache
from
pathlib
import
Path
from
typing
import
Any
...
...
@@ -8,8 +8,8 @@ from numpy.random import choice
from
tqdm
import
trange
from
cli
import
argument_parser
from
task
import
QuestionAnswering
,
SentimentAnalysis
from
models
import
Llama2
,
OpenAI
from
task
import
QuestionAnswering
,
SentimentAnalysis
from
utils
import
(
Prompt
,
log_calls
,
...
...
@@ -185,14 +185,16 @@ def run_episode(evo_alg_str: str, debug: bool = False):
# converting prompts to Prompt object
P
=
[
[
Prompt
(
p
,
score
=
score
,
gen
=
0
,
meta
=
{
"
idx
"
:
idx
}
)
Prompt
(
p
,
score
=
score
,
gen
=
0
)
for
idx
,
(
p
,
score
)
in
enumerate
(
zip
(
initial_population
,
population_scores
))
]
]
# add initial prompts to family tree
# None marks that there is no parent
family_tree
=
[(
prompt
,
None
)
for
prompt
in
P
[
0
]]
family_tree
:
dict
[
str
,
tuple
[
str
,
str
]
|
None
]
=
{
prompt
.
id
:
None
for
prompt
in
P
[
0
]
}
# evolution = EvolutionGA(num_evolutions=N)
...
...
@@ -224,10 +226,10 @@ def run_episode(evo_alg_str: str, debug: bool = False):
# s′_i ← f(p′i,D)
s_i
=
f_D
(
p_i
)
evolved_prompt
=
Prompt
(
content
=
p_i
,
score
=
s_i
,
gen
=
t
,
meta
=
{
"
idx
"
:
i
}
)
evolved_prompt
=
Prompt
(
content
=
p_i
,
score
=
s_i
,
gen
=
t
)
# keep track of genealogy
family_tree
.
append
((
evolved_prompt
,
(
pr1
,
pr2
))
)
family_tree
[
evolved_prompt
.
id
]
=
(
pr1
.
id
,
pr2
.
id
)
new_evolutions
.
append
(
evolved_prompt
)
new_evolutions_scores
.
append
(
s_i
)
...
...
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