LLM-Engines is a unified large language model inference engine that supports open-source models (VLLM, SGLang, Together) and commercial models (OpenAI, Mistral, Claude). It was developed by Dongfu Jiang to simplify the differences in invocation across different engines.
Main Capabilities
- Unified Interface: Call models from different engines through a consistent API.
- Correctness Verification: Compare outputs from different engines at temperature=0.0 and max_tokens=None to ensure consistency.
- Multi-turn Conversation: Supports multi-turn conversation messages in OpenAI format.
- Batch Inference: Supports the OpenAI Batch API, allowing for a half-price discount, and automatically caches requests to avoid duplication.
- Vision Input: All engines support vision input.
- Parallel Inference: Enables parallel inference across multiple models through the HuggingFace dataset map.
- Caching Mechanism: Caches queries and responses to avoid repeated requests; cache files are located in the generation_cache directory.
- Sleep Mode: Supports VLLM sleep mode to save GPU resources (requires vllm>=0.7.3).
Usage
- Installation: Using uv to manage the environment is recommended. If using SGLang, it must be installed separately.
- Load Model: Use the load_model function, specifying parameters such as model_name and engine.
- Generation: Use the call_model or batch_call_model function, passing in inputs and generation parameters.
- Unload Model: After use, unload it to release resources; by default, it is automatically unloaded when the program exits.
- Start Standalone Workers: vllm or sglang workers can be started separately, and multiple existing workers can be queried.
Applicable Scenarios
- Research that needs to compare output consistency across different engines.
- Scenarios that need to batch process a large number of queries and use caching to save costs.
- Applications that need multi-turn conversation or vision input.
- Scenarios that need parallel inference for multiple models.
Limitations
- Some engine outputs may be inconsistent; for example, SGLang is sometimes inconsistent with other engines.
- Certain abnormal inputs may cause the model to reason indefinitely; setting a timeout is recommended.
- vllm==0.5.4 has a bug when num_workers>1; using vllm==0.5.5 is recommended.
- Avoid loading the same OpenAI model using different cache directories, as this may cause confusion.
- The model must support chat templates, otherwise an error will occur.
Changelog
- 2025-03-03: Added support for sleep mode for vllm models.
- 2025-02-23: All engines support vision input.
- 2025-02-19: Added support for the fireworks API service, enabling high-speed calls to the deepseek-r1 model.
- 2025-02-18: Added support for the grok model.