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
37d991ad
Commit
37d991ad
authored
9 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Allow to generate unique paraphrases
parent
5b1c997f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
optimization.py
+13
-8
13 additions, 8 deletions
optimization.py
with
13 additions
and
8 deletions
optimization.py
+
13
−
8
View file @
37d991ad
...
...
@@ -18,14 +18,17 @@ def paraphrase_prompts(
model
:
LLMModel
,
prompt
:
str
,
n
:
int
,
unique_p
rompt
s
:
bool
=
False
,
num
_tries
:
int
=
10
,
return_only_unique_p
rompt
s
:
bool
=
False
,
unique_p
araphrase
s
:
bool
=
False
,
max
_tries
:
int
=
10
,
return_only_unique_p
araphrase
s
:
bool
=
False
,
):
# TODO implement unique paraphrases
total_usage
=
ModelUsage
()
paraphrases
=
[]
for
_
in
range
(
n
):
num_tries
=
0
while
len
(
paraphrases
)
<
n
:
if
num_tries
>=
max_tries
:
break
num_tries
+=
1
paraphrase
,
usage
=
model
(
system_message
=
PARAPHRASE_PROMPT
,
prompt
=
prompt
,
...
...
@@ -35,10 +38,12 @@ def paraphrase_prompts(
total_usage
+=
usage
if
"
<prompt>
"
in
paraphrase
:
paraphrase
=
paraphrase
.
split
(
"
<prompt>
"
)[
1
].
split
(
"
</prompt>
"
)[
0
]
paraphrases
.
append
(
paraphrase
)
if
return_only_unique_prompts
:
if
not
unique_paraphrases
or
paraphrase
not
in
paraphrases
:
# add paraphrase only if not already present if unique_paraphrases==True
paraphrases
.
append
(
paraphrase
)
if
return_only_unique_paraphrases
:
paraphrases
=
list
(
set
(
paraphrases
))
return
paraphrases
,
usage
return
paraphrases
,
total_
usage
class
PromptOptimization
:
...
...
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