Spaces:
Sleeping
Sleeping
Commit ·
d5a16ff
1
Parent(s): fcdea4e
update
Browse files
examples/tutorials/lora_unsloth/step_4_evaluation.py
CHANGED
|
@@ -17,6 +17,7 @@ else:
|
|
| 17 |
from datasets import load_dataset
|
| 18 |
from unsloth import FastLanguageModel
|
| 19 |
from transformers import TextStreamer
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
def get_args():
|
|
@@ -110,7 +111,7 @@ def main():
|
|
| 110 |
valid_dataset = dataset["test"]
|
| 111 |
|
| 112 |
with open(output_file.as_posix(), "w", encoding="utf-8") as f:
|
| 113 |
-
for example in valid_dataset:
|
| 114 |
conversation = example["conversation"]
|
| 115 |
prompt = conversation[:-1]
|
| 116 |
response = conversation[-1]["content"]
|
|
@@ -133,7 +134,7 @@ def main():
|
|
| 133 |
)
|
| 134 |
|
| 135 |
response_: str = tokenizer.decode(generated_ids[0][len(inputs["input_ids"][0]):], skip_special_tokens=True)
|
| 136 |
-
response_ = response_.split("</
|
| 137 |
|
| 138 |
row = {
|
| 139 |
"prompt": prompt,
|
|
|
|
| 17 |
from datasets import load_dataset
|
| 18 |
from unsloth import FastLanguageModel
|
| 19 |
from transformers import TextStreamer
|
| 20 |
+
from tqdm import tqdm
|
| 21 |
|
| 22 |
|
| 23 |
def get_args():
|
|
|
|
| 111 |
valid_dataset = dataset["test"]
|
| 112 |
|
| 113 |
with open(output_file.as_posix(), "w", encoding="utf-8") as f:
|
| 114 |
+
for example in tqdm(valid_dataset):
|
| 115 |
conversation = example["conversation"]
|
| 116 |
prompt = conversation[:-1]
|
| 117 |
response = conversation[-1]["content"]
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
response_: str = tokenizer.decode(generated_ids[0][len(inputs["input_ids"][0]):], skip_special_tokens=True)
|
| 137 |
+
response_ = response_.split("</think>")[-1].strip()
|
| 138 |
|
| 139 |
row = {
|
| 140 |
"prompt": prompt,
|