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
ColossalAI
Commits
3ff60d13
Unverified
Commit
3ff60d13
authored
Dec 15, 2023
by
Yuanchen
Committed by
GitHub
Dec 15, 2023
Browse files
Fix ColossalEval (#5186)
Co-authored-by:
Xu Yuanchen
<
yuanchen.xu00@gmail.com
>
parent
79718fae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
applications/ColossalEval/colossal_eval/evaluate/dataset_evaluator/dataset_evaluator.py
...ssal_eval/evaluate/dataset_evaluator/dataset_evaluator.py
+13
-15
applications/ColossalEval/colossal_eval/models/huggingface.py
...ications/ColossalEval/colossal_eval/models/huggingface.py
+4
-5
No files found.
applications/ColossalEval/colossal_eval/evaluate/dataset_evaluator/dataset_evaluator.py
View file @
3ff60d13
...
...
@@ -58,12 +58,12 @@ class DatasetEvaluator(object):
[
sample
[
"output"
]
for
sample
in
self
.
data
[
category
][
"data"
]]
flag
=
False
softmax
s
=
[]
logit
s
=
[]
for
i
,
sample
in
enumerate
(
self
.
data
[
category
][
"data"
]):
if
np
.
any
(
np
.
isnan
(
np
.
array
(
list
(
sample
[
"
softmax
_over_choices"
].
values
())))):
if
np
.
any
(
np
.
isnan
(
np
.
array
(
list
(
sample
[
"
logits
_over_choices"
].
values
())))):
if
not
flag
:
print
(
f
"NaN in the
softmax
, switch to exact match for category
{
category
}
in dataset
{
self
.
dataset_name
}
in model
{
self
.
model_name
}
."
f
"NaN in the
logits
, switch to exact match for category
{
category
}
in dataset
{
self
.
dataset_name
}
in model
{
self
.
model_name
}
."
)
flag
=
True
score
=
0
...
...
@@ -79,13 +79,13 @@ class DatasetEvaluator(object):
score
,
metric_helper
.
accuracy_by_options
(
sample
[
"input"
],
sample
[
"output"
],
ref
),
)
softmax
s
.
append
(
references
[
i
]
if
score
==
1
else
-
1
)
logit
s
.
append
(
references
[
i
]
if
score
==
1
else
-
1
)
else
:
softmax
s
.
append
(
np
.
argmax
(
np
.
array
(
list
(
sample
[
"
softmax
_over_choices"
].
values
()))))
logit
s
.
append
(
np
.
argmax
(
np
.
array
(
list
(
sample
[
"
logits
_over_choices"
].
values
()))))
references
=
np
.
array
(
references
)
softmax
s
=
np
.
array
(
softmax
s
)
scores
=
np
.
sum
(
references
==
softmax
s
)
/
len
(
self
.
data
[
category
][
"data"
])
*
100
logit
s
=
np
.
array
(
logit
s
)
scores
=
np
.
sum
(
references
==
logit
s
)
/
len
(
self
.
data
[
category
][
"data"
])
*
100
self
.
evaluation_results
[
metric
][
category
]
=
(
scores
,
len
(
self
.
data
[
category
][
"data"
]))
self
.
evaluation_results
[
metric
][
"ALL"
]
+=
scores
*
weight
...
...
@@ -105,12 +105,12 @@ class DatasetEvaluator(object):
predictions
=
[
sample
[
"output"
]
for
sample
in
self
.
data
[
category
][
"data"
]]
flag
=
False
softmax
s
=
[]
logit
s
=
[]
for
i
,
sample
in
enumerate
(
self
.
data
[
category
][
"data"
]):
if
np
.
any
(
np
.
isnan
(
np
.
array
(
list
(
sample
[
"
softmax
_over_choices"
].
values
())))):
if
np
.
any
(
np
.
isnan
(
np
.
array
(
list
(
sample
[
"
logits
_over_choices"
].
values
())))):
if
not
flag
:
print
(
f
"NaN in the
softmax
, switch to exact match for category
{
category
}
in dataset
{
self
.
dataset_name
}
in model
{
self
.
model_name
}
."
f
"NaN in the
logits
, switch to exact match for category
{
category
}
in dataset
{
self
.
dataset_name
}
in model
{
self
.
model_name
}
."
)
flag
=
True
score
=
0
...
...
@@ -121,16 +121,14 @@ class DatasetEvaluator(object):
sample
[
"output"
],
ref
,
all_classes
=
self
.
data
[
category
][
"inference_kwargs"
][
"all_classes"
]
),
)
softmax
s
.
append
(
references
[
i
]
if
score
==
1
else
-
1
)
logit
s
.
append
(
references
[
i
]
if
score
==
1
else
-
1
)
else
:
softmax
s
.
append
(
np
.
argmax
(
np
.
array
(
list
(
sample
[
"
softmax
_over_choices"
].
values
()))))
logit
s
.
append
(
np
.
argmax
(
np
.
array
(
list
(
sample
[
"
logits
_over_choices"
].
values
()))))
metric_method
=
eval
(
"metric_helper."
+
metric
)
total_score
=
0.0
for
prediction
,
reference
,
references_label
,
softmax
in
zip
(
predictions
,
references
,
references_labels
,
softmaxs
):
for
prediction
,
reference
,
references_label
,
softmax
in
zip
(
predictions
,
references
,
references_labels
,
logits
):
score
=
0.0
for
ref
in
reference
:
...
...
applications/ColossalEval/colossal_eval/models/huggingface.py
View file @
3ff60d13
...
...
@@ -116,10 +116,10 @@ class HuggingFaceModel(BaseModel):
shard_config: Shard config for tensor parallel.
"""
model_kwargs
.
setdefault
(
"torch_dtype"
,
torch
.
float16
)
if
"torch_dtype"
in
model_kwargs
:
model_kwargs
[
"torch_dtype"
]
=
eval
(
model_kwargs
[
"torch_dtype"
])
else
:
model_kwargs
.
setdefault
(
"torch_dtype"
,
torch
.
float16
)
if
"config"
in
model_kwargs
:
model_kwargs
[
"config"
]
=
AutoConfig
.
from_pretrained
(
model_kwargs
[
"config"
])
...
...
@@ -586,11 +586,10 @@ class HuggingFaceCausalLM(HuggingFaceModel):
shard_config: Shard config for tensor parallel.
"""
model_kwargs
.
setdefault
(
"torch_dtype"
,
torch
.
float16
)
if
"torch_dtype"
in
model_kwargs
:
model_kwargs
[
"torch_dtype"
]
=
eval
(
model_kwargs
[
"torch_dtype"
])
else
:
model_kwargs
.
setdefault
(
"torch_dtype"
,
torch
.
float16
)
if
"config"
in
model_kwargs
:
model_kwargs
[
"config"
]
=
AutoConfig
.
from_pretrained
(
model_kwargs
[
"config"
])
...
...
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