# Multimodal Large Models This framework supports two custom multimodal evaluation methods: - **General-VQA Format**: Based on OpenAI message format, supports multi-image/audio input, system prompts, and base64 encoding, suitable for Q&A-based multimodal evaluation tasks. - **General-VMCQ Format**: Similar to MMMU format, question text can contain image placeholders ``, suitable for multiple-choice multimodal evaluation tasks. ## General-VQA Format ### 1. Data Preparation Prepare data files conforming to OpenAI message format, supporting **JSONL** or **TSV** formats: **JSONL Format Example** (`example_openai.jsonl`): ```json {"messages": [{"role": "user", "content": [{"type": "text", "text": "What animal is this?"}, {"type": "image_url", "image_url": {"url": "custom_eval/multimodal/images/dog.jpg"}}]}], "answer": "Dog"} {"messages": [{"role": "user", "content": [{"type": "text", "text": "What building is this?"}, {"type": "image_url", "image_url": {"url": "custom_eval/multimodal/images/AMNH.jpg"}}]}], "answer": "Museum"} ``` **TSV Format Example** (`example_openai.tsv`): ```text messages answer [{"role": "user", "content": [{"type": "text", "text": "What animal is this?"}, {"type": "image_url", "image_url": {"url": "custom_eval/multimodal/images/dog.jpg"}}]}] Dog [{"role": "user", "content": [{"type": "text", "text": "What building is this?"}, {"type": "image_url", "image_url": {"url": "custom_eval/multimodal/images/AMNH.jpg"}}]}] Museum ``` **Field Descriptions**: - `messages`: OpenAI format message array, supporting: - Text content: `{"type": "text", "text": "question text"}` - Image URL: `{"type": "image_url", "image_url": {"url": "path or base64"}}` - Audio input: `{"type": "input_audio", "input_audio": {"data": "path or base64", "format": "wav"}}` - Video URL: `{"type": "video_url", "video_url": {"url": "path or base64"}}` - System message: `{"role": "system", "content": "system prompt"}` - `answer`: Reference answer (optional, used to calculate BLEU and Rouge scores) **Supported Image Formats**: - Local path: `"url": "custom_eval/multimodal/images/dog.jpg"` - HTTP URL: `"url": "https://example.com/image.jpg"` (requires model service support) - Base64 encoding: `"url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."` **Supported Audio Formats**: - Local path: `"data": "custom_eval/multimodal/audio/sample.wav"` - Base64 encoding: `"data": "data:audio/wav;base64,UklGRiQ..."` - Audio format (`format` field): supports `"wav"` and `"mp3"` **Supported Video Formats**: - Local path: `"url": "custom_eval/multimodal/videos/sample.mp4"` - HTTP URL: `"url": "https://example.com/video.mp4"` (requires model service support) - Base64 encoding: `"url": "data:video/mp4;base64,AAAAIGZ0eX..."` - Video format is inferred from the path, URL, or data URI; supported formats are `"mp4"`, `"mpeg"`, and `"mov"`. **Multi-image Input** Supports using multiple images in one question: ```json { "messages": [ { "role": "user", "content": [ {"type": "text", "text": "Compare these two images:"}, {"type": "image_url", "image_url": {"url": "image1.jpg"}}, {"type": "text", "text": "and"}, {"type": "image_url", "image_url": {"url": "image2.jpg"}}, {"type": "text", "text": "What are the differences?"} ] } ], "answer": "The main differences are..." } ``` **System Prompt** You can add system messages to set the evaluation context: ```json { "messages": [ {"role": "system", "content": "You are a medical AI assistant."}, { "role": "user", "content": [ {"type": "text", "text": "Analyze this X-ray:"}, {"type": "image_url", "image_url": {"url": "xray.jpg", "detail": "high"}} ] } ], "answer": "The X-ray shows..." } ``` **Base64 Images** Supports directly using base64 encoded images: ```json { "messages": [ { "role": "user", "content": [ {"type": "text", "text": "What's in this image?"}, { "type": "image_url", "image_url": { "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..." } } ] } ], "answer": "A beautiful landscape" } ``` **Audio Input** Supports audio content input using OpenAI `input_audio` format. The `data` field accepts either a local file path or base64-encoded data. The `format` field supports `"wav"` and `"mp3"`: ```json { "messages": [ { "role": "user", "content": [ {"type": "text", "text": "Describe the content of this audio clip."}, { "type": "input_audio", "input_audio": { "data": "custom_eval/multimodal/audio/sample.wav", "format": "wav" } } ] } ], "answer": "A piano music performance." } ``` You can also use base64-encoded audio data: ```json { "messages": [ { "role": "user", "content": [ {"type": "text", "text": "What is being said in this audio?"}, { "type": "input_audio", "input_audio": { "data": "UklGRiQAAABXQVZFZm10IBAAAA...", "format": "wav" } } ] } ], "answer": "Hello, world." } ``` **Video Input** Supports video content input using OpenAI-compatible `video_url` format. The `url` field accepts either a local file path, HTTP URL, or base64-encoded data URL: ```json { "messages": [ { "role": "user", "content": [ {"type": "text", "text": "Describe the content of this video clip."}, { "type": "video_url", "video_url": { "url": "custom_eval/multimodal/videos/sample.mp4" } } ] } ], "answer": "A short video clip." } ``` ### 2. Configure Evaluation Task Evaluate using Python API or CLI: **Python API**: ```python from evalscope.run import run_task from evalscope.config import TaskConfig from os import environ as env task_cfg = TaskConfig( model='qwen-vl-plus', api_url='https://dashscope.aliyuncs.com/compatible-mode/v1', api_key=env.get('DASHSCOPE_API_KEY'), eval_type='openai_api', datasets=['general_vqa'], dataset_args={ 'general_vqa': { 'local_path': 'custom_eval/multimodal/vqa', # Dataset directory 'subset_list': ['example_openai'], # Filename (without extension) } }, limit=5, # Optional: limit number of evaluation samples ) result = run_task(task_cfg=task_cfg) ``` **CLI**: ```bash evalscope eval \ --model qwen-vl-plus \ --api-url https://dashscope.aliyuncs.com/compatible-mode/v1 \ --api-key "$DASHSCOPE_API_KEY" \ --eval-type openai_api \ --datasets general_vqa \ --dataset-args '{"general_vqa": {"local_path": "custom_eval/multimodal/vqa", "subset_list": ["example_openai"]}}' \ --limit 5 ``` Evaluation will output BLEU and Rouge metrics: ```text +--------------+-------------+----------------+----------------+-------+---------+---------+ | Model | Dataset | Metric | Subset | Num | Score | Cat.0 | +==============+=============+================+================+=======+=========+=========+ | qwen-vl-plus | general_vqa | mean_bleu-1 | example_openai | 5 | 0.0067 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_bleu-2 | example_openai | 5 | 0 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_bleu-3 | example_openai | 5 | 0 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_bleu-4 | example_openai | 5 | 0 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-1-R | example_openai | 5 | 0.4 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-1-P | example_openai | 5 | 0.0062 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-1-F | example_openai | 5 | 0.0121 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-2-R | example_openai | 5 | 0 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-2-P | example_openai | 5 | 0 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-2-F | example_openai | 5 | 0 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-L-R | example_openai | 5 | 0.4 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-L-P | example_openai | 5 | 0.0047 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ | qwen-vl-plus | general_vqa | mean_Rouge-L-F | example_openai | 5 | 0.0093 | default | +--------------+-------------+----------------+----------------+-------+---------+---------+ ``` ### 3. Configure Judge Model You can specify a judge model through the `judge_model` parameter to generate reference answers for evaluation, which will obtain accuracy metrics: ```python from evalscope.run import run_task from evalscope.constants import EvalType, JudgeStrategy from os import environ as env task_cfg = TaskConfig( model='qwen-vl-plus', api_url='https://dashscope.aliyuncs.com/compatible-mode/v1', api_key=env.get('DASHSCOPE_API_KEY'), eval_type='openai_api', datasets=['general_vqa'], dataset_args={ 'general_vqa': { 'local_path': 'custom_eval/multimodal/vqa', 'subset_list': ['example_openai'], } }, limit=5, judge_model_args={ 'model_id': 'qwen-plus', # Does not need to be a multimodal model 'api_url': 'https://dashscope.aliyuncs.com/compatible-mode/v1', 'api_key': env.get('DASHSCOPE_API_KEY'), 'generation_config': { 'temperature': 0.0, 'max_tokens': 4096 }, }, eval_batch_size=5, judge_strategy=JudgeStrategy.LLM, ) result = run_task(task_cfg=task_cfg) ``` **CLI** (equivalent): ```bash evalscope eval \ --model qwen-vl-plus \ --api-url https://dashscope.aliyuncs.com/compatible-mode/v1 \ --api-key "$DASHSCOPE_API_KEY" \ --eval-type openai_api \ --datasets general_vqa \ --dataset-args '{"general_vqa": {"local_path": "custom_eval/multimodal/vqa", "subset_list": ["example_openai"]}}' \ --limit 5 \ --judge-model-args '{"model_id": "qwen-plus", "api_url": "https://dashscope.aliyuncs.com/compatible-mode/v1", "api_key": "$DASHSCOPE_API_KEY", "generation_config": {"temperature": 0.0, "max_tokens": 4096}}' \ --judge-worker-num 5 \ --judge-strategy llm ``` Evaluation will output accuracy metrics: ```text +--------------+-------------+----------+----------------+-------+---------+---------+ | Model | Dataset | Metric | Subset | Num | Score | Cat.0 | +==============+=============+==========+================+=======+=========+=========+ | qwen-vl-plus | general_vqa | mean_acc | example_openai | 5 | 1 | default | +--------------+-------------+----------+----------------+-------+---------+---------+ ``` ## General-VMCQ Format ### 1. Data Preparation General-VMCQ adopts a structure similar to MMMU: question text can contain image placeholders `` and video placeholders `