Skip to content

Commit

Permalink
upgrade lm-eval to 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhuach21 committed Jun 4, 2024
1 parent 6a19227 commit 46cb4b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
36 changes: 20 additions & 16 deletions examples/language-modeling/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def get_library_version(library_name):
return "Library not found"


res = get_library_version("lm-eval")
if res == "0.3.0":
lm_eval_version = get_library_version("lm-eval")
if lm_eval_version == "0.3.0":
use_eval_legacy = True

if isinstance(tasks, str):
Expand Down Expand Up @@ -340,17 +340,21 @@ def get_library_version(library_name):
model.save_pretrained(output_dir)
tokenizer.save_pretrained(output_dir)

# if not args.disable_eval and "fake" in deployment_device: ##support autogptq real eval later
# excel_name = f"{output_dir}_result.xlsx"
# output_dir += "/"
# print(excel_name, flush=True)
# eval_model(model_path=output_dir, tasks=tasks, dtype=dtype, limit=None,
# eval_bs=args.eval_bs, use_accelerate=not args.disable_low_gpu_mem_usage,
# device=torch_device, excel_file=excel_name)
from auto_round.auto_quantizer import AutoHfQuantizer
from eval_042.evaluation import simple_evaluate

model_args = f"pretrained={export_dir}-gpu"
simple_evaluate(model="hf", model_args=model_args,
tasks="lambada_openai",
batch_size=args.eval_bs)
if not args.disable_eval and "fake" in deployment_device and lm_eval_version == "0.4.2": ##support autogptq real eval later
excel_name = f"{output_dir}_result.xlsx"
output_dir += "/"
print(excel_name, flush=True)
eval_model(model_path=output_dir, tasks=tasks, dtype=dtype, limit=None,
eval_bs=args.eval_bs, use_accelerate=not args.disable_low_gpu_mem_usage,
device=torch_device, excel_file=excel_name)

if not args.disable_eval and lm_eval_version == "0.4.2":
from eval_042.evaluation import simple_evaluate

if 'gpu' in deployment_device or "auto_round" in gpu_format or "auto-round" in gpu_format:
model_args = f"pretrained={export_dir}-gpu"
else:
model_args = f"pretrained={output_dir}"
simple_evaluate(model="hf", model_args=model_args,
tasks=tasks,
batch_size=args.eval_bs)
1 change: 1 addition & 0 deletions examples/language-modeling/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
transformers
torch
lm-eval==0.4.2
git+https://github.com/EleutherAI/lm-evaluation-harness.git@96d185fa6232a5ab685ba7c43e45d1dbb3bb906d
# For the paper results use the old lm_eval (0.3.0)
# git+https://github.com/EleutherAI/lm-evaluation-harness.git@008fc2a23245c40384f2312718433eeb1e0f87a9
Expand Down

0 comments on commit 46cb4b7

Please sign in to comment.