推理引擎#
Xinference 对于不同模型支持不同的推理引擎。用户选择模型后,Xinference 会自动选择合适的引擎
llama.cpp#
llama-cpp-python 是 llama.cpp 的 Python 接口。llama-cpp 是基于 tensor 库 ggml 开发的,支持 LLaMA 系列的大语言模型以及它的各种变种。
推荐用户手动安装 llama-cpp-python,根据当前使用的硬件,指定对应的编译选项以获得最好的推理性能。可以参考 llama-cpp-python 安装指南 。
transformers#
Transformers 支持绝大部分新出的模型。是 Pytorch 格式模型默认使用的引擎。
vLLM#
vLLM 是一个非常高效并且易用的大语言模型推理引擎。
vLLM 具有以下特点:
领先的推理吞吐量
使用 PagedAttention 高效管理注意力键和值记忆
对传入请求进行连续批处理
优化的 CUDA 内核
当满足以下条件时,Xinference 会自动选择 vLLM 作为推理引擎:
模型格式为
pytorch,gptq或者awq。当模型格式为
pytorch时,量化选项需为none。当模型格式为
awq时,量化选项需为Int4。当模型格式为
gptq时,量化选项需为Int3,Int4或Int8。操作系统为 Linux 并且至少有一个支持 CUDA 的设备
自定义模型的
model_family字段和内置模型的model_name字段在 vLLM 的支持列表中。
目前,支持的模型包括:
llama-2,llama-3,llama-3.1,llama-3.2-vision,llama-2-chat,llama-3-instruct,llama-3.1-instruct,llama-3.3-instructmistral-v0.1,mistral-instruct-v0.1,mistral-instruct-v0.2,mistral-instruct-v0.3,mistral-nemo-instruct,mistral-large-instructcodestral-v0.1Yi,Yi-1.5,Yi-chat,Yi-1.5-chat,Yi-1.5-chat-16kcode-llama,code-llama-python,code-llama-instructdeepseek,deepseek-coder,deepseek-chat,deepseek-coder-instruct,deepseek-v2-chat,deepseek-v2-chat-0628,deepseek-v2.5yi-coder,yi-coder-chatcodeqwen1.5,codeqwen1.5-chatqwen2.5,qwen2.5-coder,qwen2.5-instruct,qwen2.5-coder-instructbaichuan-2-chatinternlm2-chatinternlm2.5-chat,internlm2.5-chat-1mqwen-chatmixtral-instruct-v0.1,mixtral-8x22B-instruct-v0.1chatglm3,chatglm3-32k,chatglm3-128kglm4-chat,glm4-chat-1mcodegeex4qwen1.5-chat,qwen1.5-moe-chatqwen2-instruct,qwen2-moe-instructQwQ-32B-Previewgemma-it,gemma-2-itorion-chat,orion-chat-ragc4ai-command-r-v01minicpm3-4b
SGLang#
SGLang 具有基于 RadixAttention 的高性能推理运行时。它通过在多个调用之间自动重用KV缓存,显著加速了复杂 LLM 程序的执行。它还支持其他常见推理技术,如连续批处理和张量并行处理。
MLX#
MLX 提供在苹果 silicon 芯片上高效运行 LLM 的方式。在模型包含 MLX 格式的时候,推荐使用苹果 silicon 芯片的 Mac 用户使用 MLX 引擎。