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
gaoqiong
lm-evaluation-harness
Commits
96c60cf6
Commit
96c60cf6
authored
Sep 06, 2023
by
baberabb
Browse files
artifact loglikelihood results
parent
f1e62d36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
.github/workflows/unit_tests.yml
.github/workflows/unit_tests.yml
+6
-0
tests/models/test_huggingface.py
tests/models/test_huggingface.py
+9
-1
No files found.
.github/workflows/unit_tests.yml
View file @
96c60cf6
...
...
@@ -70,3 +70,9 @@ jobs:
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
-
name
:
Test with pytest
run
:
python -m pytest --showlocals -s -vv -n=auto --ignore=tests/tests_master --ignore=tests/extra
-
name
:
Archive artifacts
uses
:
actions/upload-artifact@v3
with
:
name
:
output_results
path
:
|
test_logs/*
tests/models/test_huggingface.py
View file @
96c60cf6
from
__future__
import
annotations
import
pytest
from
pathlib
import
Path
import
numpy
as
np
from
lm_eval.models.huggingface
import
HFLM
from
lm_eval.api.instance
import
Instance
import
lm_eval.tasks
as
tasks
import
sys
import
torch
class
Test_HFLM
:
torch
.
use_deterministic_algorithms
(
True
)
version_minor
=
sys
.
version_info
.
minor
multiple_choice_task
=
tasks
.
TASK_REGISTRY
.
get
(
"arc_easy"
)()
# type: ignore
multiple_choice_task
.
build_all_requests
(
limit
=
10
,
rank
=
0
,
world_size
=
1
)
MULTIPLE_CH
:
list
[
Instance
]
=
multiple_choice_task
.
instances
...
...
@@ -91,7 +94,12 @@ class Test_HFLM:
def
test_logliklihood
(
self
)
->
None
:
res
=
self
.
LM
.
loglikelihood
(
self
.
MULTIPLE_CH
)
_RES
,
_res
=
self
.
MULTIPLE_CH_RES
,
[
r
[
0
]
for
r
in
res
]
# change atol in case of consistent failure
# log samples to CI
file_path
=
Path
(
f
"test_logs/outputs_log_
{
self
.
version_minor
}
.txt"
)
file_path
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
file_path
=
file_path
.
resolve
()
with
open
(
file_path
,
"w"
)
as
f
:
f
.
write
(
"
\n
"
.
join
(
str
(
x
)
for
x
in
_res
))
assert
np
.
allclose
(
_res
,
_RES
,
atol
=
1e-4
)
# check indices for Multiple Choice
argmax_RES
,
argmax_res
=
np
.
argmax
(
...
...
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