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
03728b20
Commit
03728b20
authored
7 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Improve prompt extraction
parent
36eef613
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
+9
-5
9 additions, 5 deletions
evoprompt/evolution.py
evoprompt/template_de.py
+1
-1
1 addition, 1 deletion
evoprompt/template_de.py
with
10 additions
and
6 deletions
evoprompt/evolution.py
+
9
−
5
View file @
03728b20
...
...
@@ -250,14 +250,18 @@ class DifferentialEvolution(EvolutionAlgorithm):
),
)
matches
=
re
.
findall
(
#
TODO make sure that regex matches
also if </prompt> is missing
r
"
<prompt>(.*
?
)</prompt>
"
,
#
regex that matches any characters between last pair of <prompt></prompt>,
also if </prompt> is missing
r
"
<prompt>(
?!.*<prompt>)(?:(
.*)</prompt>
|(.*))
"
,
evolved_prompt
,
flags
=
(
re
.
IGNORECASE
|
re
.
DOTALL
),
)
if
matches
:
# we expect that the last match is where we find the prompt, other matches are part of the instruction (which the model repeats)
evolved_prompt
=
matches
[
-
1
]
if
matches
and
any
(
matches
[
0
]):
# there is always only a single match, and one group should be non-empty
if
matches
[
0
][
0
]:
evolved_prompt
=
matches
[
0
][
0
]
else
:
assert
matches
[
0
][
1
]
evolved_prompt
=
matches
[
0
][
1
]
else
:
# TODO what to do in this case? Discard generated prompt directly?
pass
...
...
This diff is collapsed.
Click to expand it.
evoprompt/template_de.py
+
1
−
1
View file @
03728b20
...
...
@@ -102,7 +102,7 @@ def get_de_prompt_template(use_demonstration_example: bool, task: None | Task =
if
use_demonstration_example
:
assert
(
task
is
not
None
),
"
Task cannot be
d
one if demonstation data should be used.
"
),
"
Task cannot be
N
one if demonstation data should be used.
"
if
isinstance
(
task
,
(
TextClassification
,
Summarization
)):
return
DE_PROMPT_WITH_DEMONSTRATION_SIM
...
...
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