Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
opencompass
Commits
fbb912dd
Unverified
Commit
fbb912dd
authored
Dec 21, 2023
by
bittersweet1999
Committed by
GitHub
Dec 21, 2023
Browse files
[Feature] Add abbr for judgemodel in subjective evaluation (#724)
* add_judgemodel_abbr * add judgemodel abbr
parent
b35d9917
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
10 deletions
+45
-10
opencompass/summarizers/alignmentbench.py
opencompass/summarizers/alignmentbench.py
+4
-3
opencompass/summarizers/corev2.py
opencompass/summarizers/corev2.py
+3
-2
opencompass/summarizers/creationv01.py
opencompass/summarizers/creationv01.py
+3
-2
opencompass/tasks/subjective_eval.py
opencompass/tasks/subjective_eval.py
+34
-2
tools/convert_alignmentbench.py
tools/convert_alignmentbench.py
+1
-1
No files found.
opencompass/summarizers/alignmentbench.py
View file @
fbb912dd
...
@@ -116,15 +116,16 @@ class AlignmentBenchSummarizer:
...
@@ -116,15 +116,16 @@ class AlignmentBenchSummarizer:
output_dir
=
osp
.
join
(
osp
.
split
(
output_path
)[
0
],
f
'
{
self
.
time_str
}
'
)
output_dir
=
osp
.
join
(
osp
.
split
(
output_path
)[
0
],
f
'
{
self
.
time_str
}
'
)
mmengine
.
mkdir_or_exist
(
output_dir
)
mmengine
.
mkdir_or_exist
(
output_dir
)
results_folder
=
osp
.
join
(
work_dir
,
'results'
)
results_folder
=
osp
.
join
(
work_dir
,
'results'
)
fout
=
osp
.
join
(
output_dir
,
'dimension.csv'
)
fout2
=
osp
.
join
(
output_dir
,
'capability.csv'
)
fout_flag
,
fout_flag2
=
0
,
0
fout_flag
,
fout_flag2
=
0
,
0
for
subdir
in
os
.
listdir
(
results_folder
):
for
subdir
in
os
.
listdir
(
results_folder
):
if
subdir
not
in
self
.
eval_model_abbrs
:
if
subdir
not
in
self
.
eval_model_abbrs
:
continue
continue
subdir_path
=
os
.
path
.
join
(
results_folder
,
subdir
)
subdir_path
=
os
.
path
.
join
(
results_folder
,
subdir
)
if
os
.
path
.
isdir
(
subdir_path
):
if
os
.
path
.
isdir
(
subdir_path
):
model
=
subdir
model
,
judge_model
=
subdir
.
split
(
'_'
)
fout
=
osp
.
join
(
output_dir
,
judge_model
+
'dimension.csv'
)
fout2
=
osp
.
join
(
output_dir
,
judge_model
+
'capability.csv'
)
for
dataset
in
dataset_cfgs
:
for
dataset
in
dataset_cfgs
:
dataset_abbr
=
dataset_abbr_from_cfg
(
dataset
)
dataset_abbr
=
dataset_abbr_from_cfg
(
dataset
)
filepath
=
os
.
path
.
join
(
subdir_path
,
filepath
=
os
.
path
.
join
(
subdir_path
,
...
...
opencompass/summarizers/corev2.py
View file @
fbb912dd
...
@@ -75,11 +75,12 @@ class Corev2Summarizer:
...
@@ -75,11 +75,12 @@ class Corev2Summarizer:
output_dir
=
osp
.
join
(
osp
.
split
(
output_path
)[
0
],
f
'
{
self
.
time_str
}
'
)
output_dir
=
osp
.
join
(
osp
.
split
(
output_path
)[
0
],
f
'
{
self
.
time_str
}
'
)
mmengine
.
mkdir_or_exist
(
output_dir
)
mmengine
.
mkdir_or_exist
(
output_dir
)
results_folder
=
osp
.
join
(
work_dir
,
'results'
)
results_folder
=
osp
.
join
(
work_dir
,
'results'
)
fout
=
osp
.
join
(
output_dir
,
'report.csv'
)
for
subdir
in
os
.
listdir
(
results_folder
):
for
subdir
in
os
.
listdir
(
results_folder
):
subdir_path
=
os
.
path
.
join
(
results_folder
,
subdir
)
subdir_path
=
os
.
path
.
join
(
results_folder
,
subdir
)
if
os
.
path
.
isdir
(
subdir_path
):
if
os
.
path
.
isdir
(
subdir_path
):
model1
,
model2
=
subdir
.
split
(
'_'
)
model1
,
model2
,
judge_model
=
subdir
.
split
(
'_'
)
fout
=
osp
.
join
(
output_dir
,
judge_model
+
'-report.csv'
)
for
dataset
in
dataset_cfgs
:
for
dataset
in
dataset_cfgs
:
dataset_abbr
=
dataset_abbr_from_cfg
(
dataset
)
dataset_abbr
=
dataset_abbr_from_cfg
(
dataset
)
filepath
=
os
.
path
.
join
(
subdir_path
,
filepath
=
os
.
path
.
join
(
subdir_path
,
...
...
opencompass/summarizers/creationv01.py
View file @
fbb912dd
...
@@ -76,11 +76,12 @@ class Creationv01Summarizer:
...
@@ -76,11 +76,12 @@ class Creationv01Summarizer:
output_dir
=
osp
.
join
(
osp
.
split
(
output_path
)[
0
],
f
'
{
self
.
time_str
}
'
)
output_dir
=
osp
.
join
(
osp
.
split
(
output_path
)[
0
],
f
'
{
self
.
time_str
}
'
)
mmengine
.
mkdir_or_exist
(
output_dir
)
mmengine
.
mkdir_or_exist
(
output_dir
)
results_folder
=
osp
.
join
(
work_dir
,
'results'
)
results_folder
=
osp
.
join
(
work_dir
,
'results'
)
fout
=
osp
.
join
(
output_dir
,
'report.csv'
)
for
subdir
in
os
.
listdir
(
results_folder
):
for
subdir
in
os
.
listdir
(
results_folder
):
subdir_path
=
os
.
path
.
join
(
results_folder
,
subdir
)
subdir_path
=
os
.
path
.
join
(
results_folder
,
subdir
)
if
os
.
path
.
isdir
(
subdir_path
):
if
os
.
path
.
isdir
(
subdir_path
):
model
=
subdir
model
,
judge_model
=
subdir
.
split
(
'_'
)
fout
=
osp
.
join
(
output_dir
,
judge_model
+
'-report.csv'
)
for
dataset
in
dataset_cfgs
:
for
dataset
in
dataset_cfgs
:
dataset_abbr
=
dataset_abbr_from_cfg
(
dataset
)
dataset_abbr
=
dataset_abbr_from_cfg
(
dataset
)
filepath
=
os
.
path
.
join
(
subdir_path
,
filepath
=
os
.
path
.
join
(
subdir_path
,
...
...
opencompass/tasks/subjective_eval.py
View file @
fbb912dd
...
@@ -69,7 +69,11 @@ class SubjectiveEvalTask(BaseTask):
...
@@ -69,7 +69,11 @@ class SubjectiveEvalTask(BaseTask):
# Load Dataset
# Load Dataset
eval_cfg
=
dataset_cfg
.
get
(
'eval_cfg'
)
eval_cfg
=
dataset_cfg
.
get
(
'eval_cfg'
)
output_column
=
dataset_cfg
[
'reader_cfg'
][
'output_column'
]
output_column
=
dataset_cfg
[
'reader_cfg'
][
'output_column'
]
if
type
(
model_cfg
)
==
ConfigDict
:
model_cfg
=
(
model_cfg
,
)
model_cfg
+=
({
'abbr'
:
'judged-by--'
+
self
.
judge_cfg
[
'abbr'
]
},
)
out_path
=
get_infer_output_path
(
out_path
=
get_infer_output_path
(
model_cfg
,
dataset_cfg
,
osp
.
join
(
self
.
work_dir
,
'results'
))
model_cfg
,
dataset_cfg
,
osp
.
join
(
self
.
work_dir
,
'results'
))
if
osp
.
exists
(
out_path
):
if
osp
.
exists
(
out_path
):
...
@@ -153,7 +157,14 @@ class SubjectiveEvalTask(BaseTask):
...
@@ -153,7 +157,14 @@ class SubjectiveEvalTask(BaseTask):
# Get out_path
# Get out_path
out_path
=
get_infer_output_path
(
model_cfg
,
dataset_cfg
,
out_path
=
get_infer_output_path
(
model_cfg
,
dataset_cfg
,
osp
.
join
(
self
.
work_dir
,
'results'
))
osp
.
join
(
self
.
work_dir
,
'results'
))
model_preds
=
self
.
_load_model_pred
(
model_cfg
,
dataset_cfg
,
eval_cfg
)
new_model_cfg
=
[]
for
m_cfg
in
model_cfg
:
if
len
(
m_cfg
)
>
1
:
new_model_cfg
.
append
(
m_cfg
)
if
len
(
new_model_cfg
)
==
1
:
new_model_cfg
=
new_model_cfg
[
0
]
model_preds
=
self
.
_load_model_pred
(
new_model_cfg
,
dataset_cfg
,
eval_cfg
)
if
not
self
.
judge_cfg
:
if
not
self
.
judge_cfg
:
raise
ValueError
(
'missing "eval.runner.task.judge_cfg"'
)
raise
ValueError
(
'missing "eval.runner.task.judge_cfg"'
)
eval_cfg
[
'evaluator'
][
'judge_cfg'
]
=
self
.
judge_cfg
eval_cfg
[
'evaluator'
][
'judge_cfg'
]
=
self
.
judge_cfg
...
@@ -210,6 +221,27 @@ class SubjectiveEvalTask(BaseTask):
...
@@ -210,6 +221,27 @@ class SubjectiveEvalTask(BaseTask):
return
s
[
start
:
end
]
return
s
[
start
:
end
]
def
get_output_paths
(
self
,
file_extension
:
str
=
'json'
)
->
List
[
str
]:
"""Get the paths to the output files. Every file should exist if the
task succeeds.
Args:
file_extension (str): The file extension of the output files.
Default: 'json'.
"""
output_paths
=
[]
for
model
,
datasets
in
zip
(
self
.
model_cfgs
,
self
.
dataset_cfgs
):
for
dataset
in
datasets
:
if
type
(
model
)
==
ConfigDict
:
model
=
(
model
,
)
model
+=
({
'abbr'
:
'judged-by--'
+
self
.
judge_cfg
[
'abbr'
]},
)
output_paths
.
append
(
get_infer_output_path
(
model
,
dataset
,
osp
.
join
(
self
.
work_dir
,
self
.
output_subdir
),
file_extension
))
return
output_paths
def
parse_args
():
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Score Calculator'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'Score Calculator'
)
...
...
tools/convert_alignmentbench.py
View file @
fbb912dd
...
@@ -29,7 +29,7 @@ def extract_predictions_from_json(input_folder):
...
@@ -29,7 +29,7 @@ def extract_predictions_from_json(input_folder):
# for prediction
# for prediction
output_path
=
os
.
path
.
join
(
sub_folder
,
model_name
+
'_submission.csv'
)
output_path
=
os
.
path
.
join
(
sub_folder
,
model_name
+
'_submission.csv'
)
with
open
(
output_path
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
with
open
(
output_path
,
'w'
,
encoding
=
'utf-8
-sig
'
)
as
file
:
writer
=
csv
.
writer
(
file
)
writer
=
csv
.
writer
(
file
)
for
ans
in
tqdm
(
all_predictions
):
for
ans
in
tqdm
(
all_predictions
):
writer
.
writerow
([
str
(
ans
)])
writer
.
writerow
([
str
(
ans
)])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment