Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 12 additions & 4 deletions MLLM_eval/gpt4v_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
},
"minimax": {
"base_url": "https://api.minimax.io/v1/chat/completions",
"model": "MiniMax-M2.7",
"model": "MiniMax-M3",
"models": ["MiniMax-M3", "MiniMax-M2.7", "MiniMax-M2.7-highspeed"],
"api_key_env": "MINIMAX_API_KEY",
},
}

def parse_args():
parser = argparse.ArgumentParser(description="Evaluation by GPT-4V or MiniMax M2.7.")
parser = argparse.ArgumentParser(description="Evaluation by GPT-4V or MiniMax (M3 by default, M2.7 still available).")
parser.add_argument(
"--image_path",
type=str,
Expand Down Expand Up @@ -59,9 +60,16 @@ def parse_args():
type=str,
default="openai",
choices=["openai", "minimax"],
help="LLM provider for vision evaluation: 'openai' (GPT-4V) or 'minimax' (MiniMax M2.7). "
help="LLM provider for vision evaluation: 'openai' (GPT-4V) or 'minimax' (MiniMax, defaults to M3). "
"Set the corresponding API key via OPENAI_API_KEY or MINIMAX_API_KEY env var.",
)
parser.add_argument(
"--model",
type=str,
default=None,
help="Override the provider's default model. For 'minimax' choose MiniMax-M3 (default), "
"MiniMax-M2.7, or MiniMax-M2.7-highspeed. Defaults to the provider's configured model.",
)

return parser.parse_args()

Expand All @@ -84,7 +92,7 @@ def main():
if not resolved_api_key:
print(f"Warning: {cfg['api_key_env']} is not set. Requests will likely fail.")

model = cfg["model"]
model = args.model or cfg["model"]
endpoint = cfg["base_url"]

# Path to your image
Expand Down
33 changes: 28 additions & 5 deletions MLLM_eval/test_gpt4v_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,23 @@ def test_minimax_endpoint(self):
self.assertIn("api.minimax.io", PROVIDER_CONFIGS["minimax"]["base_url"])
self.assertIn("/v1/chat/completions", PROVIDER_CONFIGS["minimax"]["base_url"])

def test_minimax_model_is_m27(self):
self.assertEqual(PROVIDER_CONFIGS["minimax"]["model"], "MiniMax-M2.7")
def test_minimax_default_model_is_m3(self):
self.assertEqual(PROVIDER_CONFIGS["minimax"]["model"], "MiniMax-M3")

def test_minimax_models_list_m3_first(self):
models = PROVIDER_CONFIGS["minimax"]["models"]
self.assertEqual(models[0], "MiniMax-M3") # M3 is the new default / listed first

def test_minimax_retains_m27(self):
self.assertIn("MiniMax-M2.7", PROVIDER_CONFIGS["minimax"]["models"])

def test_minimax_retains_m27_highspeed(self):
self.assertIn("MiniMax-M2.7-highspeed", PROVIDER_CONFIGS["minimax"]["models"])

def test_minimax_drops_deprecated_models(self):
models = PROVIDER_CONFIGS["minimax"]["models"]
for old in ("MiniMax-M2.5", "MiniMax-M2.1", "MiniMax-M2", "MiniMax-M1"):
self.assertNotIn(old, models)

def test_minimax_api_key_env(self):
self.assertEqual(PROVIDER_CONFIGS["minimax"]["api_key_env"], "MINIMAX_API_KEY")
Expand Down Expand Up @@ -82,6 +97,14 @@ def test_minimax_provider_flag(self):
args = self._parse(["--provider", "minimax"])
self.assertEqual(args.provider, "minimax")

def test_model_defaults_to_none(self):
args = self._parse(["--provider", "minimax"])
self.assertIsNone(args.model)

def test_model_override_flag(self):
args = self._parse(["--provider", "minimax", "--model", "MiniMax-M2.7"])
self.assertEqual(args.model, "MiniMax-M2.7")

def test_invalid_provider_raises(self):
with self.assertRaises(SystemExit):
self._parse(["--provider", "unknown_provider"])
Expand Down Expand Up @@ -142,11 +165,11 @@ def _make_payload(self, provider, model, content_list):
"max_tokens": 300,
}

def test_minimax_payload_uses_m27(self):
def test_minimax_payload_uses_m3(self):
cfg = PROVIDER_CONFIGS["minimax"]
content = [{"type": "text", "text": "hello"}]
payload = self._make_payload("minimax", cfg["model"], content)
self.assertEqual(payload["model"], "MiniMax-M2.7")
self.assertEqual(payload["model"], "MiniMax-M3")

def test_openai_payload_uses_gpt4v(self):
cfg = PROVIDER_CONFIGS["openai"]
Expand Down Expand Up @@ -186,7 +209,7 @@ def test_minimax_endpoint_is_called(self, mock_post):
mock_post.return_value = self._mock_response()
endpoint = PROVIDER_CONFIGS["minimax"]["base_url"]
headers = {"Authorization": "Bearer fake-key"}
payload = {"model": "MiniMax-M2.7", "messages": [], "max_tokens": 300}
payload = {"model": "MiniMax-M3", "messages": [], "max_tokens": 300}
import requests as req
req.post(endpoint, headers=headers, json=payload)
mock_post.assert_called_once_with(endpoint, headers=headers, json=payload)
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ cd $project_dir
python gpt4v_eval.py --category "color" --start 0 --step 10
```

##### MiniMax M2.7 (alternative to GPT-4V):
##### MiniMax M3 (alternative to GPT-4V):

[MiniMax M2.7](https://www.minimax.io) is a multimodal LLM with vision support and an OpenAI-compatible API, providing a cost-effective alternative to GPT-4V for evaluation. Use the `--provider minimax` flag:
[MiniMax M3](https://www.minimax.io) is a multimodal LLM with vision support and an OpenAI-compatible API, providing a cost-effective alternative to GPT-4V for evaluation. Use the `--provider minimax` flag:

```bash
export MINIMAX_API_KEY="your-minimax-api-key"
Expand All @@ -215,7 +215,7 @@ cd $project_dir
python gpt4v_eval.py --provider minimax --category "color" --start 0 --step 10
```

The `--provider` argument accepts `openai` (default, uses GPT-4V) or `minimax` (uses MiniMax-M2.7). The API key is read from `OPENAI_API_KEY` or `MINIMAX_API_KEY` respectively.
The `--provider` argument accepts `openai` (default, uses GPT-4V) or `minimax` (uses MiniMax-M3 by default). The API key is read from `OPENAI_API_KEY` or `MINIMAX_API_KEY` respectively. To use a previous MiniMax model instead, pass `--model MiniMax-M2.7` or `--model MiniMax-M2.7-highspeed`.

The output files are formatted as a json file named "gpt4v_result\_{start}\_{step}.json" in "examples/gpt4v" directory.

Expand Down