Principle:Open compass VLMEvalKit API Model Adapter Pattern
| Field | Value |
|---|---|
| source | VLMEvalKit|https://github.com/open-compass/VLMEvalKit |
| domain | Vision, Model_Architecture, API_Integration |
| last_updated | 2026-02-14 00:00 GMT |
Overview
An adapter pattern with retry-based fault tolerance for wrapping diverse commercial VLM API endpoints behind a common interface.
Description
VLMEvalKit defines BaseAPI as the abstract base class for all API model wrappers (GPT-4o, Claude, Gemini, etc.). It extends the adapter concept with:
- Automatic retry logic with exponential backoff
- Random delay between requests to avoid rate limiting
- Configurable failure messages
- System prompt management
The generate() method preprocesses messages, then calls generate_inner() (returns tuple of ret_code, answer, log) up to retry times. chat() provides multi-turn support with automatic conversation truncation on failure.
Usage
Use when integrating a new API-based VLM into VLMEvalKit. Subclass BaseAPI, implement generate_inner(inputs, **kwargs) which must return (ret_code, answer, log) tuple where 0 means success.
Theoretical Basis
Adapter pattern with retry/backoff — wraps HTTP API differences behind a common interface while handling transient failures. The retry mechanism uses randomized delays to avoid thundering herd.