设备端模型中心 | 文档 | Discord | 博客 | X (Twitter)
Nexa SDK 是一个本地设备端推理框架,支持 ONNX 和 GGML 模型,具备文本生成、图像生成、视觉-语言模型 (VLM)、音频-语言模型、语音转文本 (ASR) 和文本转语音 (TTS) 等功能。可通过 Python 包或可执行安装程序安装。
nexa eval <model_path> --tasks gpqa --num_workers 8
nexa run omniVLM
和音频语言模型(2.9B 参数):nexa run omniaudio
nexa run qwen2audio
,我们是第一个支持使用 GGML 张量库的音频语言模型的开源工具包。nexa embed <model_path> <prompt>
nexa run -hf <hf_model_id> -mt COMPUTER_VISION
或 nexa run -ms <ms_model_id> -mt COMPUTER_VISION
nexa run -hf <hf_model_id> -mt NLP
或 nexa run -ms <ms_model_id> -mt NLP
欢迎通过 issues 提交您的请求,我们每周发布。
curl -fsSL https://public-storage.nexa4ai.com/install.sh | sh
尝试使用 nexa-exe
代替
nexa-exe <command>
我们已经发布了适用于各种 Python 版本、平台和后端的预构建 wheels,以便在我们索引页面上方便地安装。
pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/cpu --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于支持 Metal (macOS) 的 GPU 版本
CMAKE_ARGS="-DGGML_METAL=ON" pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/metal --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
尝试以下命令
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
conda create -n nexasdk python=3.10
conda activate nexasdk
CMAKE_ARGS="-DGGML_METAL=ON" pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/metal --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
要安装 CUDA 支持,请确保已安装 CUDA Toolkit 12.0 或更高版本。
对于 Linux
CMAKE_ARGS="-DGGML_CUDA=ON" pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/cu124 --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于 Windows PowerShell
$env:CMAKE_ARGS="-DGGML_CUDA=ON"; pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/cu124 --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于 Windows 命令提示符
set CMAKE_ARGS="-DGGML_CUDA=ON" & pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/cu124 --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于 Windows Git Bash
CMAKE_ARGS="-DGGML_CUDA=ON" pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/cu124 --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于 Windows
确保您已安装以下内容
.\scripts\windows-build-sycl.bat
要安装 ROCm 支持,请确保您已安装 ROCm 6.2.1 或更高版本。
对于 Linux
CMAKE_ARGS="-DGGML_HIPBLAS=on" pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/rocm621 --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
要安装 Vulkan 支持,请确保您已安装 Vulkan SDK 1.3.261.1 或更高版本。
对于 Windows PowerShell
$env:CMAKE_ARGS="-DGGML_VULKAN=on"; pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/vulkan --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于 Windows 命令提示符
set CMAKE_ARGS="-DGGML_VULKAN=on" & pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/vulkan --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
对于 Windows Git Bash
CMAKE_ARGS="-DGGML_VULKAN=on" pip install nexaai --prefer-binary --index-url https://github.nexa.ai/whl/vulkan --extra-index-url https://pypi.ac.cn/simple --no-cache-dir
如何克隆此 repo
git clone --recursive https://github.com/NexaAI/nexa-sdk
如果您忘记使用 --recursive
,可以使用以下命令添加子模块
git submodule update --init --recursive
然后您可以构建和安装软件包
pip install -e .
以下是我们与其他类似工具的差异化
特性 | Nexa SDK | ollama | Optimum | LM Studio |
---|---|---|---|---|
GGML 支持 | ✅ | ✅ | ❌ | ✅ |
ONNX 支持 | ✅ | ❌ | ✅ | ❌ |
文本生成 | ✅ | ✅ | ✅ | ✅ |
图像生成 | ✅ | ❌ | ❌ | ❌ |
视觉-语言模型 | ✅ | ✅ | ✅ | ✅ |
音频-语言模型 | ✅ | ❌ | ❌ | ❌ |
文本转语音 | ✅ | ❌ | ✅ | ❌ |
服务器能力 | ✅ | ✅ | ✅ | ✅ |
用户界面 | ✅ | ❌ | ❌ | ✅ |
可执行文件安装 | ✅ | ✅ | ❌ | ✅ |
我们的设备端模型中心提供所有类型的量化模型(文本、图像、音频、多模态),并具有 RAM、文件大小、任务等过滤器,以帮助您轻松探索 UI 模型。在 设备端模型中心 探索设备端模型
支持的模型示例(完整列表请参见 模型中心)
模型 | 类型 | 格式 | 命令 |
---|---|---|---|
omniaudio | AudioLM | GGUF | nexa run omniaudio |
qwen2audio | AudioLM | GGUF | nexa run qwen2audio |
octopus-v2 | 函数调用 | GGUF | nexa run octopus-v2 |
octo-net | 文本 | GGUF | nexa run octo-net |
omniVLM | 多模态 | GGUF | nexa run omniVLM |
nanollava | 多模态 | GGUF | nexa run nanollava |
llava-phi3 | 多模态 | GGUF | nexa run llava-phi3 |
llava-llama3 | 多模态 | GGUF | nexa run llava-llama3 |
llava1.6-mistral | 多模态 | GGUF | nexa run llava1.6-mistral |
llava1.6-vicuna | 多模态 | GGUF | nexa run llava1.6-vicuna |
llama3.2 | 文本 | GGUF | nexa run llama3.2 |
llama3-uncensored | 文本 | GGUF | nexa run llama3-uncensored |
gemma2 | 文本 | GGUF | nexa run gemma2 |
qwen2.5 | 文本 | GGUF | nexa run qwen2.5 |
mathqwen | 文本 | GGUF | nexa run mathqwen |
codeqwen | 文本 | GGUF | nexa run codeqwen |
mistral | 文本 | GGUF/ONNX | nexa run mistral |
deepseek-coder | 文本 | GGUF | nexa run deepseek-coder |
DeepSeek-R1-Distill-Qwen-1.5B | 文本 | GGUF | nexa run DeepSeek-R1-Distill-Qwen-1.5B:q4_K_M |
DeepSeek-R1-Distill-Llama-8B | 文本 | GGUF | nexa run DeepSeek-R1-Distill-Llama-8B:q4_K_M |
phi3.5 | 文本 | GGUF | nexa run phi3.5 |
openelm | 文本 | GGUF | nexa run openelm |
stable-diffusion-v2-1 | 图像生成 | GGUF | nexa run sd2-1 |
stable-diffusion-3-medium | 图像生成 | GGUF | nexa run sd3 |
FLUX.1-schnell | 图像生成 | GGUF | nexa run flux |
lcm-dreamshaper | 图像生成 | GGUF/ONNX | nexa run lcm-dreamshaper |
whisper-large-v3-turbo | 语音转文本 | BIN | nexa run faster-whisper-large-turbo |
whisper-tiny.en | 语音转文本 | ONNX | nexa run whisper-tiny.en |
mxbai-embed-large-v1 | Embedding | GGUF | nexa embed mxbai |
nomic-embed-text-v1.5 | Embedding | GGUF | nexa embed nomic |
all-MiniLM-L12-v2 | Embedding | GGUF | nexa embed all-MiniLM-L12-v2:fp16 |
bark-small | 文本转语音 | GGUF | nexa run bark-small:fp16 |
OuteTTS-0.1-350M | 文本转语音 | GGUF | nexa run OuteTTS-0.1-350M:q4_K_M |
OuteTTS-0.2-500M | 文本转语音 | GGUF | nexa run OuteTTS-0.2-500M:q4_K_M |
您可以使用 Nexa SDK 从 HF 或 MS 拉取、转换(为 .gguf)、量化和运行 llama.cpp 支持的 文本生成模型。
使用 nexa run -hf <hf-model-id>
或 nexa run -ms <ms-model-id>
运行带有提供的 .gguf 文件的模型
nexa run -hf Qwen/Qwen2.5-Coder-7B-Instruct-GGUF
nexa run -ms Qwen/Qwen2.5-Coder-7B-Instruct-GGUF
注意: 系统将提示您选择一个 .gguf 文件。如果您所需的量化版本有多个拆分文件(如 fp16-00001-of-00004),请使用 Nexa 的转换工具(见下文)在本地转换和量化模型。
安装 Nexa Python 包,并使用 pip install "nexaai[convert]"
安装 Nexa 转换工具,然后使用 nexa convert <hf-model-id>
从 huggingface 转换模型
nexa convert HuggingFaceTB/SmolLM2-135M-Instruct
或者您可以使用 nexa convert -ms <ms-model-id>
从 ModelScope 转换模型
nexa convert -ms Qwen/Qwen2.5-7B-Instruct
注意: 查看我们的 排行榜,了解主流语言模型的不同量化版本的性能基准,并查看 HuggingFace 文档,了解量化选项。
📋 您可以使用 nexa list
查看下载和转换的模型
注意
pip install nexaai
替换为 pip install "nexaai[onnx]"
。pip install nexaai
替换为 pip install "nexaai[eval]"
。pip install nexaai
替换为 pip install "nexaai[convert]"
。pip install nexaai
替换为 pip install nexaai[tts]
。--extra-index-url https://pypi.ac.cn/simple
替换为 --extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple
。以下是主要 CLI 命令的简要概述
nexa run
:使用 GGUF 模型运行各种任务的推理。nexa onnx
:使用 ONNX 模型运行各种任务的推理。nexa convert
:将 huggingface 模型转换和量化为 GGUF 模型。nexa server
:运行 Nexa AI 文本生成服务。nexa eval
:运行 Nexa AI 评估任务。nexa pull
:从官方或 hub 拉取模型。nexa remove
:从本地机器删除模型。nexa clean
:清理所有模型文件。nexa list
:列出本地机器中的所有模型。nexa login
:登录到 Nexa API。nexa whoami
:显示当前用户信息。nexa logout
:从 Nexa API 注销。有关 CLI 命令和用法的详细信息,请参阅 CLI 参考 文档。
要使用本地计算机上的模型启动本地服务器,您可以使用 nexa server
命令。有关服务器设置、API 端点和使用示例的详细信息,请参阅 服务器参考 文档。
安装 Nexa Python 包,并使用 pip install "nexaai[eval]"
安装 Nexa 基准测试工具,然后使用以下命令评估模型的基准:
nexa eval <model_path> --tasks <task> --num_workers <num_workers>
Swift SDK: 提供了一个 Swifty API,允许 Swift 开发人员轻松地在其项目中集成和使用 llama.cpp 模型。
我们要感谢以下项目: