Skip to content

support to use lm_eval for vlm #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions auto_round/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ def run_fast():

def run_mllm():
if "--eval" in sys.argv:
from auto_round.script.mllm import setup_lmeval_parser, eval
from auto_round.script.llm import setup_eval_parser, eval
sys.argv.remove("--eval")
args = setup_lmeval_parser()
args = setup_eval_parser()
args.mllm = True
eval(args)
elif "--vlmeval" in sys.argv:
sys.argv.remove("--vlmeval")
run_vlmeavl()
elif "--lmms" in sys.argv:
sys.argv.remove("--lmms")
run_lmms()
Expand All @@ -76,6 +80,12 @@ def run_lmms():
args = setup_lmms_parser()
lmms_eval(args)

def run_vlmeavl():
from auto_round.script.mllm import setup_lmeval_parser, vlmeval
args = setup_lmeval_parser()
vlmeval(args)


def switch():
if "--mllm" in sys.argv:
sys.argv.remove("--mllm")
Expand Down
12 changes: 11 additions & 1 deletion auto_round/script/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.add_argument(
"--model", "--model_name", "--model_name_or_path", default="facebook/opt-125m", help="model name or path")
self.add_argument(
"--mllm", default=False, help="whether to eval multi-model."
)
self.add_argument(
"--device",
"--devices",
Expand Down Expand Up @@ -672,8 +675,15 @@ def eval(args):
print("evaluation running time=%ds" % (time.time() - st))
else:
st = time.time()
if "auto" in batch_size and args.mllm:
logger.warning("Batch size 'auto' is not yet supported for hf-multimodal models, reset to 16")
batch_size = 16
res = simple_evaluate(
model="hf", model_args=model_args, tasks=tasks, device=device_str, batch_size=batch_size)
model="hf" if not args.mllm else "hf-multimodal",
model_args=model_args,
tasks=tasks,
device=device_str,
batch_size=batch_size)
from lm_eval.utils import make_table # pylint: disable=E0401
print(make_table(res))
print("evaluation running time=%ds" % (time.time() - st))
Expand Down
2 changes: 1 addition & 1 deletion auto_round/script/mllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def tune(args):
clear_memory()


def eval(args):
def vlmeval(args):
set_cuda_visible_devices(args.device)
device_str, parallelism = get_device_and_parallelism(args.device)
if parallelism:
Expand Down
Loading