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
OpenDAS
AutoAWQ
Commits
b9ab9a64
Commit
b9ab9a64
authored
Sep 15, 2023
by
Casper
Browse files
Add wikitext example
parent
d832a218
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
examples/quant_custom_data.py
examples/quant_custom_data.py
+6
-1
No files found.
examples/quant_custom_data.py
View file @
b9ab9a64
...
@@ -10,6 +10,7 @@ quant_config = { "zero_point": True, "q_group_size": 128, "w_bit": 4, "version":
...
@@ -10,6 +10,7 @@ quant_config = { "zero_point": True, "q_group_size": 128, "w_bit": 4, "version":
model
=
AutoAWQForCausalLM
.
from_pretrained
(
model_path
)
model
=
AutoAWQForCausalLM
.
from_pretrained
(
model_path
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_path
,
trust_remote_code
=
True
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_path
,
trust_remote_code
=
True
)
# Define data loading methods
def
load_dolly
():
def
load_dolly
():
data
=
load_dataset
(
'databricks/databricks-dolly-15k'
,
split
=
"train"
)
data
=
load_dataset
(
'databricks/databricks-dolly-15k'
,
split
=
"train"
)
...
@@ -20,8 +21,12 @@ def load_dolly():
...
@@ -20,8 +21,12 @@ def load_dolly():
concatenated
=
data
.
map
(
concatenate_data
)
concatenated
=
data
.
map
(
concatenate_data
)
return
[
text
for
text
in
concatenated
[
"text"
]]
return
[
text
for
text
in
concatenated
[
"text"
]]
def
load_wikitext
():
data
=
load_dataset
(
'wikitext'
,
'wikitext-2-raw-v1'
,
split
=
"train"
)
return
[
text
for
text
in
data
[
"text"
]
if
text
.
strip
()
!=
''
and
len
(
text
.
split
(
' '
))
>
20
]
# Quantize
# Quantize
model
.
quantize
(
tokenizer
,
quant_config
=
quant_config
,
calib_data
=
load_
dolly
())
model
.
quantize
(
tokenizer
,
quant_config
=
quant_config
,
calib_data
=
load_
wikitext
())
# Save quantized model
# Save quantized model
model
.
save_quantized
(
quant_path
)
model
.
save_quantized
(
quant_path
)
...
...
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