推理引擎#
Xinference 对于不同模型支持不同的推理引擎。用户选择模型后,Xinference 会自动选择合适的引擎
llama.cpp#
Xinference 目前支持由 Xinference 团队开发的 xllamacpp 以及 llama-cpp-python 作为 llama.cpp 后端运行。llama.cpp 基于张量库 ggml 开发,支持 LLaMA 系列模型及其变体的推理。
警告
在即将发布的 Xinference v1.5.0 中,xllamacpp 将成为 llama.cpp 的默认选项,而 llama-cpp-python 将被弃用。到 Xinference v1.6.0 时,llama-cpp-python 将被移除。
对于 llama-cpp-python,我们建议用户自行在 worker 上安装,并根据硬件调整 cmake 参数,以获得最佳推理效率。请参考 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-r1-distill-qwen,deepseek-v2-chat,deepseek-v2-chat-0628,deepseek-v2.5,deepseek-v3,deepseek-r1,deepseek-r1-distill-llamayi-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-Preview,QwQ-32Bmarco-o1gemma-it,gemma-2-itorion-chat,orion-chat-ragc4ai-command-r-v01minicpm3-4binternlm3-instructmoonlight-16b-a3b-instruct
SGLang#
SGLang 具有基于 RadixAttention 的高性能推理运行时。它通过在多个调用之间自动重用KV缓存,显著加速了复杂 LLM 程序的执行。它还支持其他常见推理技术,如连续批处理和张量并行处理。
MLX#
MLX 提供在苹果 silicon 芯片上高效运行 LLM 的方式。在模型包含 MLX 格式的时候,推荐使用苹果 silicon 芯片的 Mac 用户使用 MLX 引擎。