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
a946c6cd
"vscode:/vscode.git/clone" did not exist on "12cb760a3773fe1a97d5a00fca26412f814f20fa"
Commit
a946c6cd
authored
Jul 02, 2023
by
gk
Browse files
Fix trust_remote_code, bnb_4bit_*, max_batch_size for gpt2
parent
13014b2c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
8 deletions
+19
-8
.gitignore
.gitignore
+2
-0
lm_eval/base.py
lm_eval/base.py
+1
-1
lm_eval/evaluator.py
lm_eval/evaluator.py
+1
-0
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+7
-3
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+8
-4
No files found.
.gitignore
View file @
a946c6cd
...
@@ -3,3 +3,5 @@ env
...
@@ -3,3 +3,5 @@ env
data/
data/
lm_cache
lm_cache
.idea
.idea
*.egg-info/
lm_eval/base.py
View file @
a946c6cd
...
@@ -309,7 +309,7 @@ class BaseLM(LM):
...
@@ -309,7 +309,7 @@ class BaseLM(LM):
if
override_bs
is
not
None
if
override_bs
is
not
None
else
0
,
else
0
,
fn
=
_batch_scheduler
fn
=
_batch_scheduler
if
self
.
batch_size
==
"auto"
and
n_reordered_requests
>
0
if
self
.
batch_size
==
"auto"
and
n_reordered_requests
>
0
and
not
override_bs
else
None
,
else
None
,
):
):
inps
=
[]
inps
=
[]
...
...
lm_eval/evaluator.py
View file @
a946c6cd
...
@@ -80,6 +80,7 @@ def simple_evaluate(
...
@@ -80,6 +80,7 @@ def simple_evaluate(
lm
=
lm_eval
.
models
.
get_model
(
"hf-causal"
)(
lm
=
lm_eval
.
models
.
get_model
(
"hf-causal"
)(
pretrained
=
model
,
pretrained
=
model
,
batch_size
=
batch_size
,
batch_size
=
batch_size
,
max_batch_size
=
max_batch_size
,
)
)
no_cache
=
True
no_cache
=
True
else
:
else
:
...
...
lm_eval/models/gpt2.py
View file @
a946c6cd
...
@@ -29,6 +29,7 @@ class HFLM(BaseLM):
...
@@ -29,6 +29,7 @@ class HFLM(BaseLM):
subfolder
=
None
,
subfolder
=
None
,
tokenizer
=
None
,
tokenizer
=
None
,
batch_size
=
1
,
batch_size
=
1
,
max_batch_size
=
512
,
max_length
=
None
,
max_length
=
None
,
load_in_8bit
:
Optional
[
bool
]
=
False
,
load_in_8bit
:
Optional
[
bool
]
=
False
,
trust_remote_code
:
Optional
[
bool
]
=
False
,
trust_remote_code
:
Optional
[
bool
]
=
False
,
...
@@ -106,10 +107,13 @@ class HFLM(BaseLM):
...
@@ -106,10 +107,13 @@ class HFLM(BaseLM):
assert
isinstance
(
batch_size
,
(
int
,
str
))
assert
isinstance
(
batch_size
,
(
int
,
str
))
# setup for automatic batch size detection
# setup for automatic batch size detection
if
batch_size
==
"auto"
:
if
str
(
batch_size
).
startswith
(
"auto"
):
self
.
batch_size_per_gpu
=
batch_size
batch_size
=
batch_size
.
split
(
":"
)
self
.
batch_size_per_gpu
=
batch_size
[
0
]
self
.
batch_schedule
=
float
(
batch_size
[
1
])
if
len
(
batch_size
)
>
1
else
1
else
:
else
:
self
.
batch_size_per_gpu
=
int
(
batch_size
)
self
.
batch_size_per_gpu
=
int
(
batch_size
)
self
.
max_batch_size
=
max_batch_size
self
.
_max_length
=
max_length
self
.
_max_length
=
max_length
...
...
lm_eval/models/huggingface.py
View file @
a946c6cd
...
@@ -279,8 +279,10 @@ class HuggingFaceAutoLM(BaseLM):
...
@@ -279,8 +279,10 @@ class HuggingFaceAutoLM(BaseLM):
if
transformers
.
__version__
>=
"4.30.0"
:
if
transformers
.
__version__
>=
"4.30.0"
:
model_kwargs
[
"load_in_4bit"
]
=
load_in_4bit
model_kwargs
[
"load_in_4bit"
]
=
load_in_4bit
if
load_in_4bit
:
if
load_in_4bit
:
if
bnb_4bit_quant_type
:
model_kwargs
[
"bnb_4bit_quant_type"
]
=
bnb_4bit_quant_type
model_kwargs
[
"bnb_4bit_quant_type"
]
=
bnb_4bit_quant_type
model_kwargs
[
"bnb_4bit_compute_dtype"
]
=
getattr
(
torch
,
bnb_4bit_compute_dtype
)
if
bnb_4bit_compute_dtype
:
model_kwargs
[
"bnb_4bit_compute_dtype"
]
=
_get_dtype
(
bnb_4bit_compute_dtype
)
model
=
self
.
AUTO_MODEL_CLASS
.
from_pretrained
(
model
=
self
.
AUTO_MODEL_CLASS
.
from_pretrained
(
pretrained
,
pretrained
,
revision
=
revision
+
(
"/"
+
subfolder
if
subfolder
is
not
None
else
""
),
revision
=
revision
+
(
"/"
+
subfolder
if
subfolder
is
not
None
else
""
),
...
@@ -331,7 +333,7 @@ class HuggingFaceAutoLM(BaseLM):
...
@@ -331,7 +333,7 @@ class HuggingFaceAutoLM(BaseLM):
revision
:
str
,
revision
:
str
,
subfolder
:
str
,
subfolder
:
str
,
tokenizer
:
Optional
[
str
]
=
None
,
tokenizer
:
Optional
[
str
]
=
None
,
trust_remote_code
:
bool
=
False
,
trust_remote_code
:
Optional
[
bool
]
=
False
,
)
->
transformers
.
PreTrainedTokenizer
:
)
->
transformers
.
PreTrainedTokenizer
:
"""Returns a pre-trained tokenizer from a pre-trained tokenizer configuration."""
"""Returns a pre-trained tokenizer from a pre-trained tokenizer configuration."""
tokenizer
=
self
.
AUTO_TOKENIZER_CLASS
.
from_pretrained
(
tokenizer
=
self
.
AUTO_TOKENIZER_CLASS
.
from_pretrained
(
...
@@ -501,12 +503,14 @@ class AutoCausalLM(HuggingFaceAutoLM):
...
@@ -501,12 +503,14 @@ class AutoCausalLM(HuggingFaceAutoLM):
revision
:
str
,
revision
:
str
,
subfolder
:
str
,
subfolder
:
str
,
tokenizer
:
Optional
[
str
]
=
None
,
tokenizer
:
Optional
[
str
]
=
None
,
trust_remote_code
:
Optional
[
bool
]
=
False
,
)
->
transformers
.
PreTrainedTokenizer
:
)
->
transformers
.
PreTrainedTokenizer
:
tokenizer
=
super
().
_create_auto_tokenizer
(
tokenizer
=
super
().
_create_auto_tokenizer
(
pretrained
=
pretrained
,
pretrained
=
pretrained
,
revision
=
revision
,
revision
=
revision
,
subfolder
=
subfolder
,
subfolder
=
subfolder
,
tokenizer
=
tokenizer
,
tokenizer
=
tokenizer
,
trust_remote_code
=
trust_remote_code
,
)
)
tokenizer
.
padding_side
=
"left"
tokenizer
.
padding_side
=
"left"
return
tokenizer
return
tokenizer
...
...
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