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
b011af90
Commit
b011af90
authored
Aug 29, 2023
by
Matt Hoffner
Browse files
push recommended diff from @gardner
parent
85d3b8d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
lm_eval/models/ggml.py
lm_eval/models/ggml.py
+4
-4
No files found.
lm_eval/models/ggml.py
View file @
b011af90
...
@@ -36,7 +36,7 @@ class GGMLLM(BaseLM):
...
@@ -36,7 +36,7 @@ class GGMLLM(BaseLM):
logger
.
error
(
f
"RequestException:
{
e
}
"
)
logger
.
error
(
f
"RequestException:
{
e
}
"
)
time
.
sleep
(
delay
)
# wait before retrying
time
.
sleep
(
delay
)
# wait before retrying
else
:
else
:
raise
Exception
(
f
"Failed to get a valid response after
{
retries
}
retries.
Last exception:
{
e
}
"
)
raise
Exception
(
f
"Failed to get a valid response after
{
retries
}
retries."
)
def
loglikelihood
(
self
,
requests
):
def
loglikelihood
(
self
,
requests
):
...
@@ -44,11 +44,11 @@ class GGMLLM(BaseLM):
...
@@ -44,11 +44,11 @@ class GGMLLM(BaseLM):
return
[]
return
[]
res
=
[]
res
=
[]
for
context
,
continuation
in
tqdm
(
requests
):
for
context
,
continuation
in
tqdm
(
requests
):
response
=
self
.
ggml_completion
(
self
.
base_url
,
context
=
context
,
continuation
=
continuation
)
response
=
self
.
ggml_completion
(
context
=
context
,
continuation
=
continuation
)
if
response
and
"choices"
in
response
and
response
[
"choices"
]:
if
response
and
"choices"
in
response
and
response
[
"choices"
]:
choice
=
response
[
"choices"
][
0
]
choice
=
response
[
"choices"
][
0
]
logprobs
=
choice
.
get
(
"logprobs"
)
logprobs
=
choice
.
get
(
"logprobs"
)
if
logprobs
and
"token_logprobs"
in
logprobs
:
if
logprobs
and
"token_logprobs"
in
logprobs
and
logprobs
[
"token_logprobs"
]
:
logprob
=
logprobs
[
"token_logprobs"
][
0
]
logprob
=
logprobs
[
"token_logprobs"
][
0
]
is_greedy
=
choice
[
"finish_reason"
]
==
"length"
is_greedy
=
choice
[
"finish_reason"
]
==
"length"
res
.
append
((
logprob
,
is_greedy
))
res
.
append
((
logprob
,
is_greedy
))
...
@@ -69,7 +69,7 @@ class GGMLLM(BaseLM):
...
@@ -69,7 +69,7 @@ class GGMLLM(BaseLM):
inp
=
request
[
0
]
inp
=
request
[
0
]
request_args
=
request
[
1
]
request_args
=
request
[
1
]
until
=
request_args
[
"until"
]
until
=
request_args
[
"until"
]
response
=
self
.
ggml_completion
(
self
.
base_url
,
context
=
inp
,
stop
=
until
)
response
=
self
.
ggml_completion
(
context
=
inp
,
stop
=
until
)
if
response
and
"choices"
in
response
and
response
[
"choices"
]:
if
response
and
"choices"
in
response
and
response
[
"choices"
]:
choice
=
response
[
"choices"
][
0
]
choice
=
response
[
"choices"
][
0
]
if
"text"
in
choice
:
if
"text"
in
choice
:
...
...
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