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
97bc9780
Unverified
Commit
97bc9780
authored
Nov 03, 2023
by
Hailey Schoelkopf
Committed by
GitHub
Nov 03, 2023
Browse files
Update and rename test_ggml.py to test_gguf.py
parent
2d433a4a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
tests/test_gguf.py
tests/test_gguf.py
+12
-12
No files found.
tests/test_gg
ml
.py
→
tests/test_gg
uf
.py
View file @
97bc9780
...
@@ -4,11 +4,11 @@ import hashlib
...
@@ -4,11 +4,11 @@ import hashlib
import
json
import
json
import
os
import
os
import
pickle
import
pickle
from
lm_eval.models.gg
ml
import
GG
ML
LM
from
lm_eval.models.gg
uf
import
GG
UF
LM
base_url
=
"https://matthoffner-ggml-llm-api.hf.space"
base_url
=
"https://matthoffner-ggml-llm-api.hf.space"
def
gg
ml
_completion_mock
(
base_url
,
**
kwargs
):
def
gg
uf
_completion_mock
(
base_url
,
**
kwargs
):
# Generate a hash from the parameters
# Generate a hash from the parameters
hash_kwargs
=
{
'base_url'
:
base_url
,
**
kwargs
}
hash_kwargs
=
{
'base_url'
:
base_url
,
**
kwargs
}
hash
=
hashlib
.
sha256
(
json
.
dumps
(
hash_kwargs
,
sort_keys
=
True
).
encode
(
'utf-8'
)).
hexdigest
()
hash
=
hashlib
.
sha256
(
json
.
dumps
(
hash_kwargs
,
sort_keys
=
True
).
encode
(
'utf-8'
)).
hexdigest
()
...
@@ -37,10 +37,10 @@ def ggml_completion_mock(base_url, **kwargs):
...
@@ -37,10 +37,10 @@ def ggml_completion_mock(base_url, **kwargs):
return
result
return
result
class
GG
ML
LMTest
(
unittest
.
TestCase
):
class
GG
UF
LMTest
(
unittest
.
TestCase
):
@
patch
(
'lm_eval.models.gg
ml
.GG
ML
LM.gg
ml
_completion'
,
side_effect
=
gg
ml
_completion_mock
)
@
patch
(
'lm_eval.models.gg
uf
.GG
UF
LM.gg
uf
_completion'
,
side_effect
=
gg
uf
_completion_mock
)
def
test_loglikelihood
(
self
,
gg
ml
_completion_mock
):
def
test_loglikelihood
(
self
,
gg
uf
_completion_mock
):
lm
=
GG
ML
LM
(
base_url
)
lm
=
GG
UF
LM
(
base_url
)
# Test loglikelihood
# Test loglikelihood
requests
=
[(
"context1"
,
"continuation1"
),
(
"context2"
,
"continuation2"
)]
requests
=
[(
"context1"
,
"continuation1"
),
(
"context2"
,
"continuation2"
)]
...
@@ -50,9 +50,9 @@ class GGMLLMTest(unittest.TestCase):
...
@@ -50,9 +50,9 @@ class GGMLLMTest(unittest.TestCase):
expected_res
=
[(
logprob
,
True
)
for
logprob
in
[
-
1.2345
,
-
1.2345
]]
expected_res
=
[(
logprob
,
True
)
for
logprob
in
[
-
1.2345
,
-
1.2345
]]
self
.
assertEqual
(
res
,
expected_res
)
self
.
assertEqual
(
res
,
expected_res
)
@
patch
(
'lm_eval.models.gg
ml
.GG
ML
LM.gg
ml
_completion'
,
side_effect
=
gg
ml
_completion_mock
)
@
patch
(
'lm_eval.models.gg
uf
.GG
UF
LM.gg
uf
_completion'
,
side_effect
=
gg
uf
_completion_mock
)
def
test_greedy_until
(
self
,
gg
ml
_completion_mock
):
def
test_greedy_until
(
self
,
gg
uf
_completion_mock
):
lm
=
GG
ML
LM
(
base_url
)
lm
=
GG
UF
LM
(
base_url
)
# Test greedy_until
# Test greedy_until
requests
=
[(
"input1"
,
{
"until"
:
"stop1"
}),
(
"input2"
,
{
"until"
:
"stop2"
})]
requests
=
[(
"input1"
,
{
"until"
:
"stop1"
}),
(
"input2"
,
{
"until"
:
"stop2"
})]
...
@@ -62,9 +62,9 @@ class GGMLLMTest(unittest.TestCase):
...
@@ -62,9 +62,9 @@ class GGMLLMTest(unittest.TestCase):
expected_res
=
[
"generated text until stop1"
,
"generated text until stop2"
]
expected_res
=
[
"generated text until stop1"
,
"generated text until stop2"
]
self
.
assertEqual
(
res
,
expected_res
)
self
.
assertEqual
(
res
,
expected_res
)
@
patch
(
'lm_eval.models.gg
ml
.GG
ML
LM.gg
ml
_completion'
,
side_effect
=
gg
ml
_completion_mock
)
@
patch
(
'lm_eval.models.gg
uf
.GG
UF
LM.gg
uf
_completion'
,
side_effect
=
gg
uf
_completion_mock
)
def
test_loglikelihood_rolling
(
self
,
gg
ml
_completion_mock
):
def
test_loglikelihood_rolling
(
self
,
gg
uf
_completion_mock
):
lm
=
GG
ML
LM
(
base_url
)
lm
=
GG
UF
LM
(
base_url
)
# Test loglikelihood_rolling
# Test loglikelihood_rolling
requests
=
[
"input1"
,
"input2"
]
requests
=
[
"input1"
,
"input2"
]
...
...
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