Sergei Skvortsov
commited on
Commit
·
ab05f76
1
Parent(s):
29045a7
New calibration
Browse files- calibrate.py +8 -25
- model.safetensors +1 -1
- tokenizer.json +0 -0
calibrate.py
CHANGED
|
@@ -42,34 +42,17 @@ tokenizer = AutoTokenizer.from_pretrained(model_stub)
|
|
| 42 |
|
| 43 |
output_dir = f"/{model_name}-FP8"
|
| 44 |
|
| 45 |
-
DATASET_ID = "
|
| 46 |
-
DATASET_SPLIT = "
|
| 47 |
NUM_CALIBRATION_SAMPLES = 512
|
| 48 |
-
MAX_SEQUENCE_LENGTH =
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
def preprocess(example):
|
| 54 |
-
return {
|
| 55 |
-
"text": tokenizer.apply_chat_template(
|
| 56 |
-
example["messages"],
|
| 57 |
-
tokenize=False,
|
| 58 |
-
)
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
ds = ds.map(preprocess)
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
padding=False,
|
| 67 |
-
max_length=MAX_SEQUENCE_LENGTH,
|
| 68 |
-
truncation=True,
|
| 69 |
-
add_special_tokens=False,
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
ds = ds.map(tokenize, remove_columns=ds.column_names)
|
| 73 |
|
| 74 |
oneshot(
|
| 75 |
model=model,
|
|
|
|
| 42 |
|
| 43 |
output_dir = f"/{model_name}-FP8"
|
| 44 |
|
| 45 |
+
DATASET_ID = "neuralmagic/LLM_compression_calibration"
|
| 46 |
+
DATASET_SPLIT = "train"
|
| 47 |
NUM_CALIBRATION_SAMPLES = 512
|
| 48 |
+
MAX_SEQUENCE_LENGTH = 8192
|
| 49 |
|
| 50 |
+
def preprocess_fn(example):
|
| 51 |
+
return {"text": tokenizer.apply_chat_template(example["messages"], add_generation_prompt=False, tokenize=False)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
ds = load_dataset(DATASET_ID, split=DATASET_SPLIT)
|
| 54 |
+
ds = ds.shuffle().select(range(NUM_CALIBRATION_SAMPLES))
|
| 55 |
+
ds = ds.map(preprocess_fn)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
oneshot(
|
| 58 |
model=model,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 903038064
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e164b5b6ae0c8a2e3fc8f8684513e31a79be4285d917cd1e3b9787272e8d8a83
|
| 3 |
size 903038064
|
tokenizer.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|