├── .github └── workflows │ ├── android.yml │ ├── ios.yml │ ├── linux.yml │ ├── macos.yml │ ├── python.yml │ ├── stale.yml │ └── windows.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yaml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── README_en.md ├── android ├── .idea │ └── compiler.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── ic_launcher-playstore.png │ │ ├── java │ │ └── com │ │ │ └── mnn │ │ │ └── llm │ │ │ ├── BaseActivity.java │ │ │ ├── Chat.java │ │ │ ├── Common.java │ │ │ ├── Conversation.java │ │ │ └── MainActivity.java │ │ ├── jni │ │ └── llm_mnn_jni.cpp │ │ └── res │ │ ├── drawable-hdpi │ │ ├── ic_action_add.png │ │ ├── ic_action_back.png │ │ ├── ic_action_chats.png │ │ ├── ic_action_contacts.png │ │ ├── ic_action_edit_icon.png │ │ ├── ic_action_logout.png │ │ ├── ic_action_settings.png │ │ └── ic_action_trash.png │ │ ├── drawable-mdpi │ │ ├── ic_action_add.png │ │ ├── ic_action_back.png │ │ ├── ic_action_chats.png │ │ ├── ic_action_contacts.png │ │ ├── ic_action_edit_icon.png │ │ ├── ic_action_logout.png │ │ ├── ic_action_settings.png │ │ └── ic_action_trash.png │ │ ├── drawable-nodpi │ │ └── logo.png │ │ ├── drawable-v21 │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ └── ic_menu_slideshow.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable-xhdpi │ │ ├── ic_action_add.png │ │ ├── ic_action_back.png │ │ ├── ic_action_chats.png │ │ ├── ic_action_contacts.png │ │ ├── ic_action_edit_icon.png │ │ ├── ic_action_logout.png │ │ ├── ic_action_settings.png │ │ └── ic_action_trash.png │ │ ├── drawable-xxhdpi │ │ ├── ic_action_add.png │ │ ├── ic_action_back.png │ │ ├── ic_action_chats.png │ │ ├── ic_action_contacts.png │ │ ├── ic_action_edit_icon.png │ │ ├── ic_action_logout.png │ │ ├── ic_action_settings.png │ │ └── ic_action_trash.png │ │ ├── drawable-xxxhdpi │ │ ├── ic_action_add.png │ │ ├── ic_action_back.png │ │ ├── ic_action_chats.png │ │ ├── ic_action_contacts.png │ │ ├── ic_action_edit_icon.png │ │ ├── ic_action_logout.png │ │ ├── ic_action_settings.png │ │ └── ic_action_trash.png │ │ ├── drawable │ │ ├── bg_bottom_grey.xml │ │ ├── bg_chat_me.xml │ │ ├── bg_chat_you.xml │ │ ├── bg_gradient.xml │ │ ├── bg_item_list.xml │ │ ├── bg_online.xml │ │ ├── bg_top_grey.xml │ │ ├── bg_unread.xml │ │ ├── bg_white_rounded.xml │ │ ├── btn_grey.xml │ │ ├── btn_pink.xml │ │ ├── checkbox.xml │ │ ├── ic_arrow_right.xml │ │ ├── ic_attachment.xml │ │ ├── ic_clock.xml │ │ ├── ic_image.xml │ │ ├── ic_menu.xml │ │ ├── ic_radio.xml │ │ ├── ic_radio_checked.xml │ │ ├── ic_trash.xml │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── activity_conversation.xml │ │ ├── activity_main.xml │ │ ├── app_bar_main.xml │ │ ├── content_conversation.xml │ │ ├── content_main.xml │ │ ├── layout_holder_date.xml │ │ ├── layout_holder_me.xml │ │ ├── layout_holder_you.xml │ │ └── toolbar.xml │ │ ├── menu │ │ ├── main.xml │ │ ├── menu_add.xml │ │ ├── menu_drawer.xml │ │ ├── menu_drawer_bottom.xml │ │ ├── menu_edit.xml │ │ └── menu_userphoto.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-hdpi │ │ └── dimens.xml │ │ ├── values-mdpi │ │ └── dimens.xml │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ ├── values-xhdpi │ │ └── dimens.xml │ │ ├── values-xxhdpi │ │ └── dimens.xml │ │ ├── values-xxxhdpi │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── demo ├── README.md ├── cli_demo.cpp ├── embedding_demo.cpp ├── tokenizer_demo.cpp └── web_demo.cpp ├── docs ├── Makefile ├── README ├── _static │ └── style.css ├── about.md ├── compile.md ├── conf.py ├── cpp_api.md ├── demo.md ├── download.md ├── export.md ├── faq.md ├── index.rst ├── llm_config.md ├── make.bat ├── python_api.md ├── requirements.txt ├── run.md └── run_config.md ├── include ├── httplib.h ├── llm.hpp └── tokenizer.hpp ├── ios ├── README.md ├── ios_app.jpg └── mnn-llm │ ├── icon.png │ ├── mnn-llm.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── wangzhaode.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── wangzhaode.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist │ └── mnn-llm │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ └── icon.png │ └── Contents.json │ ├── ContentView.swift │ ├── LLMInferenceEngineWrapper.h │ ├── LLMInferenceEngineWrapper.mm │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ ├── mnn-llm-Bridging-Header.h │ └── mnn_llmApp.swift ├── python ├── README.md ├── cmmlu │ └── qwen.py ├── mnnllm.cpp ├── mnnllm │ └── __init__.py ├── pymnn_llm.py ├── setup.py └── test.py ├── resource ├── android_demo.png ├── bench.txt ├── config.json ├── logo.png ├── memory_demo.json ├── prompt.txt ├── template_config.json └── win_pthreads.zip ├── script ├── android_app_build.sh ├── android_build.sh ├── build.ps1 ├── build.sh ├── ios_build.sh └── py_build.sh ├── src ├── llm.cpp ├── llmconfig.hpp └── tokenizer.cpp ├── watchos └── mnn-llm │ ├── mnn-llm Watch App │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── ContentView.swift │ ├── LLMInferenceEngineWrapper.h │ ├── LLMInferenceEngineWrapper.mm │ ├── Preview Content │ │ └── Preview Assets.xcassets │ │ │ └── Contents.json │ ├── mnn-llm-Bridging-Header.h │ └── mnn_llmApp.swift │ └── mnn-llm.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── wangzhaode.xcuserdatad │ │ ├── Bookmarks │ │ └── bookmarks.plist │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── wangzhaode.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist └── web ├── css ├── github-markdown-light.min.css ├── github.min.css ├── katex.min.css └── texmath.css ├── index.html └── js ├── highlight.min.js ├── katex.min.js ├── markdown-it-link-attributes.min.js ├── markdown-it.min.js └── texmath.js /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: android 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - 'feature/**' 7 | paths: 8 | - 'src/**' 9 | - 'android/**' 10 | - '.github/workflows/android-build.yml' 11 | pull_request: 12 | branches: [master] 13 | paths: 14 | - 'src/**' 15 | - 'android/**' 16 | - '.github/workflows/android-build.yml' 17 | 18 | concurrency: 19 | group: android-${{ github.ref }} 20 | cancel-in-progress: true 21 | permissions: 22 | contents: read 23 | 24 | jobs: 25 | android_adb_build: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v3 29 | with: 30 | submodules: 'recursive' 31 | - name: build 32 | run: ./script/android_build.sh 33 | 34 | android_app_build: 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v3 38 | with: 39 | submodules: 'recursive' 40 | - name: build 41 | run: ./script/android_app_build.sh 42 | 43 | -------------------------------------------------------------------------------- /.github/workflows/ios.yml: -------------------------------------------------------------------------------- 1 | name: ios 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - 'feature/**' 7 | paths: 8 | - 'src/**' 9 | - 'ios/**' 10 | - '.github/workflows/ios.yml' 11 | pull_request: 12 | branches: [master] 13 | paths: 14 | - 'src/**' 15 | - 'ios/**' 16 | - '.github/workflows/ios.yml' 17 | 18 | jobs: 19 | build: 20 | name: ios-build 21 | runs-on: macos-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | with: 26 | submodules: 'recursive' 27 | 28 | - name: download_mode 29 | run: | 30 | wget -c -nv https://github.com/wangzhaode/mnn-llm/releases/download/qwen1.5-0.5b-chat-mnn/Qwen1.5-0.5B-Chat-MNN.zip 31 | unzip Qwen1.5-0.5B-Chat-MNN.zip 32 | mv Qwen1.5-0.5B-Chat-MNN/* ios/mnn-llm/model/qwen1.5-0.5b-chat/ 33 | 34 | - name: build 35 | run: | 36 | ./script/ios_build.sh -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: linux 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - 'feature/**' 7 | paths: 8 | - 'src/**' 9 | - '.github/workflows/linux.yml' 10 | pull_request: 11 | branches: [master] 12 | paths: 13 | - 'src/**' 14 | - '.github/workflows/linux.yml' 15 | 16 | jobs: 17 | build: 18 | name: linux-build 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | with: 24 | submodules: 'recursive' 25 | 26 | - name: build 27 | run: ./script/build.sh 28 | 29 | - name: download_mode 30 | run: | 31 | wget -c -nv https://github.com/wangzhaode/mnn-llm/releases/download/qwen1.5-0.5b-chat-mnn/Qwen1.5-0.5B-Chat-MNN.zip 32 | unzip Qwen1.5-0.5B-Chat-MNN.zip 33 | 34 | - name: test_model 35 | run: | 36 | cd build 37 | ./cli_demo ../Qwen1.5-0.5B-Chat-MNN/config.json ../resource/prompt.txt 38 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macos 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - 'feature/**' 7 | paths: 8 | - 'src/**' 9 | - '.github/workflows/macos.yml' 10 | pull_request: 11 | branches: [master] 12 | paths: 13 | - 'src/**' 14 | - '.github/workflows/macos.yml' 15 | 16 | jobs: 17 | build: 18 | name: macos-build 19 | runs-on: macos-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | with: 24 | submodules: 'recursive' 25 | 26 | - name: build 27 | run: ./script/build.sh 28 | 29 | - name: download_mode 30 | run: | 31 | wget -c -nv https://github.com/wangzhaode/mnn-llm/releases/download/qwen1.5-0.5b-chat-mnn/Qwen1.5-0.5B-Chat-MNN.zip 32 | unzip Qwen1.5-0.5B-Chat-MNN.zip 33 | 34 | - name: test_model 35 | run: | 36 | cd build 37 | ./cli_demo ../Qwen1.5-0.5B-Chat-MNN/config.json ../resource/prompt.txt -------------------------------------------------------------------------------- /.github/workflows/python.yml: -------------------------------------------------------------------------------- 1 | name: python 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - 'feature/**' 7 | paths: 8 | - 'src/**' 9 | - 'python/**' 10 | - '.github/workflows/python.yml' 11 | pull_request: 12 | branches: [master] 13 | paths: 14 | - 'src/**' 15 | - 'python/**' 16 | - '.github/workflows/python.yml' 17 | 18 | jobs: 19 | build: 20 | name: python-build 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | with: 26 | submodules: 'recursive' 27 | 28 | - uses: s-weigand/setup-conda@v1 29 | 30 | - name: build 31 | run: ./script/py_build.sh 32 | 33 | - name: download_mode 34 | run: | 35 | wget -c -nv https://github.com/wangzhaode/mnn-llm/releases/download/qwen1.5-0.5b-chat-mnn/Qwen1.5-0.5B-Chat-MNN.zip 36 | unzip Qwen1.5-0.5B-Chat-MNN.zip 37 | 38 | - name: test_model 39 | run: | 40 | conda install -c conda-forge gcc=12.1.0 41 | cd python 42 | pip install dist/*.whl 43 | python test.py ../Qwen1.5-0.5B-Chat-MNN/config.json 44 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: stale 2 | 3 | on: 4 | schedule: 5 | - cron: '20 9 * * *' 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | steps: 16 | - uses: actions/stale@v5 17 | with: 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | days-before-stale: 30 20 | stale-issue-message: 'Marking as stale. No activity in 30 days.' 21 | stale-pr-message: 'Marking as stale. No activity in 30 days.' 22 | stale-issue-label: 'stale' 23 | stale-pr-label: 'stale' 24 | remove-stale-when-updated: true 25 | operations-per-run: 1000 26 | days-before-close: 1 27 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: windows 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - 'feature/**' 7 | paths: 8 | - 'src/**' 9 | - '.github/workflows/windows.yml' 10 | pull_request: 11 | branches: [master] 12 | paths: 13 | - 'src/**' 14 | - '.github/workflows/windows.yml' 15 | 16 | jobs: 17 | build: 18 | name: windows-build 19 | runs-on: windows-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | with: 24 | submodules: 'recursive' 25 | 26 | - name: build 27 | run: .\script\build.ps1 28 | 29 | - name: download_mode 30 | run: | 31 | Invoke-WebRequest -Uri https://github.com/wangzhaode/mnn-llm/releases/download/qwen1.5-0.5b-chat-mnn/Qwen1.5-0.5B-Chat-MNN.zip -OutFile Qwen1.5-0.5B-Chat-MNN.zip 32 | unzip Qwen1.5-0.5B-Chat-MNN.zip 33 | 34 | - name: test_model 35 | run: | 36 | cd build 37 | .\Release\cli_demo ..\Qwen1.5-0.5B-Chat-MNN\config.json ..\resource\prompt.txt 38 | Exit 0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore dirs 2 | build/ 3 | .vscode/ 4 | .cached/ 5 | .cache/ 6 | libs/ 7 | Debug/ 8 | Release 9 | include/pthread.h 10 | include/sched.h 11 | include/semaphore.h 12 | docs/_build/ 13 | 14 | # ignore files 15 | .DS_Store 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "MNN"] 2 | path = MNN 3 | url = https://github.com/alibaba/MNN.git 4 | shallow = true 5 | 6 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | # Required 5 | version: 2 6 | 7 | # Set the OS, Python version and other tools you might need 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.12" 12 | # You can also specify other tool versions: 13 | # nodejs: "20" 14 | # rust: "1.70" 15 | # golang: "1.20" 16 | 17 | # Build documentation in the "docs/" directory with Sphinx 18 | sphinx: 19 | configuration: docs/conf.py 20 | # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs 21 | # builder: "dirhtml" 22 | # Fail on all warnings to avoid broken references 23 | # fail_on_warning: true 24 | 25 | # Optionally build your docs in additional formats such as PDF and ePub 26 | # formats: 27 | # - pdf 28 | # - epub 29 | 30 | # Optional but recommended, declare the Python requirements required 31 | # to build your documentation 32 | # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 33 | python: 34 | install: 35 | - requirements: docs/requirements.txt 36 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(mnn-llm) 3 | 4 | option(BUILD_FOR_ANDROID "Build for android whith mini memory mode." OFF) 5 | option(LLM_SUPPORT_VISION "Llm model support vision input." OFF) 6 | option(DUMP_PROFILE_INFO "Dump profile info when chat." OFF) 7 | option(BUILD_JNI "Build JNI for android app." OFF) 8 | 9 | if (DUMP_PROFILE_INFO) 10 | add_definitions(-DDUMP_PROFILE_INFO) 11 | endif() 12 | 13 | if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 15 | endif() 16 | 17 | # compile MNN first 18 | set(MNN_LOW_MEMORY ON CACHE BOOL "Open MNN_LOW_MEMORY" FORCE) 19 | set(MNN_SUPPORT_TRANSFORMER_FUSE ON CACHE BOOL "Open MNN_SUPPORT_TRANSFORMER_FUSE" FORCE) 20 | if (BUILD_FOR_ANDROID) 21 | set(MNN_ARM82 ON CACHE BOOL "Open MNN_ARM82" FORCE) 22 | endif() 23 | if (LLM_SUPPORT_VISION) 24 | add_definitions(-DLLM_SUPPORT_VISION) 25 | set(MNN_BUILD_OPENCV ON CACHE BOOL "Open MNN_BUILD_OPENCV" FORCE) 26 | set(MNN_IMGCODECS ON CACHE BOOL "Open MNN_IMGCODECS" FORCE) 27 | endif() 28 | 29 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/MNN) 30 | 31 | # include dir 32 | include_directories(${CMAKE_CURRENT_LIST_DIR}/include/ 33 | ${CMAKE_CURRENT_LIST_DIR}/MNN/include/ 34 | ${CMAKE_CURRENT_LIST_DIR}/MNN/tools/cv/include/ 35 | ${CMAKE_CURRENT_LIST_DIR}/MNN/3rd_party/ 36 | ${CMAKE_CURRENT_LIST_DIR}/MNN/tools/ 37 | ) 38 | 39 | # source files 40 | FILE(GLOB SRCS ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp) 41 | 42 | # jni file 43 | if (BUILD_JNI) 44 | list(APPEND SRCS "${CMAKE_CURRENT_LIST_DIR}/android/app/src/main/jni/llm_mnn_jni.cpp") 45 | endif() 46 | 47 | if (MSVC) 48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11") 49 | add_compile_options("$<$:/source-charset:utf-8>") 50 | # compile static lib, surrpot Winwows 51 | add_library(llm STATIC ${SRCS}) 52 | link_directories(${CMAKE_BINARY_DIR}/MNN/Release) 53 | target_link_libraries(llm MNN.lib) 54 | else() 55 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 56 | # compile dynamic so, support Linux/Mac 57 | add_library(llm SHARED ${SRCS}) 58 | set_target_properties(llm PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) 59 | 60 | target_link_libraries(llm MNN MNN_Express) 61 | if (MNN_OPENCL) 62 | target_link_libraries(llm MNN_CL) 63 | endif() 64 | if (LLM_SUPPORT_VISION) 65 | target_link_libraries(llm MNNOpenCV) 66 | endif() 67 | endif() 68 | 69 | if (NOT (BUILD_JNI)) 70 | 71 | add_executable(cli_demo ${CMAKE_CURRENT_LIST_DIR}/demo/cli_demo.cpp) 72 | add_executable(tokenizer_demo ${CMAKE_CURRENT_LIST_DIR}/demo/tokenizer_demo.cpp) 73 | add_executable(embedding_demo ${CMAKE_CURRENT_LIST_DIR}/demo/embedding_demo.cpp) 74 | 75 | if (BUILD_FOR_ANDROID) 76 | # add_library(MNN SHARED IMPORTED) 77 | # add_library(MNN_Express SHARED IMPORTED) 78 | set_target_properties( 79 | MNN 80 | PROPERTIES IMPORTED_LOCATION 81 | ${CMAKE_CURRENT_LIST_DIR}/libs/libMNN.so 82 | ) 83 | set_target_properties( 84 | MNN_Express 85 | PROPERTIES IMPORTED_LOCATION 86 | ${CMAKE_CURRENT_LIST_DIR}/libs/libMNN_Express.so 87 | ) 88 | target_link_libraries(cli_demo llm log) 89 | target_link_libraries(tokenizer_demo llm log) 90 | target_link_libraries(embedding_demo llm log) 91 | else() 92 | target_link_libraries(cli_demo llm) 93 | target_link_libraries(tokenizer_demo llm) 94 | target_link_libraries(embedding_demo llm) 95 | # web demo 96 | add_executable(web_demo ${CMAKE_CURRENT_LIST_DIR}/demo/web_demo.cpp) 97 | if (MSVC) 98 | target_link_libraries(web_demo llm pthreadVC2) 99 | add_custom_command( 100 | TARGET cli_demo POST_BUILD 101 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 102 | ${CMAKE_SOURCE_DIR}/build/MNN/Release/MNN.dll 103 | $ 104 | ) 105 | else() 106 | target_link_libraries(web_demo llm pthread) 107 | endif() 108 | endif() 109 | else() 110 | set(LLM_LIBS "") 111 | list(APPEND LLM_LIBS $) 112 | list(APPEND LLM_LIBS $) 113 | if (LLM_SUPPORT_VISION) 114 | #list(APPEND LLM_LIBS $) 115 | endif() 116 | if (MNN_OPENCL) 117 | list(APPEND LLM_LIBS $) 118 | endif() 119 | add_custom_command(TARGET llm POST_BUILD 120 | COMMAND ${CMAKE_COMMAND} -E copy 121 | ${LLM_LIBS} 122 | ${CMAKE_CURRENT_LIST_DIR}/android/app/src/main/jni/libs/arm64-v8a) 123 | endif() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![mnn-llm](resource/logo.png) 2 | 3 | # mnn-llm 4 | [![License](https://img.shields.io/github/license/wangzhaode/mnn-llm)](LICENSE.txt) 5 | [![Download](https://img.shields.io/github/downloads/wangzhaode/mnn-llm/total)](https://github.com/wangzhaode/mnn-llm/releases) 6 | [![Documentation Status](https://readthedocs.org/projects/mnn-llm/badge/?version=latest)](https://mnn-llm.readthedocs.io/en/latest/?badge=latest) 7 | 8 | 9 | [English](./README_en.md) 10 | 11 | **该项目代码已经Merge到[MNN](https://github.com/alibaba/MNN/tree/master/transformers/llm).** 12 | 13 | ## 示例工程 14 | 15 | - [cli](./demo/cli_demo.cpp): 使用命令行编译,android编译参考[android_build.sh](./script/android_build.sh) 16 | - [web](./demo/web_demo.cpp): 使用命令行编译,运行时需要指定[web资源](./web) 17 | - [android](./android/): 使用Android Studio打开编译; 18 | - [ios](./ios/README.md): 使用Xcode打开编译;🚀🚀🚀**该示例代码100%由ChatGPT生成**🚀🚀🚀 19 | - [python](./python/README.md): 对mnn-llm的python封装`mnnllm`; 20 | - [other](./demo): 新增文本embedding; 21 | 22 | ## 模型导出与下载 23 | 24 | llm模型导出`onnx`和`mnn`模型请使用[llm-export](https://github.com/wangzhaode/llm-export) 25 | 26 | [模型下载](./docs/download.md) 27 | 28 | 29 | ## 构建 30 | 31 | CI构建状态: 32 | 33 | [![Build Status][pass-linux]][ci-linux] 34 | [![Build Status][pass-macos]][ci-macos] 35 | [![Build Status][pass-windows]][ci-windows] 36 | [![Build Status][pass-android]][ci-android] 37 | [![Build Status][pass-ios]][ci-ios] 38 | [![Build Status][pass-python]][ci-python] 39 | 40 | [pass-linux]: https://github.com/wangzhaode/mnn-llm/actions/workflows/linux.yml/badge.svg 41 | [pass-macos]: https://github.com/wangzhaode/mnn-llm/actions/workflows/macos.yml/badge.svg 42 | [pass-windows]: https://github.com/wangzhaode/mnn-llm/actions/workflows/windows.yml/badge.svg 43 | [pass-android]: https://github.com/wangzhaode/mnn-llm/actions/workflows/android.yml/badge.svg 44 | [pass-ios]: https://github.com/wangzhaode/mnn-llm/actions/workflows/ios.yml/badge.svg 45 | [pass-python]: https://github.com/wangzhaode/mnn-llm/actions/workflows/python.yml/badge.svg 46 | [ci-linux]: https://github.com/wangzhaode/mnn-llm/actions/workflows/linux.yml 47 | [ci-macos]: https://github.com/wangzhaode/mnn-llm/actions/workflows/macos.yml 48 | [ci-windows]: https://github.com/wangzhaode/mnn-llm/actions/workflows/windows.yml 49 | [ci-android]: https://github.com/wangzhaode/mnn-llm/actions/workflows/android.yml 50 | [ci-ios]: https://github.com/wangzhaode/mnn-llm/actions/workflows/ios.yml 51 | [ci-python]: https://github.com/wangzhaode/mnn-llm/actions/workflows/python.yml 52 | 53 | ### 本地编译 54 | ``` 55 | # clone 56 | git clone --recurse-submodules https://github.com/wangzhaode/mnn-llm.git 57 | cd mnn-llm 58 | 59 | # linux 60 | ./script/build.sh 61 | 62 | # macos 63 | ./script/build.sh 64 | 65 | # windows msvc 66 | ./script/build.ps1 67 | 68 | # python wheel 69 | ./script/py_build.sh 70 | 71 | # android 72 | ./script/android_build.sh 73 | 74 | # android apk 75 | ./script/android_app_build.sh 76 | 77 | # ios 78 | ./script/ios_build.sh 79 | ``` 80 | 81 | 一些编译宏: 82 | - `BUILD_FOR_ANDROID`: 编译到Android设备; 83 | - `LLM_SUPPORT_VISION`: 是否支持视觉处理能力; 84 | - `DUMP_PROFILE_INFO`: 每次对话后dump出性能数据到命令行中; 85 | 86 | 默认使用`CPU`,如果使用其他后端或能力,可以在编译MNN时添加`MNN`编译宏 87 | - cuda: `-DMNN_CUDA=ON` 88 | - opencl: `-DMNN_OPENCL=ON` 89 | - metal: `-DMNN_METAL=ON` 90 | 91 | ### 4. 执行 92 | 93 | ```bash 94 | # linux/macos 95 | ./cli_demo ./Qwen2-1.5B-Instruct-MNN/config.json # cli demo 96 | ./web_demo ./Qwen2-1.5B-Instruct-MNN/config.json ../web # web ui demo 97 | 98 | # windows 99 | .\Debug\cli_demo.exe ./Qwen2-1.5B-Instruct-MNN/config.json 100 | .\Debug\web_demo.exe ./Qwen2-1.5B-Instruct-MNN/config.json ../web 101 | 102 | # android 103 | adb push android_build/MNN/OFF/arm64-v8a/libMNN.so /data/local/tmp 104 | adb push android_build/MNN/express/OFF/arm64-v8a/libMNN_Express.so /data/local/tmp 105 | adb push android_build/libllm.so android_build/cli_demo /data/local/tmp 106 | adb push Qwen2-1.5B-Instruct-MNN /data/local/tmp 107 | adb shell "cd /data/local/tmp && export LD_LIBRARY_PATH=. && ./cli_demo ./Qwen2-1.5B-Instruct-MNN/config.json" 108 | ``` 109 | 110 | 111 | ## Reference 112 |
113 | reference 114 | 115 | - [cpp-httplib](https://github.com/yhirose/cpp-httplib) 116 | - [chatgpt-web](https://github.com/xqdoo00o/chatgpt-web) 117 | - [ChatViewDemo](https://github.com/BrettFX/ChatViewDemo) 118 | - [nlohmann/json](https://github.com/nlohmann/json) 119 | - [Qwen-1.8B-Chat](https://modelscope.cn/models/qwen/Qwen-1_8B-Chat/summary) 120 | - [Qwen-7B-Chat](https://modelscope.cn/models/qwen/Qwen-7B-Chat/summary) 121 | - [Qwen-VL-Chat](https://modelscope.cn/models/qwen/Qwen-VL-Chat/summary) 122 | - [Qwen1.5-0.5B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat/summary) 123 | - [Qwen1.5-1.8B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-1.8B-Chat/summary) 124 | - [Qwen1.5-4B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-4B-Chat/summary) 125 | - [Qwen1.5-7B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-7B-Chat/summary) 126 | - [Qwen2-0.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2-0.5B-Instruct/summary) 127 | - [Qwen2-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2-1.5B-Instruct/summary) 128 | - [Qwen2-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2-7B-Instruct/summary) 129 | - [Qwen2-VL-2B-Instruct](https://modelscope.cn/models/qwen/Qwen2-VL-2B-Instruct/summary) 130 | - [Qwen2-VL-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2-VL-7B-Instruct/summary) 131 | - [Qwen2.5-0.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-0.5B-Instruct/summary) 132 | - [Qwen2.5-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-1.5B-Instruct/summary) 133 | - [Qwen2.5-3B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-3B-Instruct/summary) 134 | - [Qwen2.5-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-7B-Instruct/summary) 135 | - [Qwen2.5-Coder-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Coder-1.5B-Instruct/summary) 136 | - [Qwen2.5-Coder-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Coder-7B-Instruct/summary) 137 | - [Qwen2.5-Math-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Math-1.5B-Instruct/summary) 138 | - [Qwen2.5-Math-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Math-7B-Instruct/summary) 139 | - [chatglm-6b](https://modelscope.cn/models/ZhipuAI/chatglm-6b/summary) 140 | - [chatglm2-6b](https://modelscope.cn/models/ZhipuAI/chatglm2-6b/summary) 141 | - [codegeex2-6b](https://modelscope.cn/models/ZhipuAI/codegeex2-6b/summary) 142 | - [chatglm3-6b](https://modelscope.cn/models/ZhipuAI/chatglm3-6b/summary) 143 | - [glm4-9b-chat](https://modelscope.cn/models/ZhipuAI/glm-4-9b-chat/summary) 144 | - [Llama-2-7b-chat-ms](https://modelscope.cn/models/modelscope/Llama-2-7b-chat-ms/summary) 145 | - [Llama-3-8B-Instruct](https://modelscope.cn/models/modelscope/Meta-Llama-3-8B-Instruct/summary) 146 | - [Llama-3.2-1B-Instruct](https://modelscope.cn/models/LLM-Research/Llama-3.2-1B-Instruct/summary) 147 | - [Llama-3.2-3B-Instruct](https://modelscope.cn/models/LLM-Research/Llama-3.2-3B-Instruct/summary) 148 | - [Baichuan2-7B-Chat](https://modelscope.cn/models/baichuan-inc/baichuan-7B/summary) 149 | - [internlm-chat-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-chat-7b/summary) 150 | - [Yi-6B-Chat](https://modelscope.cn/models/01ai/Yi-6B-Chat/summary) 151 | - [deepseek-llm-7b-chat](https://modelscope.cn/models/deepseek-ai/deepseek-llm-7b-chat/summary) 152 | - [TinyLlama-1.1B-Chat-v0.6](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v0.6) 153 | - [phi-2](https://modelscope.cn/models/AI-ModelScope/phi-2/summary) 154 | - [bge-large-zh](https://modelscope.cn/models/AI-ModelScope/bge-large-zh/summary) 155 | - [gte_sentence-embedding_multilingual-base](https://modelscope.cn/models/iic/gte_sentence-embedding_multilingual-base/summary) 156 |
-------------------------------------------------------------------------------- /README_en.md: -------------------------------------------------------------------------------- 1 | ![mnn-llm](resource/logo.png) 2 | 3 | # mnn-llm 4 | [![License](https://img.shields.io/github/license/wangzhaode/mnn-llm)](LICENSE.txt) 5 | [![Download](https://img.shields.io/github/downloads/wangzhaode/mnn-llm/total)](https://github.com/wangzhaode/mnn-llm/releases) 6 | [![Documentation Status](https://readthedocs.org/projects/mnn-llm/badge/?version=latest)](https://mnn-llm.readthedocs.io/en/latest/?badge=latest) 7 | 8 | [Chinese](./README.md) 9 | 10 | **This project has merged into [MNN](https://github.com/alibaba/MNN/tree/master/transformers/llm).** 11 | 12 | 13 | ## Example Projects 14 | 15 | - [cli](./demo/cli_demo.cpp): Compile using the command line, for Android compilation refer to[android_build.sh](./script/android_build.sh) 16 | - [web](./demo/web_demo.cpp): Compile using the command line, runtime requires specifying[web resources](./web) 17 | - [android](./android/): Open with Android Studio for compilation; 18 | - [ios](./ios/README.md): Open with Xcode for compilation; 🚀🚀🚀**This sample code is 100% generated by ChatGPT**🚀🚀🚀 19 | - [python](./python/README.md): mnn-llm python api `mnnllm`; 20 | - [other](./demo): Added capabilities for text embedding. 21 | 22 | 23 | ## model export and download 24 | 25 | For exporting the llm model to `ONNX` or `mnn`, please use[llm-export](https://github.com/wangzhaode/llm-export) 26 | 27 | [model download](./docs/download.md) 28 | 29 | ## Building 30 | 31 | Current CI build status: 32 | 33 | [![Build Status][pass-linux]][ci-linux] 34 | [![Build Status][pass-macos]][ci-macos] 35 | [![Build Status][pass-windows]][ci-windows] 36 | [![Build Status][pass-android]][ci-android] 37 | [![Build Status][pass-ios]][ci-ios] 38 | [![Build Status][pass-python]][ci-python] 39 | 40 | [pass-linux]: https://github.com/wangzhaode/mnn-llm/actions/workflows/linux.yml/badge.svg 41 | [pass-macos]: https://github.com/wangzhaode/mnn-llm/actions/workflows/macos.yml/badge.svg 42 | [pass-windows]: https://github.com/wangzhaode/mnn-llm/actions/workflows/windows.yml/badge.svg 43 | [pass-android]: https://github.com/wangzhaode/mnn-llm/actions/workflows/android.yml/badge.svg 44 | [pass-ios]: https://github.com/wangzhaode/mnn-llm/actions/workflows/ios.yml/badge.svg 45 | [pass-python]: https://github.com/wangzhaode/mnn-llm/actions/workflows/python.yml/badge.svg 46 | [ci-linux]: https://github.com/wangzhaode/mnn-llm/actions/workflows/linux.yml 47 | [ci-macos]: https://github.com/wangzhaode/mnn-llm/actions/workflows/macos.yml 48 | [ci-windows]: https://github.com/wangzhaode/mnn-llm/actions/workflows/windows.yml 49 | [ci-android]: https://github.com/wangzhaode/mnn-llm/actions/workflows/android.yml 50 | [ci-ios]: https://github.com/wangzhaode/mnn-llm/actions/workflows/ios.yml 51 | [ci-python]: https://github.com/wangzhaode/mnn-llm/actions/workflows/python.yml 52 | 53 | ### Local Compilation 54 | ``` 55 | # clone 56 | git clone --recurse-submodules https://github.com/wangzhaode/mnn-llm.git 57 | cd mnn-llm 58 | 59 | # linux 60 | ./script/build.sh 61 | 62 | # windows msvc 63 | ./script/build.ps1 64 | 65 | # python wheel 66 | ./script/py_build.sh 67 | 68 | # android 69 | ./script/android_build.sh 70 | 71 | # android apk 72 | ./script/android_app_build.sh 73 | 74 | # ios 75 | ./script/ios_build.sh 76 | ``` 77 | 78 | The default backend used is `CPU`. If you want to use a different backend, you can add a MNN compilation macro: 79 | - cuda: `-DMNN_CUDA=ON` 80 | - opencl: `-DMNN_OPENCL=ON` 81 | - metal: `-DMNN_METAL=ON` 82 | 83 | 84 | ### 4. Execution 85 | 86 | ```bash 87 | # linux/macos 88 | ./cli_demo ./Qwen2-1.5B-Instruct-MNN/config.json # cli demo 89 | ./web_demo ./Qwen2-1.5B-Instruct-MNN/config.json ../web # web ui demo 90 | 91 | # windows 92 | .\Debug\cli_demo.exe ./Qwen2-1.5B-Instruct-MNN/config.json 93 | .\Debug\web_demo.exe ./Qwen2-1.5B-Instruct-MNN/config.json ../web 94 | 95 | # android 96 | adb push android_build/MNN/OFF/arm64-v8a/libMNN.so /data/local/tmp 97 | adb push android_build/MNN/express/OFF/arm64-v8a/libMNN_Express.so /data/local/tmp 98 | adb push android_build/libllm.so android_build/cli_demo /data/local/tmp 99 | adb push Qwen2-1.5B-Instruct-MNN /data/local/tmp 100 | adb shell "cd /data/local/tmp && export LD_LIBRARY_PATH=. && ./cli_demo ./Qwen2-1.5B-Instruct-MNN/config.json" 101 | ``` 102 | 103 | 104 | ## Reference 105 |
106 | reference 107 | 108 | - [cpp-httplib](https://github.com/yhirose/cpp-httplib) 109 | - [chatgpt-web](https://github.com/xqdoo00o/chatgpt-web) 110 | - [ChatViewDemo](https://github.com/BrettFX/ChatViewDemo) 111 | - [nlohmann/json](https://github.com/nlohmann/json) 112 | - [Qwen-1.8B-Chat](https://modelscope.cn/models/qwen/Qwen-1_8B-Chat/summary) 113 | - [Qwen-7B-Chat](https://modelscope.cn/models/qwen/Qwen-7B-Chat/summary) 114 | - [Qwen-VL-Chat](https://modelscope.cn/models/qwen/Qwen-VL-Chat/summary) 115 | - [Qwen1.5-0.5B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat/summary) 116 | - [Qwen1.5-1.8B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-1.8B-Chat/summary) 117 | - [Qwen1.5-4B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-4B-Chat/summary) 118 | - [Qwen1.5-7B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-7B-Chat/summary) 119 | - [Qwen2-0.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2-0.5B-Instruct/summary) 120 | - [Qwen2-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2-1.5B-Instruct/summary) 121 | - [Qwen2-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2-7B-Instruct/summary) 122 | - [Qwen2-VL-2B-Instruct](https://modelscope.cn/models/qwen/Qwen2-VL-2B-Instruct/summary) 123 | - [Qwen2-VL-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2-VL-7B-Instruct/summary) 124 | - [Qwen2.5-0.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-0.5B-Instruct/summary) 125 | - [Qwen2.5-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-1.5B-Instruct/summary) 126 | - [Qwen2.5-3B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-3B-Instruct/summary) 127 | - [Qwen2.5-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-7B-Instruct/summary) 128 | - [Qwen2.5-Coder-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Coder-1.5B-Instruct/summary) 129 | - [Qwen2.5-Coder-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Coder-7B-Instruct/summary) 130 | - [Qwen2.5-Math-1.5B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Math-1.5B-Instruct/summary) 131 | - [Qwen2.5-Math-7B-Instruct](https://modelscope.cn/models/qwen/Qwen2.5-Math-7B-Instruct/summary) 132 | - [chatglm-6b](https://modelscope.cn/models/ZhipuAI/chatglm-6b/summary) 133 | - [chatglm2-6b](https://modelscope.cn/models/ZhipuAI/chatglm2-6b/summary) 134 | - [codegeex2-6b](https://modelscope.cn/models/ZhipuAI/codegeex2-6b/summary) 135 | - [chatglm3-6b](https://modelscope.cn/models/ZhipuAI/chatglm3-6b/summary) 136 | - [glm4-9b-chat](https://modelscope.cn/models/ZhipuAI/glm-4-9b-chat/summary) 137 | - [Llama-2-7b-chat-ms](https://modelscope.cn/models/modelscope/Llama-2-7b-chat-ms/summary) 138 | - [Llama-3-8B-Instruct](https://modelscope.cn/models/modelscope/Meta-Llama-3-8B-Instruct/summary) 139 | - [Llama-3.2-1B-Instruct](https://modelscope.cn/models/LLM-Research/Llama-3.2-1B-Instruct/summary) 140 | - [Llama-3.2-3B-Instruct](https://modelscope.cn/models/LLM-Research/Llama-3.2-3B-Instruct/summary) 141 | - [Baichuan2-7B-Chat](https://modelscope.cn/models/baichuan-inc/baichuan-7B/summary) 142 | - [internlm-chat-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-chat-7b/summary) 143 | - [Yi-6B-Chat](https://modelscope.cn/models/01ai/Yi-6B-Chat/summary) 144 | - [deepseek-llm-7b-chat](https://modelscope.cn/models/deepseek-ai/deepseek-llm-7b-chat/summary) 145 | - [TinyLlama-1.1B-Chat-v0.6](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v0.6) 146 | - [phi-2](https://modelscope.cn/models/AI-ModelScope/phi-2/summary) 147 | - [bge-large-zh](https://modelscope.cn/models/AI-ModelScope/bge-large-zh/summary) 148 | - [gte_sentence-embedding_multilingual-base](https://modelscope.cn/models/iic/gte_sentence-embedding_multilingual-base/summary) 149 | 150 |
-------------------------------------------------------------------------------- /android/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "29.0.2" 6 | defaultConfig { 7 | applicationId "com.mnn.llm" 8 | minSdkVersion 21 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | externalNativeBuild { 14 | cmake { 15 | arguments "-DBUILD_JNI=TRUE", "-DANDROID_STL=c++_shared", "-DLLM_SUPPORT_VISION=TRUE", "-DMNN_OPENCL=TRUE" 16 | abiFilters 'arm64-v8a' 17 | } 18 | } 19 | } 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | externalNativeBuild { 27 | cmake { 28 | path file('../../CMakeLists.txt') 29 | } 30 | } 31 | sourceSets { 32 | main { 33 | jniLibs.srcDirs = ['src/main/jni/libs'] 34 | } 35 | } 36 | compileOptions { 37 | sourceCompatibility JavaVersion.VERSION_1_8 38 | targetCompatibility JavaVersion.VERSION_1_8 39 | } 40 | packagingOptions { 41 | exclude("META-INF/DEPENDENCIES") 42 | exclude("META-INF/LICENSE") 43 | exclude("META-INF/LICENSE.txt") 44 | exclude("META-INF/license.txt") 45 | exclude("META-INF/NOTICE") 46 | exclude("META-INF/NOTICE.txt") 47 | exclude("META-INF/notice.txt") 48 | exclude("META-INF/ASL2.0") 49 | exclude("META-INF/*.kotlin_module") 50 | } 51 | } 52 | 53 | dependencies { 54 | implementation fileTree(dir: 'libs', include: ['*.jar']) 55 | implementation 'androidx.appcompat:appcompat:1.0.2' 56 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 57 | testImplementation 'junit:junit:4.12' 58 | androidTestImplementation 'androidx.test.ext:junit:1.1.0' 59 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 60 | implementation 'androidx.recyclerview:recyclerview:1.1.0' 61 | implementation 'com.android.support:appcompat-v7:28.0.0' 62 | implementation 'com.android.support:design:28.0.0' 63 | implementation 'uk.co.chrisjenx:calligraphy:2.2.0' 64 | implementation 'com.android.support:support-v4:28.0.0' 65 | implementation 'com.google.android.material:material:1.0.0' 66 | implementation "com.squareup.okhttp3:okhttp:4.11.0" 67 | } 68 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /android/app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /android/app/src/main/java/com/mnn/llm/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.mnn.llm; 2 | 3 | import android.content.Context; 4 | //import android.support.annotation.DrawableRes; 5 | //import android.support.v7.app.AppCompatActivity; 6 | //import android.support.v7.widget.Toolbar; 7 | import android.view.Menu; 8 | import android.view.MenuInflater; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import androidx.annotation.DrawableRes; 13 | import androidx.appcompat.app.AppCompatActivity; 14 | import androidx.appcompat.widget.Toolbar; 15 | 16 | import com.mnn.llm.R; 17 | import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper; 18 | 19 | public class BaseActivity extends AppCompatActivity { 20 | Toolbar toolbar; 21 | TextView title; 22 | public final void changeTitle(int toolbarId, String titlePage){ 23 | toolbar = (Toolbar) findViewById(toolbarId); 24 | setSupportActionBar(toolbar); 25 | 26 | title = (TextView) toolbar.findViewById(R.id.tv_title); 27 | title.setText(titlePage); 28 | getSupportActionBar().setTitle(""); 29 | } 30 | public final void setupToolbar(int toolbarId, String titlePage){ 31 | toolbar = (Toolbar) findViewById(toolbarId); 32 | setSupportActionBar(toolbar); 33 | 34 | title = (TextView) toolbar.findViewById(R.id.tv_title); 35 | title.setText(titlePage); 36 | 37 | getSupportActionBar().setTitle(""); 38 | } 39 | public void setupToolbarWithUpNav(int toolbarId, String titlePage, @DrawableRes int res){ 40 | toolbar = (Toolbar) findViewById(toolbarId); 41 | setSupportActionBar(toolbar); 42 | 43 | title = (TextView) toolbar.findViewById(R.id.tv_title); 44 | title.setText(titlePage); 45 | 46 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 47 | getSupportActionBar().setHomeAsUpIndicator(res); 48 | getSupportActionBar().setTitle(""); 49 | } 50 | @Override 51 | protected void attachBaseContext(Context newBase) { 52 | super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/mnn/llm/Chat.java: -------------------------------------------------------------------------------- 1 | package com.mnn.llm; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Chat implements Serializable { 6 | public native boolean Init(String modelDir); 7 | public native String Submit(String input); 8 | public native byte[] Response(); 9 | public native void Done(); 10 | public native void Reset(); 11 | 12 | static { 13 | System.loadLibrary("llm"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/mnn/llm/Common.java: -------------------------------------------------------------------------------- 1 | package com.mnn.llm; 2 | 3 | import android.app.Activity; 4 | import android.content.res.AssetManager; 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | 10 | 11 | public class Common { 12 | public static String copyAssetResource2File(Activity activity, String assetsDir) throws IOException, InterruptedException { 13 | AssetManager assetManager = activity.getBaseContext().getAssets(); 14 | // make output dir 15 | String outDir = activity.getCacheDir() + "/" + assetsDir; 16 | File outPath = new File(outDir); 17 | if (!outPath.exists()) { 18 | outPath.mkdirs(); 19 | } 20 | // visit input files and copy 21 | String[] files = assetManager.list(assetsDir); 22 | int nums = files.length; 23 | CopyThread [] threads = new CopyThread[nums]; 24 | for (int i = 0; i < nums; i++) { 25 | System.out.println("MNN_DEBUG: " + files[i]); 26 | String assetsFile = files[i]; 27 | if (new File(outDir + '/' + assetsFile).exists()) { 28 | continue; 29 | } 30 | threads[i] = new CopyThread(assetManager, assetsDir + '/' + assetsFile, outDir + '/' + assetsFile); 31 | threads[i].start(); 32 | } 33 | for (int i = 0; i < nums; i++) { 34 | if (threads[i] != null) { 35 | threads[i].join(); 36 | } 37 | } 38 | return outDir; 39 | } 40 | } 41 | 42 | class CopyThread extends Thread { 43 | private AssetManager mAsset; 44 | private String mSrcPath; 45 | private String mDstPath; 46 | public CopyThread(AssetManager asset, String src, String dst) { 47 | mAsset = asset; 48 | mSrcPath = src; 49 | mDstPath = dst; 50 | } 51 | public void run() { 52 | try { 53 | InputStream inS = mAsset.open(mSrcPath); 54 | File outF = new File(mDstPath); 55 | FileOutputStream outS = new FileOutputStream(outF); 56 | int byteCount; 57 | byte[] buffer = new byte[1024]; 58 | while ((byteCount = inS.read(buffer)) != -1) { 59 | outS.write(buffer, 0, byteCount); 60 | } 61 | outS.flush(); 62 | inS.close(); 63 | outS.close(); 64 | outF.setReadable(true); 65 | } catch (Exception e) {} 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/mnn/llm/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.mnn.llm; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.annotation.SuppressLint; 6 | import android.content.Intent; 7 | import android.graphics.Color; 8 | import android.os.Bundle; 9 | import android.view.View; 10 | import android.widget.AdapterView; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.Button; 13 | import android.widget.Spinner; 14 | import android.widget.TextView; 15 | 16 | import java.io.File; 17 | import java.io.IOException; 18 | import java.util.ArrayList; 19 | 20 | public class MainActivity extends AppCompatActivity { 21 | private Chat mChat; 22 | private Intent mIntent; 23 | private Button mLoadButton; 24 | private TextView mModelInfo; 25 | private Spinner mSpinnerModels; 26 | private final String mSearchPath = "/data/local/tmp/mnn-llm/"; 27 | private String mModelName = "qwen-1.8b-int4"; 28 | private String mModelDir = mSearchPath + mModelName; 29 | 30 | @SuppressLint("HandlerLeak") 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_main); 35 | mIntent = new Intent(this, Conversation.class); 36 | mModelInfo = findViewById(R.id.model_info); 37 | mLoadButton = findViewById(R.id.load_button); 38 | mSpinnerModels = findViewById(R.id.spinner_models); 39 | 40 | mModelDir = this.getCacheDir() + "/" + mModelName; 41 | populateFoldersSpinner(); 42 | mSpinnerModels.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 43 | @Override 44 | public void onItemSelected(AdapterView parent, View view, int position, long id) { 45 | if (position > 0) { 46 | mModelName = (String) parent.getItemAtPosition(position); 47 | mModelInfo.setText(String.format("选择模型:%s", mModelName)); 48 | mModelInfo.setVisibility(View.VISIBLE); 49 | mModelDir = mSearchPath + mModelName + "/config.json"; 50 | } 51 | } 52 | @Override 53 | public void onNothingSelected(AdapterView parent) {} 54 | }); 55 | } 56 | 57 | public void loadModel(View view) { 58 | onCheckModels(); 59 | mLoadButton.setClickable(false); 60 | mLoadButton.setBackgroundColor(Color.parseColor("#2454e4")); 61 | mLoadButton.setText("模型加载中 ..."); 62 | 63 | new Thread(() -> { 64 | mChat = new Chat(); 65 | mChat.Init(mModelDir); 66 | runOnUiThread(() -> { 67 | mIntent.putExtra("chat", mChat); 68 | startActivity(mIntent); 69 | }); 70 | }).start(); 71 | } 72 | 73 | private void onCheckModels() { 74 | boolean modelReady = checkModelsReady(); 75 | if (!modelReady) { 76 | try { 77 | mModelDir = Common.copyAssetResource2File(this, mModelName); 78 | modelReady = checkModelsReady(); 79 | } catch (IOException | InterruptedException e) { 80 | throw new RuntimeException(e); 81 | } 82 | } 83 | if (!modelReady) { 84 | mModelInfo.setVisibility(View.VISIBLE); 85 | mModelInfo.setText(String.format("%s模型文件就绪,模型加载中", mModelName)); 86 | mLoadButton.setText("加载模型"); 87 | } 88 | } 89 | 90 | private boolean checkModelsReady() { 91 | File dir = new File(mModelDir); 92 | return dir.exists(); 93 | } 94 | 95 | private ArrayList getFoldersList(String path) { 96 | File directory = new File(path); 97 | File[] files = directory.listFiles(); 98 | ArrayList foldersList = new ArrayList<>(); 99 | if (files != null) { 100 | for (File file : files) { 101 | if (file.isDirectory()) { 102 | foldersList.add(file.getName()); 103 | } 104 | } 105 | } 106 | return foldersList; 107 | } 108 | 109 | private void populateFoldersSpinner() { 110 | ArrayList folders = getFoldersList("/data/local/tmp/mnn-llm"); 111 | folders.add(0, getString(R.string.spinner_prompt)); 112 | ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, folders); 113 | mSpinnerModels.setAdapter(adapter); 114 | } 115 | } -------------------------------------------------------------------------------- /android/app/src/main/jni/llm_mnn_jni.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "llm.hpp" 12 | 13 | static std::unique_ptr llm(nullptr); 14 | static std::stringstream response_buffer; 15 | 16 | extern "C" { 17 | 18 | JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { 19 | __android_log_print(ANDROID_LOG_DEBUG, "MNN_DEBUG", "JNI_OnLoad"); 20 | return JNI_VERSION_1_4; 21 | } 22 | 23 | JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) { 24 | __android_log_print(ANDROID_LOG_DEBUG, "MNN_DEBUG", "JNI_OnUnload"); 25 | } 26 | 27 | JNIEXPORT jboolean JNICALL Java_com_mnn_llm_Chat_Init(JNIEnv* env, jobject thiz, jstring modelDir) { 28 | const char* model_dir = env->GetStringUTFChars(modelDir, 0); 29 | if (!llm.get()) { 30 | llm.reset(Llm::createLLM(model_dir)); 31 | llm->load(); 32 | } 33 | return JNI_TRUE; 34 | } 35 | 36 | JNIEXPORT jboolean JNICALL Java_com_mnn_llm_Chat_Ready(JNIEnv* env, jobject thiz) { 37 | if (llm.get()) { 38 | return JNI_TRUE; 39 | } 40 | return JNI_FALSE; 41 | } 42 | 43 | JNIEXPORT jstring JNICALL Java_com_mnn_llm_Chat_Submit(JNIEnv* env, jobject thiz, jstring inputStr) { 44 | if (!llm.get()) { 45 | return env->NewStringUTF("Failed, Chat is not ready!"); 46 | } 47 | const char* input_str = env->GetStringUTFChars(inputStr, 0); 48 | auto chat = [&](std::string str) { 49 | llm->response(str, &response_buffer, ""); 50 | }; 51 | std::thread chat_thread(chat, input_str); 52 | chat_thread.detach(); 53 | jstring result = env->NewStringUTF("Submit success!"); 54 | return result; 55 | } 56 | 57 | JNIEXPORT jbyteArray JNICALL Java_com_mnn_llm_Chat_Response(JNIEnv* env, jobject thiz) { 58 | auto len = response_buffer.str().size(); 59 | jbyteArray res = env->NewByteArray(len); 60 | env->SetByteArrayRegion(res, 0, len, (const jbyte*)response_buffer.str().c_str()); 61 | return res; 62 | } 63 | 64 | JNIEXPORT void JNICALL Java_com_mnn_llm_Chat_Done(JNIEnv* env, jobject thiz) { 65 | response_buffer.str(""); 66 | } 67 | 68 | JNIEXPORT void JNICALL Java_com_mnn_llm_Chat_Reset(JNIEnv* env, jobject thiz) { 69 | llm->reset(); 70 | } 71 | 72 | } // extern "C" -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_add.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_chats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_chats.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_contacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_contacts.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_edit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_edit_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_logout.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_settings.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_action_trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-hdpi/ic_action_trash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_add.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_chats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_chats.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_contacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_contacts.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_edit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_edit_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_logout.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_settings.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_action_trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-mdpi/ic_action_trash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-nodpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-nodpi/logo.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_add.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_chats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_chats.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_contacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_contacts.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_edit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_edit_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_logout.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_settings.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_action_trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xhdpi/ic_action_trash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_add.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_chats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_chats.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_contacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_contacts.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_edit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_edit_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_logout.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_settings.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_action_trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxhdpi/ic_action_trash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_add.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_chats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_chats.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_contacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_contacts.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_edit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_edit_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_logout.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_settings.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_action_trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangzhaode/mnn-llm/63c01a43bcfa0f764b37ed4a28cab3d1efbd217c/android/app/src/main/res/drawable-xxxhdpi/ic_action_trash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_bottom_grey.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_chat_me.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_chat_you.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_gradient.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_item_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_online.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_top_grey.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_unread.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/bg_white_rounded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/btn_grey.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/btn_pink.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/checkbox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_arrow_right.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_attachment.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_clock.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_menu.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 16 | 21 | 22 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_radio.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_radio_checked.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_trash.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/activity_conversation.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 25 | 26 | 32 | 33 | 34 | 39 | 40 | 48 | 56 | 63 | 71 | 79 | 89 | 90 | 91 | 102 | 103 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/content_conversation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 30 | 31 | 41 | 42 |