Xinference 内置模型 InternLM3-8B-Instruct 全解析五种格式的启动与部署指南【免费下载链接】inferenceSwap GPT for any LLM by changing a single line of code. Xinference lets you run open-source, speech, and multimodal models on cloud, on-prem, or your laptop — all through one unified, production-ready inference API.项目地址: https://gitcode.com/GitHub_Trending/in/inference本文围绕 Xinference 内置的internlm3-instruct模型条目展开完整解读其五种模型规格pytorch / gptq / awq / ggufv2 / mlx的引擎、量化与启动命令并深入其源码级的注册信息对话模板、停止符、依赖解析帮助读者在统一推理 API 下快速、正确地拉起 InternLM3-8B-Instruct 并投入生产使用。读完本文你将掌握该模型在不同硬件与引擎条件下的完整选型思路和可复制的xinference launch命令行实践。模型速览internlm3-instruct 是什么InternLM3 开源了 8B 参数量的指令模型 InternLM3-8B-Instruct定位是通用场景与高级推理。在 Xinference 中它以内置模型builtin model的身份注册在internlm3-instruct名下模型能力与参数在 xinference/model/llm/llm_family.json 中集中维护核心元数据如下属性值Model Nameinternlm3-instructContext Length32768Languagesen, zhAbilitieschat, toolsArchitecturesInternLM3ForCausalLMmodel_typeinternlm3参数量8 Billion其中chat表示支持对话补全tools表示支持工具调用function calling配合 Xinference 的 OpenAI 兼容接口即可实现带工具的 Agent 式对话。32K 的上下文长度使其在处理长文档、多轮带工具的任务时具备充足窗口。该模型条目同时被收录在 doc/source/user_guide/backends.rst 的 vLLM 支持模型清单中也出现在 doc/source/getting_started/installation.rst 默认安装可用的模型列表里属于开箱即用的内置模型之一。五种模型规格逐一解析internlm3-instruct在 Xinference 中注册了 5 个 model spec分别对应不同的模型格式、量化方案与推理引擎。选型时只需在启动命令中替换${engine}与${quantization}两个变量。Spec 1pytorch 原版权重8BModel Format:pytorchModel Size:8 BillionQuantizations:noneEngines:vLLM, TransformersModel IDHugging Face:internlm/internlm3-8b-instructModel IDModelScope:Shanghai_AI_Laboratory/internlm3-8b-instructpytorch 格式是未经量化的原始权重精度最高适合拥有充足显存的 GPU 环境。启动命令为xinference launch --model-engine ${engine} --model-name internlm3-instruct \ --size-in-billions 8 --model-format pytorch --quantization ${quantization}其中${quantization}只能取none${engine}可取vllm或Transformers。示例xinference launch --model-engine vllm --model-name internlm3-instruct \ --size-in-billions 8 --model-format pytorch --quantization noneSpec 2gptq 量化8BModel Format:gptqModel Size:8 BillionQuantizations:Int4Engines:vLLM, TransformersModel IDHugging Face:internlm/internlm3-8b-instruct-gptq-int4Model IDModelScope:Shanghai_AI_Laboratory/internlm3-8b-instruct-gptq-int4GPTQ 是面向 GPU 的权重量化方案Int4 量化可将 8B 模型的显存占用显著降低。启动命令为xinference launch --model-engine ${engine} --model-name internlm3-instruct \ --size-in-billions 8 --model-format gptq --quantization ${quantization}这里${quantization}固定为Int4。示例xinference launch --model-engine vllm --model-name internlm3-instruct \ --size-in-billions 8 --model-format gptq --quantization Int4Spec 3awq 量化8BModel Format:awqModel Size:8 BillionQuantizations:Int4Engines:vLLM, TransformersModel IDHugging Face:internlm/internlm3-8b-instruct-awqModel IDModelScope:Shanghai_AI_Laboratory/internlm3-8b-instruct-awqAWQActivation-aware Weight Quantization同样提供 Int4 量化档位特点是保护对模型性能影响更大的重要权重通道量化后精度损失通常更小。启动命令xinference launch --model-engine ${engine} --model-name internlm3-instruct \ --size-in-billions 8 --model-format awq --quantization ${quantization}其中${quantization}取Int4。示例xinference launch --model-engine vllm --model-name internlm3-instruct \ --size-in-billions 8 --model-format awq --quantization Int4Spec 4ggufv2 量化8BModel Format:ggufv2Model Size:8 BillionQuantizations:q2_k, q3_k_m, q4_0, q4_k_m, q5_0, q5_k_m, q6_k, q8_0Engines:vLLM, llama.cppModel IDHugging Face:internlm/internlm3-8b-instruct-ggufModel IDModelScope:Shanghai_AI_Laboratory/internlm3-8b-instruct-ggufGGUF 格式是 llama.cpp 生态的标准权重格式量化档位最丰富覆盖从 q2_k极致压缩到 q8_0近无损共 8 档非常适合 CPU 推理或显存受限的环境。启动命令xinference launch --model-engine ${engine} --model-name internlm3-instruct \ --size-in-billions 8 --model-format ggufv2 --quantization ${quantization}例如xinference launch --model-engine llama.cpp --model-name internlm3-instruct \ --size-in-billions 8 --model-format ggufv2 --quantization q4_k_m值得说明的是GGUF 文件遵循internlm3-8b-instruct-{quantization}.gguf的命名模板见 xinference/model/llm/llm_family.json 中的model_file_name_template字段Xinference 会根据你传入的量化参数自动匹配并下载对应文件。Spec 5mlx 量化8BModel Format:mlxModel Size:8 BillionQuantizations:4bitEngines:MLXModel IDHugging Face:mlx-community/internlm3-8b-instruct-{quantization}Model IDModelScope:mlx-community/internlm3-8b-instruct-{quantization}MLX 是 Apple 芯片上的统一推理框架这一规格专为 macOSApple Silicon环境准备{quantization}占位符对应 4bit 量化。启动命令xinference launch --model-engine ${engine} --model-name internlm3-instruct \ --size-in-billions 8 --model-format mlx --quantization ${quantization}其中${engine}取MLX${quantization}取4bit。示例xinference launch --model-engine MLX --model-name internlm3-instruct \ --size-in-billions 8 --model-format mlx --quantization 4bit源码级解读llm_family.json 中的注册信息internlm3-instruct的内置元数据集中在 xinference/model/llm/llm_family.json 的第 8867 行附近除了上面 5 个 spec 的model_srcHugging Face 与 ModelScope 双源之外还包含以下直接影响推理行为的关键字段chat_template{{ bos_token }}{% for message in messages %}{{|im_start| message[role] \n message[content] |im_end| \n}}{% endfor %}{% if add_generation_prompt %}{{ |im_start|assistant\n }}{% endif %}即 InternLM3 使用的 ChatML 风格模板|im_start|/|im_end|包裹角色与内容。该模板会在模型启动时自动注入用户无需手工拼接 prompt。stop_token_ids[2, 128131]分别对应 EOS 与|im_end|的 token id用于生成终止判定。stop[/s, |im_end|]字符串级停止词与上面的 token id 相互配合确保输出在多轮对话中能正确收尾。architectures[InternLM3ForCausalLM]这是 vLLM 等引擎识别模型结构的关键标识。virtualenv.packages按引擎条件声明依赖例如#transformers_dependencies# ; #engine# Transformers、#llama_cpp_dependencies# ; #engine# llama.cpp、#mlx_dependencies# ; #engine# MLX、#vllm_dependencies# ; #engine# vllm并额外为 vLLM 引擎附带#system_numpy#。这意味着 Xinference 在启动时会根据你选择的引擎自动解析并安装对应的运行时依赖从模型注册层面保证引擎与依赖的匹配关系。从源码结构看xinference/model/llm/llm_family.py 负责将这些注册信息加载为LLMSpec并应用到后续的引擎创建流程内置模型的chat_template与停止符会直接随 spec 下发保证不同引擎vLLM / Transformers / llama.cpp / MLX在对话行为上保持一致。引擎支持与版本前提internlm3-instruct在不同格式下可选的引擎各不相同选型依据可概括为格式可用引擎pytorch / gptq / awqvLLM、Transformersggufv2vLLM、llama.cppmlxMLXvLLM高吞吐、连续批处理与 CUDA 内核优化适合 GPU 生产环境。在 xinference/model/llm/vllm/core.py 第 380-381 行可以看到InternLM3ForCausalLM从 vLLM 0.7.0 版本起被加入支持名单因此使用 vLLM 引擎时需保证依赖满足该版本前提同时 doc/source/user_guide/backends.rst 也明确将internlm3-instruct列入 vLLM 支持的内置模型清单。TransformersHugging Face 生态的通用引擎兼容性最好适合验证与调试。llama.cpp面向 GGUF 格式CPU/混合推理场景的首选。MLXApple Silicon 专属适合在 Mac 上本地运行。启动命令参数详解xinference launch是拉起模型的统一入口相关参数在 xinference/deploy/cmdline.py 中定义与本文模型相关的核心参数如下参数短选项说明--model-engine-en推理引擎如 vllm、Transformers、llama.cpp、MLX--model-name内置模型名此处为internlm3-instruct--size-in-billions-s模型参数量此处固定为8--model-format-f模型格式如 pytorch、gptq、awq、ggufv2、mlx--quantization-q量化档位随格式不同而不同--model-uid-u模型实例唯一标识默认自动生成多实例部署时建议显式指定--replica-r副本数默认 1用于水平扩展把五组命令归纳在一起即可得到一份完整的速查表# pytorch 原版无量化 xinference launch --model-engine vllm --model-name internlm3-instruct \ --size-in-billions 8 --model-format pytorch --quantization none # gptq Int4 xinference launch --model-engine vllm --model-name internlm3-instruct \ --size-in-billions 8 --model-format gptq --quantization Int4 # awq Int4 xinference launch --model-engine vllm --model-name internlm3-instruct \ --size-in-billions 8 --model-format awq --quantization Int4 # ggufv28 档量化可选此处以 q4_k_m 为例适合 CPU/llama.cpp xinference launch --model-engine llama.cpp --model-name internlm3-instruct \ --size-in-billions 8 --model-format ggufv2 --quantization q4_k_m # mlx 4bitApple Silicon xinference launch --model-engine MLX --model-name internlm3-instruct \ --size-in-billions 8 --model-format mlx --quantization 4bit启动后的调用方式模型启动成功后Xinference 会暴露 OpenAI 兼容的 RESTful API你可以用任何标准 OpenAI SDK 或curl直接调用internlm3-instruct的 chat 能力由于该模型支持tools还可在请求中携带tools与tool_choice参数实现工具调用这与 Xinference 统一的推理 API 设计一致——更换其他内置模型只需改动model字段即可。小结internlm3-instruct是 Xinference 内置的 8B 通用指令模型条目围绕它提供的五套模型规格覆盖了从 GPU 高精度推理pytorch、GPU 量化部署gptq / awq、跨平台轻量部署ggufv2 llama.cpp到 Apple 芯片本地运行MLX的全场景需求。配合 xinference/model/llm/llm_family.json 中内置的对话模板、停止符与按引擎解析的依赖声明用户只需用一条xinference launch命令即可获得与其余内置模型完全一致的统一推理体验。【免费下载链接】inferenceSwap GPT for any LLM by changing a single line of code. Xinference lets you run open-source, speech, and multimodal models on cloud, on-prem, or your laptop — all through one unified, production-ready inference API.项目地址: https://gitcode.com/GitHub_Trending/in/inference创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考