mnn-llm

mnn-llm

llm deploy project based mnn.

Stars: 1429

Visit
 screenshot

MNN-LLM is a high-performance inference engine for large language models (LLMs) on mobile and embedded devices. It provides optimized implementations of popular LLM models, such as ChatGPT, BLOOM, and GPT-3, enabling developers to easily integrate these models into their applications. MNN-LLM is designed to be efficient and lightweight, making it suitable for resource-constrained devices. It supports various deployment options, including mobile apps, web applications, and embedded systems. With MNN-LLM, developers can leverage the power of LLMs to enhance their applications with natural language processing capabilities, such as text generation, question answering, and dialogue generation.

README:

mnn-llm

mnn-llm

License Download Documentation Status

English

示例工程

  • cli: 使用命令行编译,android编译参考android_build.sh
  • web: 使用命令行编译,运行时需要指定web资源
  • android: 使用Android Studio打开编译;
  • ios: 使用Xcode打开编译;🚀🚀🚀该示例代码100%由ChatGPT生成🚀🚀🚀
  • python: 对mnn-llm的python封装mnnllm
  • other: 新增文本embedding,向量查询,文本解析,记忆库与知识库能力🔥;

模型导出与下载

llm模型导出onnxmnn模型请使用llm-export

modelscope模型下载:

qwen
glm
llama
phi
embedding

构建

CI构建状态:

Build Status Build Status Build Status Build Status Build Status Build Status

本地编译

# clone
git clone --recurse-submodules https://github.com/wangzhaode/mnn-llm.git
cd mnn-llm

# linux
./script/build.sh

# macos
./script/build.sh

# windows msvc
./script/build.ps1

# python wheel
./script/py_build.sh

# android
./script/android_build.sh

# android apk
./script/android_app_build.sh

# ios
./script/ios_build.sh

一些编译宏:

  • BUILD_FOR_ANDROID: 编译到Android设备;
  • LLM_SUPPORT_VISION: 是否支持视觉处理能力;
  • DUMP_PROFILE_INFO: 每次对话后dump出性能数据到命令行中;

默认使用CPU,如果使用其他后端或能力,可以在编译MNN时添加MNN编译宏

  • cuda: -DMNN_CUDA=ON
  • opencl: -DMNN_OPENCL=ON
  • metal: -DMNN_METAL=ON

4. 执行

# linux/macos
./cli_demo ./Qwen2-1.5B-Instruct-MNN/config.json # cli demo
./web_demo ./Qwen2-1.5B-Instruct-MNN/config.json ../web # web ui demo

# windows
.\Debug\cli_demo.exe ./Qwen2-1.5B-Instruct-MNN/config.json
.\Debug\web_demo.exe ./Qwen2-1.5B-Instruct-MNN/config.json ../web

# android
adb push libs/*.so build/libllm.so build/cli_demo /data/local/tmp
adb push model_dir /data/local/tmp
adb shell "cd /data/local/tmp && export LD_LIBRARY_PATH=. && ./cli_demo ./Qwen2-1.5B-Instruct-MNN/config.json"

Reference

reference

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for mnn-llm

Similar Open Source Tools

For similar tasks

For similar jobs