Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lm-evaluation-harness/tests/testdata/wmt20-en-zh-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-en-zh-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-fr-de-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-iu-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-iu-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ja-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ja-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-km-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-km-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-pl-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-pl-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ps-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ps-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ru-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ru-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ta-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-ta-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-zh-en-v0-greedy_until +1 -0
- lm-evaluation-harness/tests/testdata/wmt20-zh-en-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wnli-v0-loglikelihood +1 -0
- lm-evaluation-harness/tests/testdata/wnli-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wnli-v1-loglikelihood +1 -0
- lm-evaluation-harness/tests/testdata/wnli-v1-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wsc-v0-loglikelihood +1 -0
- lm-evaluation-harness/tests/testdata/wsc-v0-res.json +1 -0
- lm-evaluation-harness/tests/testdata/wsc273-v0-loglikelihood +1 -0
- lm-evaluation-harness/tests/testdata/wsc273-v0-res.json +1 -0
- lmms-eval/examples/models/instructblip.sh +19 -0
- lmms-eval/examples/models/internvl1.5.sh +24 -0
- lmms-eval/examples/models/llava_onevision.sh +10 -0
- lmms-eval/examples/models/llava_video.sh +13 -0
- lmms-eval/examples/models/mplug_owl.sh +18 -0
- lmms-eval/examples/models/openai_compatible.sh +11 -0
- lmms-eval/examples/models/plm.sh +44 -0
- lmms-eval/examples/models/qwen25vl.sh +18 -0
- lmms-eval/examples/models/qwen2vl.sh +8 -0
- lmms-eval/examples/models/sglang.sh +12 -0
- lmms-eval/examples/models/slime.sh +23 -0
- lmms-eval/examples/models/tensor_parallel.sh +12 -0
- lmms-eval/examples/models/tinyllava.sh +25 -0
- lmms-eval/examples/models/video_chatgpt.sh +17 -0
- lmms-eval/examples/models/video_llava.sh +19 -0
- lmms-eval/examples/models/vllm_qwen2vl.sh +19 -0
- lmms-eval/examples/models/xai_grok.sh +10 -0
- lmms-eval/examples/models/xcomposer.sh +32 -0
- lmms-eval/lmms_eval/__init__.py +0 -0
- lmms-eval/lmms_eval/__main__.py +539 -0
- lmms-eval/lmms_eval/api/__init__.py +0 -0
- lmms-eval/lmms_eval/api/filter.py +54 -0
- lmms-eval/lmms_eval/api/group.py +104 -0
lm-evaluation-harness/tests/testdata/wmt20-en-zh-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
67f0333ddbcb07d7a9ac12919129a18fe4fea24e4826a11bbdde4fd5ed5ed83f
|
lm-evaluation-harness/tests/testdata/wmt20-en-zh-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-en-zh": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.00014170297316825535, "chrf_stderr": 6.590669847391838e-05, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-en-zh": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-fr-de-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-fr-de": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.01143193767396364, "chrf_stderr": 0.00012555271954563658, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-fr-de": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-iu-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
97bf664a8efa54b5366b8341f77b418106dd0cb26169d5b2d0144e4d3d2bc5c9
|
lm-evaluation-harness/tests/testdata/wmt20-iu-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-iu-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.012204628007572778, "chrf_stderr": 8.944407532175802e-05, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-iu-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-ja-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
1fd846f3c0104e794eb380dae7f648592092ab8bf59234c26d0a671bbbc28df1
|
lm-evaluation-harness/tests/testdata/wmt20-ja-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-ja-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.010703148854351403, "chrf_stderr": 0.00022242113108130186, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-ja-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-km-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fb4ec81bb89c70df7e21b43e0e882915b7b71a2a85bb8d4b59e0c7938baaa4c2
|
lm-evaluation-harness/tests/testdata/wmt20-km-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-km-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.015142474534585969, "chrf_stderr": 0.0001518735048829897, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-km-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-pl-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
89274499d84176b1ffe4eaec06f2c89ca807342384dc946c2e348d00116aaade
|
lm-evaluation-harness/tests/testdata/wmt20-pl-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-pl-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.01353367757716276, "chrf_stderr": 0.00018386199249976465, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-pl-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-ps-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
c3976465e3709b4bc371175cc1494c69fe096ea4ba7d114da779d2baa0a47466
|
lm-evaluation-harness/tests/testdata/wmt20-ps-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-ps-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.015192865365105723, "chrf_stderr": 0.00011334541381539086, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-ps-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-ru-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
1477ab6542c26bd0222cc1aded174f33bf8d04d1cf6a1c0959aeca4ff3779adc
|
lm-evaluation-harness/tests/testdata/wmt20-ru-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-ru-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.013344639906399232, "chrf_stderr": 7.583552652374546e-05, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-ru-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-ta-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
111ea3efdc08f1cf536631b9426c3a20e482c575d009d2a8c71f59c027578eec
|
lm-evaluation-harness/tests/testdata/wmt20-ta-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-ta-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.013841110664859798, "chrf_stderr": 0.00018476696850880766, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-ta-en": 0}}
|
lm-evaluation-harness/tests/testdata/wmt20-zh-en-v0-greedy_until
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
07dbadfd6f2b2b9462ab6187dbfaabae6e5192ab89a8e4ede9237834b9364dd1
|
lm-evaluation-harness/tests/testdata/wmt20-zh-en-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wmt20-zh-en": {"bleu": 0.0, "bleu_stderr": 0.0, "chrf": 0.008438201290981157, "chrf_stderr": 0.0001109053964076822, "ter": 1.0, "ter_stderr": 0.0}}, "versions": {"wmt20-zh-en": 0}}
|
lm-evaluation-harness/tests/testdata/wnli-v0-loglikelihood
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
2ffd304d6096416eb29607e2e7642b1d6043163624967bcf4c4fc00fddc6c721
|
lm-evaluation-harness/tests/testdata/wnli-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wnli": {"acc": 0.3380281690140845, "acc_stderr": 0.05653887739133514}}, "versions": {"wnli": 0}}
|
lm-evaluation-harness/tests/testdata/wnli-v1-loglikelihood
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
8a0f81661d2ab2334bbc8031fac31c0c8882f1d9271dd51599d21dfdbb726dea
|
lm-evaluation-harness/tests/testdata/wnli-v1-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wnli": {"acc": 0.5633802816901409, "acc_stderr": 0.0592793555841297}}, "versions": {"wnli": 1}}
|
lm-evaluation-harness/tests/testdata/wsc-v0-loglikelihood
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
45865468eff5ca31e6a050947a6b3310d9d5ed19d0f2e578a32ecaf1c768600f
|
lm-evaluation-harness/tests/testdata/wsc-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wsc": {"acc": 0.5480769230769231, "acc_stderr": 0.049038186969314335}}, "versions": {"wsc": 0}}
|
lm-evaluation-harness/tests/testdata/wsc273-v0-loglikelihood
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
26450d414c4581feb51a09882080e7a9b95882e7eab47b1751a4a6024b5a60ee
|
lm-evaluation-harness/tests/testdata/wsc273-v0-res.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results": {"wsc273": {"acc": 0.5164835164835165, "acc_stderr": 0.0303004740355766}}, "versions": {"wsc273": 0}}
|
lmms-eval/examples/models/instructblip.sh
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cd /path/to/lmms-eval
|
| 2 |
+
python3 -m pip install -e .;
|
| 3 |
+
|
| 4 |
+
python3 -m pip install transformers --upgrade;
|
| 5 |
+
|
| 6 |
+
CKPT_PATH=$1
|
| 7 |
+
TASK=$2
|
| 8 |
+
echo $TASK
|
| 9 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 10 |
+
echo $TASK_SUFFIX
|
| 11 |
+
|
| 12 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 13 |
+
--model instructblip \
|
| 14 |
+
--model_args pretrained=$CKPT_PATH \
|
| 15 |
+
--tasks $TASK \
|
| 16 |
+
--batch_size 1 \
|
| 17 |
+
--log_samples \
|
| 18 |
+
--log_samples_suffix instructblip \
|
| 19 |
+
--output_path ./logs/
|
lmms-eval/examples/models/internvl1.5.sh
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# First you need to fork [`InternVL`](https://github.com/OpenGVLab/InternVL)
|
| 2 |
+
|
| 3 |
+
cd /path/to/lmms-eval
|
| 4 |
+
python3 -m pip install -e .;
|
| 5 |
+
|
| 6 |
+
cd /path/to/InternVL/internvl_chat
|
| 7 |
+
python3 -m pip install -e .;
|
| 8 |
+
|
| 9 |
+
python3 -m pip install flash-attn==2.3.6 --no-build-isolation;
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
TASK=$1
|
| 13 |
+
echo $TASK
|
| 14 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 15 |
+
echo $TASK_SUFFIX
|
| 16 |
+
|
| 17 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 18 |
+
--model internvl \
|
| 19 |
+
--model_args pretrained="OpenGVLab/InternVL-Chat-V1-5"\
|
| 20 |
+
--tasks $TASK \
|
| 21 |
+
--batch_size 1 \
|
| 22 |
+
--log_samples \
|
| 23 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 24 |
+
--output_path ./logs/
|
lmms-eval/examples/models/llava_onevision.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export HF_HOME="~/.cache/huggingface"
|
| 2 |
+
|
| 3 |
+
# pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
|
| 4 |
+
# pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
| 5 |
+
|
| 6 |
+
accelerate launch --num_processes=8 --main_process_port 12399 -m lmms_eval \
|
| 7 |
+
--model=llava_onevision \
|
| 8 |
+
--model_args=pretrained=lmms-lab/llava-onevision-qwen2-7b-ov,conv_template=qwen_1_5,device_map=auto,model_name=llava_qwen \
|
| 9 |
+
--tasks=ai2d,chartqa,docvqa_val,mmmu_pro \
|
| 10 |
+
--batch_size=1
|
lmms-eval/examples/models/llava_video.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export HF_HOME="~/.cache/huggingface"
|
| 2 |
+
|
| 3 |
+
# pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
|
| 4 |
+
# pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
| 5 |
+
|
| 6 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 7 |
+
--model llava_vid \
|
| 8 |
+
--model_args pretrained=lmms-lab/LLaVA-NeXT-Video-32B-Qwen,conv_template=qwen_1_5,video_decode_backend=decord,max_frames_num=32,mm_spatial_pool_mode=average,mm_newline_position=grid,mm_resampler_location=after \
|
| 9 |
+
--tasks videomme \
|
| 10 |
+
--batch_size 1 \
|
| 11 |
+
--log_samples \
|
| 12 |
+
--log_samples_suffix llava_vid_32B \
|
| 13 |
+
--output_path ./logs/
|
lmms-eval/examples/models/mplug_owl.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cd /path/to/lmms-eval
|
| 2 |
+
python3 -m pip install -e .;
|
| 3 |
+
|
| 4 |
+
# It has to use an old transformers version to run
|
| 5 |
+
python3 -m pip install av sentencepiece protobuf==3.20 transformers==4.28.1 einops;
|
| 6 |
+
|
| 7 |
+
TASK=$1
|
| 8 |
+
echo $TASK
|
| 9 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 10 |
+
echo $TASK_SUFFIX
|
| 11 |
+
|
| 12 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 13 |
+
--model mplug_owl_video \
|
| 14 |
+
--tasks $TASK \
|
| 15 |
+
--batch_size 1 \
|
| 16 |
+
--log_samples \
|
| 17 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 18 |
+
--output_path ./logs/
|
lmms-eval/examples/models/openai_compatible.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export HF_HOME="~/.cache/huggingface"
|
| 2 |
+
export AZURE_OPENAI_API_KEY=""
|
| 3 |
+
export AZURE_OPENAI_API_BASE=""
|
| 4 |
+
export AZURE_OPENAI_API_VERSION="2023-07-01-preview"
|
| 5 |
+
|
| 6 |
+
# pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
| 7 |
+
python3 -m lmms_eval \
|
| 8 |
+
--model openai_compatible \
|
| 9 |
+
--model_args model_version=gpt-4o-2024-11-20,azure_openai=True \
|
| 10 |
+
--tasks mme,mmmu_val \
|
| 11 |
+
--batch_size 1
|
lmms-eval/examples/models/plm.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# # STEP # 1: Install lmms-eval
|
| 2 |
+
# pip install lmms-eval
|
| 3 |
+
|
| 4 |
+
# # STEP # 2: Install perception_models (Details at https://github.com/facebookresearch/perception_models)
|
| 5 |
+
# git clone https://github.com/facebookresearch/perception_models.git
|
| 6 |
+
# cd perception_models
|
| 7 |
+
|
| 8 |
+
# conda create --name perception_models python=3.12
|
| 9 |
+
# conda activate perception_models
|
| 10 |
+
|
| 11 |
+
# # Install PyTorch
|
| 12 |
+
# pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 xformers --index-url https://download.pytorch.org/whl/cu124
|
| 13 |
+
|
| 14 |
+
# # We use torchcodec for decoding videos into PyTorch tensors
|
| 15 |
+
# conda install ffmpeg -c conda-forge
|
| 16 |
+
# pip install torchcodec==0.1 --index-url=https://download.pytorch.org/whl/cu124
|
| 17 |
+
|
| 18 |
+
# pip install -e .
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# Use facebook/Perception-LM-1B for 1B parameters model and facebook/Perception-LM-8B for 8B parameters model.
|
| 22 |
+
CHECKPOINTS_PATH=facebook/Perception-LM-3B
|
| 23 |
+
|
| 24 |
+
# Define the tasks you want to evaluate PLM on. We support all the tasks present in lmms-eval, however have tested the following tasks with our models.
|
| 25 |
+
ALL_TASKS=(
|
| 26 |
+
"docvqa" "chartqa" "textvqa" "infovqa" "ai2d_no_mask" "ok_vqa" "vizwiz_vqa" "mme"
|
| 27 |
+
"realworldqa" "pope" "mmmu" "ocrbench" "coco_karpathy_val" "nocaps" "vqav2_val"
|
| 28 |
+
"mvbench" "videomme" "vatex_test" "egoschema" "egoschema_subset" "mlvu_dev"
|
| 29 |
+
"tempcompass_multi_choice" "perceptiontest_val_mc" "perceptiontest_test_mc"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# We select one image and one video task as an example.
|
| 33 |
+
SELECTED_TASK="textvqa,videomme"
|
| 34 |
+
|
| 35 |
+
# After specifying the task/tasks to evaluate, run the following command to start the evaluation.
|
| 36 |
+
accelerate launch --num_processes=8 \
|
| 37 |
+
-m lmms_eval \
|
| 38 |
+
--model plm \
|
| 39 |
+
--model_args pretrained=$CHECKPOINTS_PATH,max_tokens=11264 \
|
| 40 |
+
--tasks $SELECTED_TASK \
|
| 41 |
+
--batch_size 1 \
|
| 42 |
+
--log_samples \
|
| 43 |
+
--log_samples_suffix plm \
|
| 44 |
+
--output_path plm_reproduce
|
lmms-eval/examples/models/qwen25vl.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Run and exactly reproduce qwen2vl results!
|
| 2 |
+
# mme as an example
|
| 3 |
+
export HF_HOME="~/.cache/huggingface"
|
| 4 |
+
# pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
| 5 |
+
# pip3 install qwen_vl_utils
|
| 6 |
+
# use `interleave_visuals=True` to control the visual token position, currently only for mmmu_val and mmmu_pro (and potentially for other interleaved image-text tasks), please do not use it unless you are sure about the operation details.
|
| 7 |
+
|
| 8 |
+
# accelerate launch --num_processes=8 --main_process_port=12346 -m lmms_eval \
|
| 9 |
+
# --model qwen2_vl \
|
| 10 |
+
# --model_args=pretrained=Qwen/Qwen2-VL-7B-Instruct,max_pixels=12845056,attn_implementation=flash_attention_2,interleave_visuals=True \
|
| 11 |
+
# --tasks mmmu_pro \
|
| 12 |
+
# --batch_size 1
|
| 13 |
+
|
| 14 |
+
accelerate launch --num_processes=8 --main_process_port=12346 -m lmms_eval \
|
| 15 |
+
--model qwen2_5_vl \
|
| 16 |
+
--model_args=pretrained=Qwen/Qwen2.5-VL-7B-Instruct,max_pixels=12845056,attn_implementation=flash_attention_2,interleave_visuals=False \
|
| 17 |
+
--tasks mme \
|
| 18 |
+
--batch_size 1
|
lmms-eval/examples/models/qwen2vl.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Run and exactly reproduce qwen2vl results!
|
| 2 |
+
# mme as an example
|
| 3 |
+
pip3 install qwen_vl_utils
|
| 4 |
+
accelerate launch --num_processes=8 --main_process_port=12345 -m lmms_eval \
|
| 5 |
+
--model qwen2_vl \
|
| 6 |
+
--model_args=pretrained=Qwen/Qwen2-VL-7B-Instruct,max_pixels=2359296 \
|
| 7 |
+
--tasks mme,gsm8k_cot_self_consistency,mmmu_val_reasoning,mmmu_val_pass64 \
|
| 8 |
+
--batch_size 1 --log_samples --log_samples_suffix reproduce --output_path ./logs/
|
lmms-eval/examples/models/sglang.sh
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export HF_HOME="~/.cache/huggingface"
|
| 2 |
+
# pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
| 3 |
+
|
| 4 |
+
python3 -m lmms_eval \
|
| 5 |
+
--model=llava_sglang \
|
| 6 |
+
--model_args=pretrained=lmms-lab/llava-next-72b,tokenizer=lmms-lab/llavanext-qwen-tokenizer,conv_template=chatml-llava,tp_size=8,parallel=8 \
|
| 7 |
+
--tasks=mme \
|
| 8 |
+
--batch_size=1 \
|
| 9 |
+
--log_samples \
|
| 10 |
+
--log_samples_suffix=llava_qwen \
|
| 11 |
+
--output_path=./logs/ \
|
| 12 |
+
--verbosity=INFO
|
lmms-eval/examples/models/slime.sh
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cd /path/to/lmms-eval
|
| 2 |
+
python3 -m pip install -e .;
|
| 3 |
+
|
| 4 |
+
git clone https://github.com/yfzhang114/SliME.git
|
| 5 |
+
|
| 6 |
+
cd SliME
|
| 7 |
+
pip install --upgrade pip # enable PEP 660 support
|
| 8 |
+
pip install -e .
|
| 9 |
+
cd ..
|
| 10 |
+
|
| 11 |
+
TASK=$1
|
| 12 |
+
echo $TASK
|
| 13 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 14 |
+
echo $TASK_SUFFIX
|
| 15 |
+
|
| 16 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 17 |
+
--model slime \
|
| 18 |
+
--tasks $TASK \
|
| 19 |
+
--model_args pretrained="yifanzhang114/SliME-Llama3-8B,conv_template=llama3,model_name=slime" \
|
| 20 |
+
--batch_size 1 \
|
| 21 |
+
--log_samples \
|
| 22 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 23 |
+
--output_path ./logs/
|
lmms-eval/examples/models/tensor_parallel.sh
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export HF_HOME="~/.cache/huggingface"
|
| 2 |
+
# pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
| 3 |
+
|
| 4 |
+
python3 -m lmms_eval \
|
| 5 |
+
--model=llava \
|
| 6 |
+
--model_args=pretrained=lmms-lab/llava-next-72b,conv_template=qwen_1_5,device_map=auto,model_name=llava_qwen \
|
| 7 |
+
--tasks=pope,vizwiz_vqa_val,scienceqa_img \
|
| 8 |
+
--batch_size=1 \
|
| 9 |
+
--log_samples \
|
| 10 |
+
--log_samples_suffix=llava_qwen \
|
| 11 |
+
--output_path="./logs/" \
|
| 12 |
+
--wandb_args=project=lmms-eval,job_type=eval,entity=llava-vl
|
lmms-eval/examples/models/tinyllava.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# install lmms_eval without building dependencies
|
| 2 |
+
cd lmms_eval;
|
| 3 |
+
pip install --no-deps -U -e .
|
| 4 |
+
|
| 5 |
+
# install TinyLLaVA without building dependencies
|
| 6 |
+
cd ..
|
| 7 |
+
git clone https://github.com/TinyLLaVA/TinyLLaVA_Factory
|
| 8 |
+
cd TinyLLaVA_Factory
|
| 9 |
+
pip install --no-deps -U -e .
|
| 10 |
+
|
| 11 |
+
# install all the requirements that require for reproduce llava results
|
| 12 |
+
pip install torch==2.0.1 torchvision==0.15.2 --index-url https://download.pytorch.org/whl/cu118
|
| 13 |
+
pip install -r tinyllava_repr_requirements.txt
|
| 14 |
+
|
| 15 |
+
# Run and reproduce tinyllava best results!
|
| 16 |
+
accelerate launch \
|
| 17 |
+
--num_processes=1 \
|
| 18 |
+
-m lmms_eval \
|
| 19 |
+
--model tinyllava \
|
| 20 |
+
--model_args pretrained=tinyllava/TinyLLaVA-Phi-2-SigLIP-3.1B,conv_mode=phi \
|
| 21 |
+
--tasks vqav2,gqa,scienceqa_img,textvqa,mmvet,pope,mme,mmmu_val \
|
| 22 |
+
--batch_size 1 \
|
| 23 |
+
--log_samples \
|
| 24 |
+
--log_samples_suffix tinyllava-phi2-siglip-3.1b \
|
| 25 |
+
--output_path ./logs/
|
lmms-eval/examples/models/video_chatgpt.sh
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cd /path/to/lmms-eval
|
| 2 |
+
python3 -m pip install -e .;
|
| 3 |
+
|
| 4 |
+
python3 -m pip install sentencepiece av;
|
| 5 |
+
|
| 6 |
+
TASK=$1
|
| 7 |
+
echo $TASK
|
| 8 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 9 |
+
echo $TASK_SUFFIX
|
| 10 |
+
|
| 11 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 12 |
+
--model video_chatgpt \
|
| 13 |
+
--tasks $TASK \
|
| 14 |
+
--batch_size 1 \
|
| 15 |
+
--log_samples \
|
| 16 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 17 |
+
--output_path ./logs/
|
lmms-eval/examples/models/video_llava.sh
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cd /path/to/lmms-eval
|
| 2 |
+
python3 -m pip install -e .;
|
| 3 |
+
|
| 4 |
+
python3 -m pip install transformers --upgrade;
|
| 5 |
+
python3 -m pip install av sentencepiece;
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
TASK=$1
|
| 9 |
+
echo $TASK
|
| 10 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 11 |
+
echo $TASK_SUFFIX
|
| 12 |
+
|
| 13 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 14 |
+
--model video_llava \
|
| 15 |
+
--tasks $TASK \
|
| 16 |
+
--batch_size 1 \
|
| 17 |
+
--log_samples \
|
| 18 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 19 |
+
--output_path ./logs/
|
lmms-eval/examples/models/vllm_qwen2vl.sh
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# pip3 install vllm
|
| 3 |
+
# pip3 install qwen_vl_utils
|
| 4 |
+
|
| 5 |
+
# cd ~/prod/lmms-eval-public
|
| 6 |
+
# pip3 install -e .
|
| 7 |
+
export NCCL_BLOCKING_WAIT=1
|
| 8 |
+
export NCCL_TIMEOUT=18000000
|
| 9 |
+
export NCCL_DEBUG=DEBUG
|
| 10 |
+
|
| 11 |
+
python3 -m lmms_eval \
|
| 12 |
+
--model vllm \
|
| 13 |
+
--model_args model=Qwen/Qwen2-VL-7B-Instruct,tensor_parallel_size=4 \
|
| 14 |
+
--tasks mme,gsm8k_cot_self_consistency,mmmu_val \
|
| 15 |
+
--batch_size 64 \
|
| 16 |
+
--log_samples \
|
| 17 |
+
--log_samples_suffix vllm \
|
| 18 |
+
--output_path ./logs \
|
| 19 |
+
--limit=64
|
lmms-eval/examples/models/xai_grok.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export HF_HOME="~/.cache/huggingface"
|
| 2 |
+
export OPENAI_API_KEY="xai-xxxxxxxxxx"
|
| 3 |
+
export OPENAI_API_BASE="https://api.x.ai/v1"
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
python3 -m lmms_eval \
|
| 7 |
+
--model openai_compatible \
|
| 8 |
+
--model_args model_version=grok-2-vision-1212 \
|
| 9 |
+
--tasks ai2d,chartqa,docvqa_val,mathvista_testmini,mmmu_pro \
|
| 10 |
+
--batch_size 1
|
lmms-eval/examples/models/xcomposer.sh
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cd /path/to/lmms-eval
|
| 2 |
+
python3 -m pip install -e .;
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
python3 -m pip install flash-attn --no-build-isolation;
|
| 6 |
+
python3 -m pip install torchvision einops timm sentencepiece;
|
| 7 |
+
|
| 8 |
+
TASK=$1
|
| 9 |
+
MODALITY=$2
|
| 10 |
+
echo $TASK
|
| 11 |
+
TASK_SUFFIX="${TASK//,/_}"
|
| 12 |
+
echo $TASK_SUFFIX
|
| 13 |
+
|
| 14 |
+
# For Xcomposer2d5
|
| 15 |
+
accelerate launch --num_processes 8 --main_process_port 10000 -m lmms_eval \
|
| 16 |
+
--model xcomposer2d5 \
|
| 17 |
+
--model_args pretrained="internlm/internlm-xcomposer2d5-7b",device="cuda",modality=$MODALITY\
|
| 18 |
+
--tasks $TASK \
|
| 19 |
+
--batch_size 1 \
|
| 20 |
+
--log_samples \
|
| 21 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 22 |
+
--output_path ./logs/
|
| 23 |
+
|
| 24 |
+
# For Xcomposer-4kHD
|
| 25 |
+
accelerate launch --num_processes 8 --main_process_port 12345 -m lmms_eval \
|
| 26 |
+
--model xcomposer2_4khd \
|
| 27 |
+
--model_args pretrained="internlm/internlm-xcomposer2-4khd-7b" \
|
| 28 |
+
--tasks $TASK \
|
| 29 |
+
--batch_size 1 \
|
| 30 |
+
--log_samples \
|
| 31 |
+
--log_samples_suffix $TASK_SUFFIX \
|
| 32 |
+
--output_path ./logs/
|
lmms-eval/lmms_eval/__init__.py
ADDED
|
File without changes
|
lmms-eval/lmms_eval/__main__.py
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import datetime
|
| 3 |
+
import importlib
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import traceback
|
| 8 |
+
import warnings
|
| 9 |
+
from functools import partial
|
| 10 |
+
|
| 11 |
+
import numpy as np
|
| 12 |
+
import torch
|
| 13 |
+
import yaml
|
| 14 |
+
|
| 15 |
+
warnings.simplefilter("ignore", category=DeprecationWarning)
|
| 16 |
+
|
| 17 |
+
import hashlib
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
from typing import Union
|
| 20 |
+
|
| 21 |
+
from accelerate import Accelerator
|
| 22 |
+
from accelerate.utils import InitProcessGroupKwargs
|
| 23 |
+
from loguru import logger as eval_logger
|
| 24 |
+
|
| 25 |
+
from lmms_eval import evaluator, utils
|
| 26 |
+
from lmms_eval.api.registry import ALL_TASKS
|
| 27 |
+
from lmms_eval.evaluator import request_caching_arg_to_dict
|
| 28 |
+
from lmms_eval.loggers import EvaluationTracker, WandbLogger
|
| 29 |
+
from lmms_eval.tasks import TaskManager
|
| 30 |
+
from lmms_eval.utils import (
|
| 31 |
+
handle_non_serializable,
|
| 32 |
+
make_table,
|
| 33 |
+
simple_parse_args_string,
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def _int_or_none_list_arg_type(min_len: int, max_len: int, defaults: str, value: str, split_char: str = ","):
|
| 38 |
+
def parse_value(item):
|
| 39 |
+
item = item.strip().lower()
|
| 40 |
+
if item == "none":
|
| 41 |
+
return None
|
| 42 |
+
try:
|
| 43 |
+
return int(item)
|
| 44 |
+
except ValueError:
|
| 45 |
+
raise argparse.ArgumentTypeError(f"{item} is not an integer or None")
|
| 46 |
+
|
| 47 |
+
items = [parse_value(v) for v in value.split(split_char)]
|
| 48 |
+
num_items = len(items)
|
| 49 |
+
|
| 50 |
+
if num_items == 1:
|
| 51 |
+
# Makes downstream handling the same for single and multiple values
|
| 52 |
+
items = items * max_len
|
| 53 |
+
elif num_items < min_len or num_items > max_len:
|
| 54 |
+
raise argparse.ArgumentTypeError(f"Argument requires {max_len} integers or None, separated by '{split_char}'")
|
| 55 |
+
elif num_items != max_len:
|
| 56 |
+
logging.warning(f"Argument requires {max_len} integers or None, separated by '{split_char}'. " "Missing values will be filled with defaults.")
|
| 57 |
+
default_items = [parse_value(v) for v in defaults.split(split_char)]
|
| 58 |
+
items.extend(default_items[num_items:]) # extend items list with missing defaults
|
| 59 |
+
|
| 60 |
+
return items
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def check_argument_types(parser: argparse.ArgumentParser):
|
| 64 |
+
"""
|
| 65 |
+
Check to make sure all CLI args are typed, raises error if not
|
| 66 |
+
"""
|
| 67 |
+
for action in parser._actions:
|
| 68 |
+
if action.dest != "help" and not action.const:
|
| 69 |
+
if action.type is None:
|
| 70 |
+
raise ValueError(f"Argument '{action.dest}' doesn't have a type specified.")
|
| 71 |
+
else:
|
| 72 |
+
continue
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def _handle_non_serializable(o):
|
| 76 |
+
if isinstance(o, np.int64) or isinstance(o, np.int32):
|
| 77 |
+
return int(o)
|
| 78 |
+
elif isinstance(o, set):
|
| 79 |
+
return list(o)
|
| 80 |
+
else:
|
| 81 |
+
return str(o)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def parse_eval_args() -> argparse.Namespace:
|
| 85 |
+
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
|
| 86 |
+
parser.add_argument("--config", default="", help="Path to a yaml file specifying all eval arguments, will ignore cli arguments if specified")
|
| 87 |
+
parser.add_argument("--model", default="hf", help="Name of model e.g. `hf`")
|
| 88 |
+
parser.add_argument(
|
| 89 |
+
"--tasks",
|
| 90 |
+
default=None,
|
| 91 |
+
help="To get full list of tasks, use the command lmms-eval --tasks list",
|
| 92 |
+
)
|
| 93 |
+
parser.add_argument(
|
| 94 |
+
"--model_args",
|
| 95 |
+
default="",
|
| 96 |
+
help="String arguments for model, e.g. `pretrained=EleutherAI/pythia-160m,dtype=float32`",
|
| 97 |
+
)
|
| 98 |
+
parser.add_argument(
|
| 99 |
+
"--launcher_args",
|
| 100 |
+
default=None,
|
| 101 |
+
help="String arguments for launcher for local llm as judge, e.g. `tp=8`, if None then no launcher will be used.",
|
| 102 |
+
)
|
| 103 |
+
parser.add_argument(
|
| 104 |
+
"--num_fewshot",
|
| 105 |
+
type=int,
|
| 106 |
+
default=None,
|
| 107 |
+
help="Number of examples in few-shot context",
|
| 108 |
+
)
|
| 109 |
+
parser.add_argument(
|
| 110 |
+
"--batch_size",
|
| 111 |
+
"-b",
|
| 112 |
+
type=str,
|
| 113 |
+
default=1,
|
| 114 |
+
metavar="auto|auto:N|N",
|
| 115 |
+
help="Acceptable values are 'auto', 'auto:N' or N, where N is an integer. Default 1.",
|
| 116 |
+
)
|
| 117 |
+
parser.add_argument(
|
| 118 |
+
"--max_batch_size",
|
| 119 |
+
type=int,
|
| 120 |
+
default=None,
|
| 121 |
+
metavar="N",
|
| 122 |
+
help="Maximal batch size to try with --batch_size auto.",
|
| 123 |
+
)
|
| 124 |
+
parser.add_argument(
|
| 125 |
+
"--device",
|
| 126 |
+
type=str,
|
| 127 |
+
default=None,
|
| 128 |
+
help="Device to use (e.g. cuda, cuda:0, cpu)",
|
| 129 |
+
)
|
| 130 |
+
parser.add_argument(
|
| 131 |
+
"--output_path",
|
| 132 |
+
default=None,
|
| 133 |
+
type=str,
|
| 134 |
+
metavar="= [dir/file.jsonl] [DIR]",
|
| 135 |
+
help="The path to the output file where the result metrics will be saved. If the path is a directory and log_samples is true, the results will be saved in the directory. Else the parent directory will be used.",
|
| 136 |
+
)
|
| 137 |
+
parser.add_argument(
|
| 138 |
+
"--limit",
|
| 139 |
+
type=float,
|
| 140 |
+
default=None,
|
| 141 |
+
help="Limit the number of examples per task. " "If <1, limit is a percentage of the total number of examples.",
|
| 142 |
+
)
|
| 143 |
+
parser.add_argument(
|
| 144 |
+
"--use_cache",
|
| 145 |
+
"-c",
|
| 146 |
+
type=str,
|
| 147 |
+
default=None,
|
| 148 |
+
metavar="DIR",
|
| 149 |
+
help="A path to a sqlite db file for caching model responses. `None` if not caching.",
|
| 150 |
+
)
|
| 151 |
+
parser.add_argument(
|
| 152 |
+
"--cache_requests",
|
| 153 |
+
type=str,
|
| 154 |
+
default=None,
|
| 155 |
+
choices=["true", "refresh", "delete"],
|
| 156 |
+
help="Speed up evaluation by caching the building of dataset requests. `None` if not caching.",
|
| 157 |
+
)
|
| 158 |
+
parser.add_argument(
|
| 159 |
+
"--check_integrity",
|
| 160 |
+
action="store_true",
|
| 161 |
+
help="Whether to run the relevant part of the test suite for the tasks",
|
| 162 |
+
)
|
| 163 |
+
parser.add_argument(
|
| 164 |
+
"--write_out",
|
| 165 |
+
"-w",
|
| 166 |
+
action="store_true",
|
| 167 |
+
default=False,
|
| 168 |
+
help="Prints the prompt for the first few documents.",
|
| 169 |
+
)
|
| 170 |
+
parser.add_argument(
|
| 171 |
+
"--log_samples",
|
| 172 |
+
action="store_true",
|
| 173 |
+
default=False,
|
| 174 |
+
help="If True, write out all model outputs and documents for per-sample measurement and post-hoc analysis",
|
| 175 |
+
)
|
| 176 |
+
parser.add_argument(
|
| 177 |
+
"--wandb_log_samples",
|
| 178 |
+
action="store_true",
|
| 179 |
+
default=False,
|
| 180 |
+
help="If True, write out all model outputs and documents for per-sample measurement and post-hoc analysis to Weights and Biases",
|
| 181 |
+
)
|
| 182 |
+
parser.add_argument(
|
| 183 |
+
"--log_samples_suffix",
|
| 184 |
+
type=str,
|
| 185 |
+
default="model_outputs",
|
| 186 |
+
help="Specify a suffix for the log_samples file name.",
|
| 187 |
+
)
|
| 188 |
+
parser.add_argument(
|
| 189 |
+
"--system_instruction",
|
| 190 |
+
type=str,
|
| 191 |
+
default=None,
|
| 192 |
+
help="System instruction to be used in the prompt",
|
| 193 |
+
)
|
| 194 |
+
parser.add_argument(
|
| 195 |
+
"--apply_chat_template",
|
| 196 |
+
action="store_true",
|
| 197 |
+
default=False,
|
| 198 |
+
help="If True, applies the chat template to the prompt",
|
| 199 |
+
)
|
| 200 |
+
parser.add_argument(
|
| 201 |
+
"--fewshot_as_multiturn",
|
| 202 |
+
action="store_true",
|
| 203 |
+
default=False,
|
| 204 |
+
help="If True, uses the fewshot as a multi-turn conversation",
|
| 205 |
+
)
|
| 206 |
+
parser.add_argument(
|
| 207 |
+
"--show_config",
|
| 208 |
+
action="store_true",
|
| 209 |
+
default=False,
|
| 210 |
+
help="If True, shows the the full config of all tasks at the end of the evaluation.",
|
| 211 |
+
)
|
| 212 |
+
parser.add_argument(
|
| 213 |
+
"--include_path",
|
| 214 |
+
type=str,
|
| 215 |
+
default=None,
|
| 216 |
+
help="Additional path to include if there are external tasks to include.",
|
| 217 |
+
)
|
| 218 |
+
parser.add_argument(
|
| 219 |
+
"--gen_kwargs",
|
| 220 |
+
default="",
|
| 221 |
+
help=("String arguments for model generation on greedy_until tasks," " e.g. `temperature=0,top_k=0,top_p=0`"),
|
| 222 |
+
)
|
| 223 |
+
parser.add_argument(
|
| 224 |
+
"--verbosity",
|
| 225 |
+
type=str,
|
| 226 |
+
default="INFO",
|
| 227 |
+
help="Log error when tasks are not registered.",
|
| 228 |
+
)
|
| 229 |
+
parser.add_argument(
|
| 230 |
+
"--wandb_args",
|
| 231 |
+
default="",
|
| 232 |
+
help="Comma separated string arguments passed to wandb.init, e.g. `project=lmms-eval,job_type=eval",
|
| 233 |
+
)
|
| 234 |
+
parser.add_argument(
|
| 235 |
+
"--timezone",
|
| 236 |
+
default="Asia/Singapore",
|
| 237 |
+
help="Timezone for datetime string, e.g. Asia/Singapore, America/New_York, America/Los_Angeles. You can check the full list via `import pytz; print(pytz.common_timezones)`",
|
| 238 |
+
)
|
| 239 |
+
parser.add_argument(
|
| 240 |
+
"--hf_hub_log_args",
|
| 241 |
+
type=str,
|
| 242 |
+
default="",
|
| 243 |
+
help="Comma separated string arguments passed to Hugging Face Hub's log function, e.g. `hub_results_org=EleutherAI,hub_repo_name=lm-eval-results`",
|
| 244 |
+
)
|
| 245 |
+
parser.add_argument(
|
| 246 |
+
"--predict_only",
|
| 247 |
+
"-x",
|
| 248 |
+
action="store_true",
|
| 249 |
+
default=False,
|
| 250 |
+
help="Use with --log_samples. Only model outputs will be saved and metrics will not be evaluated.",
|
| 251 |
+
)
|
| 252 |
+
default_seed_string = "0,1234,1234,1234"
|
| 253 |
+
parser.add_argument(
|
| 254 |
+
"--seed",
|
| 255 |
+
type=partial(_int_or_none_list_arg_type, 3, 4, default_seed_string),
|
| 256 |
+
default=default_seed_string, # for backward compatibility
|
| 257 |
+
help=(
|
| 258 |
+
"Set seed for python's random, numpy, torch, and fewshot sampling.\n"
|
| 259 |
+
"Accepts a comma-separated list of 4 values for python's random, numpy, torch, and fewshot sampling seeds, "
|
| 260 |
+
"respectively, or a single integer to set the same seed for all four.\n"
|
| 261 |
+
f"The values are either an integer or 'None' to not set the seed. Default is `{default_seed_string}` "
|
| 262 |
+
"(for backward compatibility).\n"
|
| 263 |
+
"E.g. `--seed 0,None,8,52` sets `random.seed(0)`, `torch.manual_seed(8)`, and fewshot sampling seed to 52. "
|
| 264 |
+
"Here numpy's seed is not set since the second value is `None`.\n"
|
| 265 |
+
"E.g, `--seed 42` sets all four seeds to 42."
|
| 266 |
+
),
|
| 267 |
+
)
|
| 268 |
+
parser.add_argument(
|
| 269 |
+
"--trust_remote_code",
|
| 270 |
+
action="store_true",
|
| 271 |
+
help="Sets trust_remote_code to True to execute code to create HF Datasets from the Hub",
|
| 272 |
+
)
|
| 273 |
+
parser.add_argument("--process_with_media", action="store_true", help="Whether you will process you dataset with audio, image. By default set to False" "In case some benchmarks need to be processed with media, set this flag to True.")
|
| 274 |
+
parser.add_argument("--force_simple", action="store_true", help="Force the evaluation to use the simple mode of the models")
|
| 275 |
+
args = parser.parse_args()
|
| 276 |
+
return args
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def cli_evaluate(args: Union[argparse.Namespace, None] = None) -> None:
|
| 280 |
+
default_args = parse_eval_args()
|
| 281 |
+
|
| 282 |
+
if args is None and len(sys.argv) == 1:
|
| 283 |
+
print("┌───────────────────────────────────────────────────────────────────────────────┐")
|
| 284 |
+
print("│ Please provide arguments to evaluate the model. e.g. │")
|
| 285 |
+
print("│ `lmms-eval --model llava --model_path liuhaotian/llava-v1.6-7b --tasks okvqa` │")
|
| 286 |
+
print("│ Use `lmms-eval --help` for more information. │")
|
| 287 |
+
print("└───────────────────────────────────────────────────────────────────────────────┘")
|
| 288 |
+
sys.exit(1)
|
| 289 |
+
|
| 290 |
+
# If args were provided, override the defaults
|
| 291 |
+
if args:
|
| 292 |
+
for key, value in vars(args).items():
|
| 293 |
+
setattr(default_args, key, value)
|
| 294 |
+
|
| 295 |
+
args = default_args
|
| 296 |
+
|
| 297 |
+
if args.wandb_args:
|
| 298 |
+
if "name" not in args.wandb_args:
|
| 299 |
+
name = f"{args.model}_{args.model_args}_{utils.get_datetime_str(timezone=args.timezone)}"
|
| 300 |
+
name = utils.sanitize_long_string(name)
|
| 301 |
+
args.wandb_args += f",name={name}"
|
| 302 |
+
wandb_logger = WandbLogger(**simple_parse_args_string(args.wandb_args))
|
| 303 |
+
|
| 304 |
+
# reset logger
|
| 305 |
+
eval_logger.remove()
|
| 306 |
+
# Configure logger with detailed format including file path, function name, and line number
|
| 307 |
+
log_format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | " "<level>{level: <8}</level> | " "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - " "<level>{message}</level>"
|
| 308 |
+
eval_logger.add(sys.stdout, colorize=True, level=args.verbosity, format=log_format)
|
| 309 |
+
eval_logger.info(f"Verbosity set to {args.verbosity}")
|
| 310 |
+
os.environ["VERBOSITY"] = args.verbosity
|
| 311 |
+
|
| 312 |
+
args_list = []
|
| 313 |
+
results_list = []
|
| 314 |
+
if args.config:
|
| 315 |
+
if not os.path.exists(args.config):
|
| 316 |
+
raise ValueError(f"Config file does not exist: {args.config}")
|
| 317 |
+
|
| 318 |
+
with open(args.config, "r") as file:
|
| 319 |
+
config_args = yaml.safe_load(file)
|
| 320 |
+
config_args = [config_args] if type(config_args) != list else config_args
|
| 321 |
+
# multiple configs, create args list first
|
| 322 |
+
for config in config_args:
|
| 323 |
+
args_copy = argparse.Namespace(**vars(args))
|
| 324 |
+
for key, value in config.items():
|
| 325 |
+
setattr(args_copy, key, value)
|
| 326 |
+
args_list.append(args_copy)
|
| 327 |
+
else:
|
| 328 |
+
args_list.append(args)
|
| 329 |
+
|
| 330 |
+
# initialize Accelerator only if not already in a distributed context
|
| 331 |
+
if torch.distributed.is_available() and torch.distributed.is_initialized():
|
| 332 |
+
accelerator = None
|
| 333 |
+
is_main_process = torch.distributed.get_rank() == 0
|
| 334 |
+
else:
|
| 335 |
+
kwargs_handler = InitProcessGroupKwargs(timeout=datetime.timedelta(seconds=60000))
|
| 336 |
+
accelerator = Accelerator(kwargs_handlers=[kwargs_handler])
|
| 337 |
+
if accelerator.is_main_process:
|
| 338 |
+
is_main_process = True
|
| 339 |
+
else:
|
| 340 |
+
is_main_process = False
|
| 341 |
+
|
| 342 |
+
for args in args_list:
|
| 343 |
+
try:
|
| 344 |
+
# if is_main_process and args.wandb_args: # thoughtfully we should only init wandb once, instead of multiple ranks to avoid network traffics and unwanted behaviors.
|
| 345 |
+
# wandb_logger = WandbLogger()
|
| 346 |
+
|
| 347 |
+
results, samples = cli_evaluate_single(args)
|
| 348 |
+
results_list.append(results)
|
| 349 |
+
|
| 350 |
+
if accelerator:
|
| 351 |
+
accelerator.wait_for_everyone()
|
| 352 |
+
elif torch.distributed.is_available() and torch.distributed.is_initialized():
|
| 353 |
+
torch.distributed.barrier()
|
| 354 |
+
if is_main_process and args.wandb_args:
|
| 355 |
+
try:
|
| 356 |
+
wandb_logger.post_init(results)
|
| 357 |
+
wandb_logger.log_eval_result()
|
| 358 |
+
if args.wandb_log_samples and samples is not None:
|
| 359 |
+
wandb_logger.log_eval_samples(samples)
|
| 360 |
+
except Exception as e:
|
| 361 |
+
eval_logger.info(f"Logging to Weights and Biases failed due to {e}")
|
| 362 |
+
# wandb_logger.finish()
|
| 363 |
+
|
| 364 |
+
except Exception as e:
|
| 365 |
+
if args.verbosity == "DEBUG":
|
| 366 |
+
raise e
|
| 367 |
+
else:
|
| 368 |
+
traceback.print_exc()
|
| 369 |
+
eval_logger.error(f"Error during evaluation: {e}. Please set `--verbosity=DEBUG` to get more information.")
|
| 370 |
+
results_list.append(None)
|
| 371 |
+
|
| 372 |
+
for args, results in zip(args_list, results_list):
|
| 373 |
+
# cli_evaluate will return none if the process is not the main process (rank 0)
|
| 374 |
+
if results is not None:
|
| 375 |
+
print(f"{args.model} ({args.model_args}), gen_kwargs: ({args.gen_kwargs}), limit: {args.limit}, num_fewshot: {args.num_fewshot}, " f"batch_size: {args.batch_size}")
|
| 376 |
+
print(make_table(results))
|
| 377 |
+
if "groups" in results:
|
| 378 |
+
print(make_table(results, "groups"))
|
| 379 |
+
|
| 380 |
+
if args.wandb_args:
|
| 381 |
+
wandb_logger.run.finish()
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def cli_evaluate_single(args: Union[argparse.Namespace, None] = None) -> None:
|
| 385 |
+
selected_task_list = args.tasks.split(",") if args.tasks else None
|
| 386 |
+
|
| 387 |
+
if args.include_path is not None:
|
| 388 |
+
eval_logger.info(f"Including path: {args.include_path}")
|
| 389 |
+
task_manager = TaskManager(args.verbosity, include_path=args.include_path, model_name=args.model)
|
| 390 |
+
|
| 391 |
+
# update the evaluation tracker args with the output path and the HF token
|
| 392 |
+
if args.output_path:
|
| 393 |
+
args.hf_hub_log_args += f",output_path={args.output_path}"
|
| 394 |
+
if os.environ.get("HF_TOKEN", None):
|
| 395 |
+
args.hf_hub_log_args += f",token={os.environ.get('HF_TOKEN')}"
|
| 396 |
+
|
| 397 |
+
evaluation_tracker_args = simple_parse_args_string(args.hf_hub_log_args)
|
| 398 |
+
eval_logger.info(f"Evaluation tracker args: {evaluation_tracker_args}")
|
| 399 |
+
|
| 400 |
+
evaluation_tracker = EvaluationTracker(**evaluation_tracker_args)
|
| 401 |
+
|
| 402 |
+
if args.predict_only:
|
| 403 |
+
args.log_samples = True
|
| 404 |
+
if (args.log_samples or args.predict_only) and not args.output_path:
|
| 405 |
+
raise ValueError("Specify --output_path if providing --log_samples or --predict_only")
|
| 406 |
+
|
| 407 |
+
if args.fewshot_as_multiturn and args.apply_chat_template is False:
|
| 408 |
+
raise ValueError("If fewshot_as_multiturn is set, apply_chat_template must be set to True.")
|
| 409 |
+
|
| 410 |
+
if (args.num_fewshot is None or args.num_fewshot == 0) and args.fewshot_as_multiturn:
|
| 411 |
+
raise ValueError("If fewshot_as_multiturn is set, num_fewshot must be greater than 0.")
|
| 412 |
+
|
| 413 |
+
if args.include_path is not None:
|
| 414 |
+
eval_logger.info(f"Including path: {args.include_path}")
|
| 415 |
+
|
| 416 |
+
if "push_samples_to_hub" in evaluation_tracker_args and not args.log_samples:
|
| 417 |
+
eval_logger.warning("Pushing samples to the Hub requires --log_samples to be set. Samples will not be pushed to the Hub.")
|
| 418 |
+
|
| 419 |
+
if args.limit:
|
| 420 |
+
eval_logger.warning(" --limit SHOULD ONLY BE USED FOR TESTING." "REAL METRICS SHOULD NOT BE COMPUTED USING LIMIT.")
|
| 421 |
+
|
| 422 |
+
if os.environ.get("LMMS_EVAL_PLUGINS", None):
|
| 423 |
+
args.include_path = [args.include_path] if args.include_path else []
|
| 424 |
+
for plugin in os.environ["LMMS_EVAL_PLUGINS"].split(","):
|
| 425 |
+
package_tasks_location = importlib.util.find_spec(f"{plugin}.tasks").submodule_search_locations[0]
|
| 426 |
+
args.include_path.append(package_tasks_location)
|
| 427 |
+
|
| 428 |
+
if args.tasks is None:
|
| 429 |
+
eval_logger.error("Need to specify task to evaluate.")
|
| 430 |
+
sys.exit()
|
| 431 |
+
elif args.tasks == "list":
|
| 432 |
+
eval_logger.info("Available Tasks:\n - {}".format(f"\n - ".join(sorted(task_manager.all_tasks))))
|
| 433 |
+
sys.exit()
|
| 434 |
+
elif args.tasks == "list_groups":
|
| 435 |
+
eval_logger.info(task_manager.list_all_tasks(list_subtasks=False, list_tags=False))
|
| 436 |
+
sys.exit()
|
| 437 |
+
elif args.tasks == "list_tags":
|
| 438 |
+
eval_logger.info(task_manager.list_all_tasks(list_groups=False, list_subtasks=False))
|
| 439 |
+
sys.exit()
|
| 440 |
+
elif args.tasks == "list_subtasks":
|
| 441 |
+
eval_logger.info(task_manager.list_all_tasks(list_groups=False, list_tags=False))
|
| 442 |
+
sys.exit()
|
| 443 |
+
else:
|
| 444 |
+
if os.path.isdir(args.tasks):
|
| 445 |
+
import glob
|
| 446 |
+
|
| 447 |
+
task_names = []
|
| 448 |
+
yaml_path = os.path.join(args.tasks, "*.yaml")
|
| 449 |
+
for yaml_file in glob.glob(yaml_path):
|
| 450 |
+
config = utils.load_yaml_config(yaml_file)
|
| 451 |
+
task_names.append(config)
|
| 452 |
+
else:
|
| 453 |
+
task_list = args.tasks.split(",")
|
| 454 |
+
task_names = task_manager.match_tasks(task_list)
|
| 455 |
+
for task in [task for task in task_list if task not in task_names]:
|
| 456 |
+
if os.path.isfile(task):
|
| 457 |
+
config = utils.load_yaml_config(task)
|
| 458 |
+
task_names.append(config)
|
| 459 |
+
task_missing = [task for task in task_list if task not in task_names and "*" not in task] # we don't want errors if a wildcard ("*") task name was used
|
| 460 |
+
|
| 461 |
+
if task_missing:
|
| 462 |
+
missing = ", ".join(task_missing)
|
| 463 |
+
eval_logger.error(
|
| 464 |
+
f"Tasks were not found: {missing}\n" f"{utils.SPACING}Try `lmms-eval --tasks list` for list of available tasks",
|
| 465 |
+
)
|
| 466 |
+
raise ValueError(
|
| 467 |
+
f"Tasks not found: {missing}. Try `lmms-eval --tasks {{list_groups,list_subtasks,list_tags,list}}` to list out all available names for task groupings; only (sub)tasks; tags; or all of the above, or pass '--verbosity DEBUG' to troubleshoot task registration issues."
|
| 468 |
+
)
|
| 469 |
+
|
| 470 |
+
eval_logger.info(f"Selected Tasks: {task_names}")
|
| 471 |
+
request_caching_args = request_caching_arg_to_dict(cache_requests=args.cache_requests)
|
| 472 |
+
datetime_str = utils.get_datetime_str(timezone=args.timezone)
|
| 473 |
+
|
| 474 |
+
results = evaluator.simple_evaluate(
|
| 475 |
+
model=args.model,
|
| 476 |
+
model_args=args.model_args,
|
| 477 |
+
tasks=task_names,
|
| 478 |
+
num_fewshot=args.num_fewshot,
|
| 479 |
+
batch_size=args.batch_size,
|
| 480 |
+
max_batch_size=args.max_batch_size,
|
| 481 |
+
device=args.device,
|
| 482 |
+
use_cache=args.use_cache,
|
| 483 |
+
limit=args.limit,
|
| 484 |
+
check_integrity=args.check_integrity,
|
| 485 |
+
write_out=args.write_out,
|
| 486 |
+
log_samples=args.log_samples,
|
| 487 |
+
evaluation_tracker=evaluation_tracker,
|
| 488 |
+
system_instruction=args.system_instruction,
|
| 489 |
+
apply_chat_template=args.apply_chat_template,
|
| 490 |
+
fewshot_as_multiturn=args.fewshot_as_multiturn,
|
| 491 |
+
gen_kwargs=args.gen_kwargs,
|
| 492 |
+
task_manager=task_manager,
|
| 493 |
+
verbosity=args.verbosity,
|
| 494 |
+
predict_only=args.predict_only,
|
| 495 |
+
random_seed=args.seed[0],
|
| 496 |
+
numpy_random_seed=args.seed[1],
|
| 497 |
+
torch_random_seed=args.seed[2],
|
| 498 |
+
fewshot_random_seed=args.seed[3],
|
| 499 |
+
cli_args=args,
|
| 500 |
+
datetime_str=datetime_str,
|
| 501 |
+
distributed_executor_backend="torchrun" if (torch.distributed.is_available() and torch.distributed.is_initialized()) else "accelerate",
|
| 502 |
+
force_simple=args.force_simple,
|
| 503 |
+
launcher_args=args.launcher_args,
|
| 504 |
+
**request_caching_args,
|
| 505 |
+
)
|
| 506 |
+
|
| 507 |
+
if results is not None:
|
| 508 |
+
if args.log_samples:
|
| 509 |
+
samples = results.pop("samples")
|
| 510 |
+
else:
|
| 511 |
+
samples = None
|
| 512 |
+
dumped = json.dumps(results, indent=4, default=_handle_non_serializable)
|
| 513 |
+
if args.show_config:
|
| 514 |
+
print(dumped)
|
| 515 |
+
|
| 516 |
+
batch_sizes = ",".join(map(str, results["config"]["batch_sizes"]))
|
| 517 |
+
|
| 518 |
+
evaluation_tracker.save_results_aggregated(results=results, samples=samples if args.log_samples else None, datetime_str=datetime_str)
|
| 519 |
+
|
| 520 |
+
if args.log_samples:
|
| 521 |
+
for task_name, config in results["configs"].items():
|
| 522 |
+
evaluation_tracker.save_results_samples(task_name=task_name, samples=samples[task_name])
|
| 523 |
+
|
| 524 |
+
if evaluation_tracker.push_results_to_hub or evaluation_tracker.push_samples_to_hub:
|
| 525 |
+
evaluation_tracker.recreate_metadata_card()
|
| 526 |
+
|
| 527 |
+
return results, samples
|
| 528 |
+
return None, None
|
| 529 |
+
|
| 530 |
+
|
| 531 |
+
def print_results(args, results):
|
| 532 |
+
print(f"{args.model} ({args.model_args}),\ngen_kwargs: ({args.gen_kwargs}),\nlimit: {args.limit},\nnum_fewshot: {args.num_fewshot},\nbatch_size: {args.batch_size}")
|
| 533 |
+
print(evaluator.make_table(results))
|
| 534 |
+
if "groups" in results:
|
| 535 |
+
print(evaluator.make_table(results, "groups"))
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
if __name__ == "__main__":
|
| 539 |
+
cli_evaluate()
|
lmms-eval/lmms_eval/api/__init__.py
ADDED
|
File without changes
|
lmms-eval/lmms_eval/api/filter.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
from typing import List
|
| 3 |
+
|
| 4 |
+
from datasets import Dataset
|
| 5 |
+
|
| 6 |
+
from lmms_eval.api.instance import Instance
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Filter:
|
| 10 |
+
"""
|
| 11 |
+
Filter classes operate on a per-task level.
|
| 12 |
+
They take all model outputs (`instance.resps` for all `task.instances`)
|
| 13 |
+
across all instances of a task, and perform operations.
|
| 14 |
+
In a single run, one can configure any number of separate filters or lists of filters.
|
| 15 |
+
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
def __init__(self, *args, **kwargs) -> None:
|
| 19 |
+
"""
|
| 20 |
+
Can define custom behavior here, if an individual instantiation of a Filter class should have state.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
def apply(self, resps, docs):
|
| 24 |
+
"""
|
| 25 |
+
Defines the operation to perform on a list of the `inst.resps` properties of `Instance` objects.
|
| 26 |
+
Should return the list of (filtered) response lists *in the same order as they were input*, e.g.
|
| 27 |
+
if pass in [<inst.resps for instance 0>, <inst.resps for instance 1>] should return
|
| 28 |
+
[<filtered resps for instance 0>, <filtered resps for instance 1>]
|
| 29 |
+
"""
|
| 30 |
+
return resps
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@dataclass
|
| 34 |
+
class FilterEnsemble:
|
| 35 |
+
"""
|
| 36 |
+
FilterEnsemble creates a pipeline applying multiple filters.
|
| 37 |
+
Its intended usage is to stack multiple post-processing steps in order.
|
| 38 |
+
`task.apply_filters` should use a list of FilterEnsemble classes that it stores, to apply each
|
| 39 |
+
pipeline separately.
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
name: str
|
| 43 |
+
filters: List[Filter]
|
| 44 |
+
|
| 45 |
+
def apply(self, instances: List[Instance], docs: List[Dataset]) -> None:
|
| 46 |
+
resps = [inst.resps for inst in instances] # operate just on the model responses
|
| 47 |
+
for f in self.filters:
|
| 48 |
+
# apply filters in sequence
|
| 49 |
+
resps = f.apply(resps, docs)
|
| 50 |
+
|
| 51 |
+
# add the end results after filtering to filtered_requests of their respective source instances.
|
| 52 |
+
# has key `self.name`: each FilterEnsemble applied in a given run should use a different name.
|
| 53 |
+
for inst, resp in zip(instances, resps):
|
| 54 |
+
inst.filtered_resps[self.name] = resp
|
lmms-eval/lmms_eval/api/group.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import abc
|
| 2 |
+
from dataclasses import asdict, dataclass
|
| 3 |
+
from inspect import getsource
|
| 4 |
+
from typing import Any, Callable, List, Optional, Union
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@dataclass
|
| 8 |
+
class AggMetricConfig(dict):
|
| 9 |
+
metric: Optional[str] = None
|
| 10 |
+
aggregation: Optional[str] = "mean"
|
| 11 |
+
weight_by_size: Optional[str] = False
|
| 12 |
+
# list of filter names which should be incorporated into the aggregated metric.
|
| 13 |
+
filter_list: Optional[Union[str, list]] = "none"
|
| 14 |
+
|
| 15 |
+
def __post_init__(self):
|
| 16 |
+
if self.aggregation != "mean" and not callable(self.aggregation):
|
| 17 |
+
raise ValueError(f"Currently, 'mean' is the only pre-defined aggregation across groups' subtasks. Got '{self.aggregation}'.")
|
| 18 |
+
|
| 19 |
+
if isinstance(self.filter_list, str):
|
| 20 |
+
self.filter_list = [self.filter_list]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
@dataclass
|
| 24 |
+
class GroupConfig(dict):
|
| 25 |
+
group: Optional[str] = None
|
| 26 |
+
group_alias: Optional[str] = None
|
| 27 |
+
task: Optional[Union[str, list]] = None
|
| 28 |
+
aggregate_metric_list: Optional[Union[List[AggMetricConfig], AggMetricConfig, dict]] = None
|
| 29 |
+
metadata: Optional[dict] = None # by default, not used in the code. allows for users to pass arbitrary info to tasks
|
| 30 |
+
|
| 31 |
+
def __getitem__(self, item):
|
| 32 |
+
return getattr(self, item)
|
| 33 |
+
|
| 34 |
+
def __setitem__(self, item, value):
|
| 35 |
+
return setattr(self, item, value)
|
| 36 |
+
|
| 37 |
+
def __post_init__(self):
|
| 38 |
+
if self.aggregate_metric_list is not None:
|
| 39 |
+
if isinstance(self.aggregate_metric_list, dict):
|
| 40 |
+
self.aggregate_metric_list = [self.aggregate_metric_list]
|
| 41 |
+
|
| 42 |
+
self.aggregate_metric_list = [AggMetricConfig(**item) if isinstance(item, dict) else item for item in self.aggregate_metric_list]
|
| 43 |
+
|
| 44 |
+
def to_dict(self, keep_callable: bool = False) -> dict:
|
| 45 |
+
"""dumps the current config as a dictionary object, as a printable format.
|
| 46 |
+
null fields will not be printed.
|
| 47 |
+
Used for dumping results alongside full task configuration
|
| 48 |
+
|
| 49 |
+
:return: dict
|
| 50 |
+
A printable dictionary version of the TaskConfig object.
|
| 51 |
+
|
| 52 |
+
# TODO: should any default value in the TaskConfig not be printed?
|
| 53 |
+
"""
|
| 54 |
+
cfg_dict = asdict(self)
|
| 55 |
+
# remove values that are `None`
|
| 56 |
+
for k, v in list(cfg_dict.items()):
|
| 57 |
+
if callable(v):
|
| 58 |
+
cfg_dict[k] = self.serialize_function(v, keep_callable=keep_callable)
|
| 59 |
+
return cfg_dict
|
| 60 |
+
|
| 61 |
+
def serialize_function(self, value: Union[Callable, str], keep_callable=False) -> Union[Callable, str]:
|
| 62 |
+
"""Serializes a given function or string.
|
| 63 |
+
|
| 64 |
+
If 'keep_callable' is True, the original callable is returned.
|
| 65 |
+
Otherwise, attempts to return the source code of the callable using 'getsource'.
|
| 66 |
+
"""
|
| 67 |
+
if keep_callable:
|
| 68 |
+
return value
|
| 69 |
+
else:
|
| 70 |
+
try:
|
| 71 |
+
return getsource(value)
|
| 72 |
+
except (TypeError, OSError):
|
| 73 |
+
return str(value)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class ConfigurableGroup(abc.ABC):
|
| 77 |
+
def __init__(
|
| 78 |
+
self,
|
| 79 |
+
config: Optional[dict] = None,
|
| 80 |
+
) -> None:
|
| 81 |
+
self._config = GroupConfig(**config)
|
| 82 |
+
|
| 83 |
+
@property
|
| 84 |
+
def group(self):
|
| 85 |
+
return self._config.group
|
| 86 |
+
|
| 87 |
+
@property
|
| 88 |
+
def group_alias(self):
|
| 89 |
+
return self._config.group_alias
|
| 90 |
+
|
| 91 |
+
@property
|
| 92 |
+
def version(self):
|
| 93 |
+
return self._config.version
|
| 94 |
+
|
| 95 |
+
@property
|
| 96 |
+
def config(self):
|
| 97 |
+
return self._config.to_dict()
|
| 98 |
+
|
| 99 |
+
@property
|
| 100 |
+
def group_name(self) -> Any:
|
| 101 |
+
return self._config.group
|
| 102 |
+
|
| 103 |
+
def __repr__(self):
|
| 104 |
+
return f"ConfigurableGroup(group={self.group}," f"group_alias={self.group_alias})"
|