-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into accelerate-rag-metrics
- Loading branch information
Showing
27 changed files
with
692 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from unitxt import add_to_catalog | ||
from unitxt.metrics import ExactMatchMM | ||
from unitxt.test_utils.metrics import test_metric | ||
|
||
metric = ExactMatchMM(n_resamples=None) | ||
|
||
predictions = ["A", "B", "C"] | ||
references = [["B"], ["A"], ["C"]] | ||
|
||
instance_targets = [ | ||
{"exact_match_mm": 0.0, "score": 0.0, "score_name": "exact_match_mm"}, | ||
{"exact_match_mm": 0.0, "score": 0.0, "score_name": "exact_match_mm"}, | ||
{"exact_match_mm": 1.0, "score": 1.0, "score_name": "exact_match_mm"}, | ||
] | ||
|
||
global_target = { | ||
"exact_match_mm": 0.33, | ||
"score": 0.33, | ||
"score_name": "exact_match_mm", | ||
"num_of_instances": 3, | ||
} | ||
|
||
outputs = test_metric( | ||
metric=metric, | ||
predictions=predictions, | ||
references=references, | ||
instance_targets=instance_targets, | ||
global_target=global_target, | ||
) | ||
|
||
add_to_catalog(metric, "metrics.exact_match_mm", overwrite=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from unitxt import add_to_catalog | ||
from unitxt.metrics import RelaxedCorrectness | ||
from unitxt.test_utils.metrics import test_metric | ||
|
||
# from cvar_pyutils.debugging_tools import set_remote_debugger | ||
# set_remote_debugger('9.61.188.58', 55557) | ||
metric = RelaxedCorrectness(n_resamples=None) | ||
|
||
predictions = ["10", "30"] | ||
references = [["14"], ["30"]] | ||
|
||
# how to create a metric which isn't updated in every sample when using UNITXT? | ||
instance_targets = [ | ||
{ | ||
"relaxed_overall": 0.0, | ||
"relaxed_human_split": 0.0, | ||
"score": 0.0, | ||
"score_name": "relaxed_overall", | ||
}, | ||
{ | ||
"relaxed_overall": 1.0, | ||
"relaxed_augmented_split": 1.0, | ||
"score": 1.0, | ||
"score_name": "relaxed_overall", | ||
}, | ||
] | ||
|
||
global_target = { | ||
"relaxed_overall": 0.5, | ||
"relaxed_human_split": 0.0, | ||
"relaxed_augmented_split": 1.0, | ||
"score": 0.5, | ||
"score_name": "relaxed_overall", | ||
"num_of_instances": 2, | ||
} | ||
outputs = test_metric( | ||
metric=metric, | ||
predictions=predictions, | ||
references=references, | ||
instance_targets=instance_targets, | ||
global_target=global_target, | ||
task_data=[{"type": "human_test"}, {"type": "augmented_test"}], | ||
) | ||
add_to_catalog(metric, "metrics.relaxed_correctness", overwrite=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from unitxt import add_to_catalog | ||
from unitxt.metrics import WebsrcSquadF1 | ||
from unitxt.test_utils.metrics import test_metric | ||
|
||
# from cvar_pyutils.debugging_tools import set_remote_debugger | ||
# set_remote_debugger('9.148.189.104', 55557) | ||
metric = WebsrcSquadF1(n_resamples=None) | ||
|
||
predictions = ["The 2nd", "The 1st"] | ||
references = [["The 2nd"], ["The 2nd"]] | ||
|
||
# how to create a metric which isn't updated in every sample when using UNITXT? | ||
instance_targets = [ | ||
{ | ||
"websrc_squad_f1": 1.0, | ||
"score": 1.0, | ||
"score_name": "websrc_squad_f1", | ||
}, | ||
{ | ||
"websrc_squad_f1": 0.5, | ||
"score": 0.5, | ||
"score_name": "websrc_squad_f1", | ||
}, | ||
] | ||
global_target = { | ||
"num_of_instances": 2, | ||
"websrc_squad_f1": 0.75, | ||
"score": 0.75, | ||
"score_name": "websrc_squad_f1", | ||
} | ||
outputs = test_metric( | ||
metric=metric, | ||
predictions=predictions, | ||
references=references, | ||
instance_targets=instance_targets, | ||
global_target=global_target, | ||
task_data=[{"domain": "movie"}, {"domain": "movie"}], | ||
) | ||
add_to_catalog(metric, "metrics.websrc_squad_f1", overwrite=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.