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
a2920e3d
Commit
a2920e3d
authored
Nov 21, 2023
by
baberabb
Browse files
add vllm model
parent
3d8bc82f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
lm_eval/models/vllm.py
lm_eval/models/vllm.py
+3
-3
No files found.
lm_eval/models/vllm.py
View file @
a2920e3d
...
@@ -74,7 +74,7 @@ class VLLM(LM):
...
@@ -74,7 +74,7 @@ class VLLM(LM):
def
_model_generate
(
def
_model_generate
(
self
,
self
,
requests
:
List
=
None
,
requests
:
List
[
int
]
=
None
,
generate
:
bool
=
False
,
generate
:
bool
=
False
,
max_tokens
:
int
=
None
,
max_tokens
:
int
=
None
,
stop
:
Optional
[
List
[
str
]]
=
None
,
stop
:
Optional
[
List
[
str
]]
=
None
,
...
@@ -153,7 +153,7 @@ class VLLM(LM):
...
@@ -153,7 +153,7 @@ class VLLM(LM):
# batch tokenize contexts
# batch tokenize contexts
context
,
all_gen_kwargs
=
zip
(
*
(
req
.
args
for
req
in
requests
))
context
,
all_gen_kwargs
=
zip
(
*
(
req
.
args
for
req
in
requests
))
context_encoding
=
self
.
tokenizer
(
context
)
context_encoding
=
self
.
tokenizer
(
context
)
requests
=
zip
((
context
,
context_encoding
.
input_ids
),
all_gen_kwargs
)
requests
=
list
(
zip
((
context
,
context_encoding
.
input_ids
),
all_gen_kwargs
)
)
def
_collate_gen
(
_requests
):
def
_collate_gen
(
_requests
):
# the negative sign on len(toks) sorts descending - this has a few advantages:
# the negative sign on len(toks) sorts descending - this has a few advantages:
...
@@ -269,7 +269,7 @@ class VLLM(LM):
...
@@ -269,7 +269,7 @@ class VLLM(LM):
inps
.
append
(
inp
)
inps
.
append
(
inp
)
ctxlens
.
append
(
ctxlen
)
ctxlens
.
append
(
ctxlen
)
outputs
=
self
.
_model_generate
(
generate
=
False
)
outputs
=
self
.
_model_generate
(
requests
=
inps
,
generate
=
False
)
for
output
,
ctxlen
,
(
cache_key
,
context_enc
,
continuation_enc
)
in
zip
(
for
output
,
ctxlen
,
(
cache_key
,
context_enc
,
continuation_enc
)
in
zip
(
outputs
,
ctxlens
,
chunk
outputs
,
ctxlens
,
chunk
...
...
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