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
96f6880f
Commit
96f6880f
authored
4 months ago
by
Grießhaber Daniel
Browse files
Options
Downloads
Patches
Plain Diff
add usage metrics to wandb logs
parent
b2fb2928
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
evoprompt/evolution/evolution.py
+21
-1
21 additions, 1 deletion
evoprompt/evolution/evolution.py
with
21 additions
and
1 deletion
evoprompt/evolution/evolution.py
+
21
−
1
View file @
96f6880f
...
...
@@ -4,10 +4,10 @@ from abc import ABCMeta, abstractmethod
from
collections.abc
import
Iterable
from
typing
import
Any
import
wandb
import
weave
from
tqdm
import
trange
import
wandb
from
evoprompt.evolution.template_de
import
(
DE_DEMONSTRATION_DATA_CLS
,
DE_DEMONSTRATION_DATA_SIM
,
...
...
@@ -153,6 +153,23 @@ class EvolutionAlgorithm(PromptOptimization, metaclass=ABCMeta):
}
)
def
log_model_usage
(
self
,
evaluation_usage
:
ModelUsage
,
evolution_usage
:
ModelUsage
):
if
wandb
.
run
is
not
None
:
wandb
.
log
(
{
"
usage/evaluation/prompt_tokens
"
:
evaluation_usage
.
prompt_tokens
,
"
usage/evaluation/completion_tokens
"
:
evaluation_usage
.
completion_tokens
,
"
usage/evaluation/total_tokens
"
:
evaluation_usage
.
total_tokens
,
"
usage/evolution/prompt_tokens
"
:
evolution_usage
.
prompt_tokens
,
"
usage/evolution/completion_tokens
"
:
evolution_usage
.
completion_tokens
,
"
usage/evolution/total_tokens
"
:
evolution_usage
.
total_tokens
,
"
usage/total
"
:
evaluation_usage
.
total_tokens
+
evolution_usage
.
total_tokens
,
}
)
@weave.op
()
def
run
(
self
,
num_iterations
:
int
,
debug
:
bool
=
False
)
->
None
:
# debug mode for quick run
...
...
@@ -244,6 +261,9 @@ class EvolutionAlgorithm(PromptOptimization, metaclass=ABCMeta):
test_performance
,
_
,
_
=
self
.
task
.
evaluate_test
(
p
.
content
)
self
.
log_test_performance
(
test_performance
)
self
.
log_model_usage
(
self
.
total_evaluation_usage
,
self
.
total_evolution_usage
)
logger
.
info
(
"
Best prompt on test set: %s %s
"
,
...
...
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