Compare commits
47 Commits
v1.6.9
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
878fd6b4f7 | ||
|
|
7fbcb5e810 | ||
|
|
2604d3c47b | ||
|
|
bb1a6191b0 | ||
|
|
dd89041f72 | ||
|
|
91eb72e515 | ||
|
|
1c7436c34b | ||
|
|
8678f376e9 | ||
|
|
050154f406 | ||
|
|
b3eae8bcfa | ||
|
|
c720362886 | ||
|
|
93029d3f5c | ||
|
|
28244a57b4 | ||
|
|
f6ba9d7451 | ||
|
|
96e431e06b | ||
|
|
cb6ddb3674 | ||
|
|
07d4ba0d6b | ||
|
|
ac139d5bda | ||
|
|
14acfc1d81 | ||
|
|
2947162cc4 | ||
|
|
4f14074a75 | ||
|
|
53a5574080 | ||
|
|
d91c3c004d | ||
|
|
c90cefc453 | ||
|
|
b8abd2fef3 | ||
|
|
887ba06bd6 | ||
|
|
c9513822c9 | ||
|
|
e3baa0da86 | ||
|
|
ba9aab920e | ||
|
|
b0f2ef65d9 | ||
|
|
c13b28561d | ||
|
|
5c88ccd9e6 | ||
|
|
e0a6a279b3 | ||
|
|
9bb3a90977 | ||
|
|
02bbd18acf | ||
|
|
18ab8b141f | ||
|
|
225abc5202 | ||
|
|
d33dff7723 | ||
|
|
771027211a | ||
|
|
94fe71b49c | ||
|
|
fafd9f7f6e | ||
|
|
85b10993ec | ||
|
|
11f1d66383 | ||
|
|
38e89aec18 | ||
|
|
3e336830a3 | ||
|
|
a1ae71d221 | ||
|
|
0703993bfd |
171
.github/workflows/docker.yml
vendored
Normal file
171
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
name: Publish Docker Image
|
||||
on: [push]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
docker_build:
|
||||
name: Build ${{ matrix.arch }} Image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
name: amd64
|
||||
# - arch: arm64
|
||||
# name: arm64
|
||||
|
||||
steps:
|
||||
- name: Free up disk spaces
|
||||
run: |
|
||||
sudo rm -rf /usr/share/dotnet || true
|
||||
sudo rm -rf /opt/ghc || true
|
||||
sudo rm -rf "/usr/local/share/boost" || true
|
||||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
|
||||
|
||||
- name: Get lowercase string for the repository name
|
||||
id: lowercase-repo-name
|
||||
uses: ASzc/change-string-case-action@v2
|
||||
with:
|
||||
string: ${{ github.event.repository.name }}
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ github.ref }}-${{ matrix.arch }}
|
||||
restore-keys: |
|
||||
${{ github.ref }}-${{ matrix.arch }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
id: vars
|
||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/${{ steps.lowercase-repo-name.outputs.lowercase }}:${{ matrix.name }}-latest
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,push=true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v1
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Build release and export
|
||||
id: build_rel
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/${{ steps.lowercase-repo-name.outputs.lowercase }}:${{ matrix.name }}-${{steps.version.outputs.result}}
|
||||
build-args: |
|
||||
SHA=${{ steps.version.outputs.result }}
|
||||
outputs: type=image,push=true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
- name: Save digest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Save release digest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digest_${{ matrix.name }}
|
||||
path: /tmp/digest.txt
|
||||
|
||||
manifests:
|
||||
name: Build manifests
|
||||
needs: [docker_build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get lowercase string for the repository name
|
||||
id: lowercase-repo-name
|
||||
uses: ASzc/change-string-case-action@v2
|
||||
with:
|
||||
string: ${{ github.event.repository.name }}
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/docker/setup-qemu-action
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
# https://github.com/docker/setup-buildx-action
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
config-inline: |
|
||||
[worker.oci]
|
||||
max-parallelism = 1
|
||||
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: /tmp/images/
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v1
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Merge and push manifest on master branch
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: python scripts/merge_manifest.py "${{ secrets.DOCKER_USERNAME }}/${{ steps.lowercase-repo-name.outputs.lowercase }}"
|
||||
|
||||
- name: Merge and push manifest on release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: python scripts/merge_manifest.py "${{ secrets.DOCKER_USERNAME }}/${{ steps.lowercase-repo-name.outputs.lowercase }}" ${{steps.version.outputs.result}}
|
||||
117
.github/workflows/pre-release.yml
vendored
Normal file
117
.github/workflows/pre-release.yml
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
name: pre-release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- "backend-python/**"
|
||||
tags-ignore:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- uses: actions/setup-python@v5
|
||||
id: cp310
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- uses: crazy-max/ghaction-chocolatey@v3
|
||||
with:
|
||||
args: install upx
|
||||
- run: |
|
||||
Start-BitsTransfer https://github.com/josStorer/ai00_rwkv_server/releases/latest/download/webgpu_server_windows_x86_64.exe ./backend-rust/webgpu_server.exe
|
||||
Start-BitsTransfer https://github.com/josStorer/web-rwkv-converter/releases/latest/download/web-rwkv-converter_windows_x86_64.exe ./backend-rust/web-rwkv-converter.exe
|
||||
Start-BitsTransfer https://github.com/josStorer/LibreHardwareMonitor.Console/releases/latest/download/LibreHardwareMonitor.Console.zip ./LibreHardwareMonitor.Console.zip
|
||||
Expand-Archive ./LibreHardwareMonitor.Console.zip -DestinationPath ./components/LibreHardwareMonitor.Console
|
||||
Start-BitsTransfer https://www.python.org/ftp/python/3.10.11/python-3.10.11-embed-amd64.zip ./python-3.10.11-embed-amd64.zip
|
||||
Expand-Archive ./python-3.10.11-embed-amd64.zip -DestinationPath ./py310
|
||||
$content=Get-Content "./py310/python310._pth"; $content | ForEach-Object {if ($_.ReadCount -eq 3) {"Lib\\site-packages"} else {$_}} | Set-Content ./py310/python310._pth
|
||||
./py310/python ./backend-python/get-pip.py
|
||||
./py310/python -m pip install Cython==3.0.4
|
||||
Copy-Item -Path "${{ steps.cp310.outputs.python-path }}/../include" -Destination "py310/include" -Recurse
|
||||
Copy-Item -Path "${{ steps.cp310.outputs.python-path }}/../libs" -Destination "py310/libs" -Recurse
|
||||
./py310/python -m pip install cyac==1.9
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
del ./backend-python/rwkv_pip/cpp/librwkv.dylib
|
||||
del ./backend-python/rwkv_pip/cpp/librwkv.so
|
||||
(Get-Content -Path ./backend-golang/app.go) -replace "//go:custom_build windows ", "" | Set-Content -Path ./backend-golang/app.go
|
||||
(Get-Content -Path ./backend-golang/utils.go) -replace "//go:custom_build windows ", "" | Set-Content -Path ./backend-golang/utils.go
|
||||
make
|
||||
Rename-Item -Path "build/bin/RWKV-Runner.exe" -NewName "RWKV-Runner_windows_x64.exe"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: RWKV-Runner_windows_x64.exe
|
||||
path: build/bin/RWKV-Runner_windows_x64.exe
|
||||
|
||||
linux:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- run: |
|
||||
wget https://github.com/josStorer/ai00_rwkv_server/releases/latest/download/webgpu_server_linux_x86_64 -O ./backend-rust/webgpu_server
|
||||
wget https://github.com/josStorer/web-rwkv-converter/releases/latest/download/web-rwkv-converter_linux_x86_64 -O ./backend-rust/web-rwkv-converter
|
||||
sudo apt-get update
|
||||
sudo apt-get install upx
|
||||
sudo apt-get install build-essential libgtk-3-dev libwebkit2gtk-4.0-dev libasound2-dev
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
rm ./backend-python/rwkv_pip/wkv_cuda.pyd
|
||||
rm ./backend-python/rwkv_pip/rwkv5.pyd
|
||||
rm ./backend-python/rwkv_pip/rwkv6.pyd
|
||||
rm ./backend-python/rwkv_pip/beta/wkv_cuda.pyd
|
||||
rm ./backend-python/get-pip.py
|
||||
rm ./backend-python/rwkv_pip/cpp/librwkv.dylib
|
||||
rm ./backend-python/rwkv_pip/cpp/rwkv.dll
|
||||
rm ./backend-python/rwkv_pip/webgpu/web_rwkv_py.cp310-win_amd64.pyd
|
||||
make
|
||||
mv build/bin/RWKV-Runner build/bin/RWKV-Runner_linux_x64
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: RWKV-Runner_linux_x64
|
||||
path: build/bin/RWKV-Runner_linux_x64
|
||||
|
||||
macos:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- run: |
|
||||
wget https://github.com/josStorer/ai00_rwkv_server/releases/latest/download/webgpu_server_darwin_aarch64 -O ./backend-rust/webgpu_server
|
||||
wget https://github.com/josStorer/web-rwkv-converter/releases/latest/download/web-rwkv-converter_darwin_aarch64 -O ./backend-rust/web-rwkv-converter
|
||||
go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
rm ./backend-python/rwkv_pip/wkv_cuda.pyd
|
||||
rm ./backend-python/rwkv_pip/rwkv5.pyd
|
||||
rm ./backend-python/rwkv_pip/rwkv6.pyd
|
||||
rm ./backend-python/rwkv_pip/beta/wkv_cuda.pyd
|
||||
rm ./backend-python/get-pip.py
|
||||
rm ./backend-python/rwkv_pip/cpp/rwkv.dll
|
||||
rm ./backend-python/rwkv_pip/cpp/librwkv.so
|
||||
rm ./backend-python/rwkv_pip/webgpu/web_rwkv_py.cp310-win_amd64.pyd
|
||||
make
|
||||
cp build/darwin/Readme_Install.txt build/bin/Readme_Install.txt
|
||||
cp build/bin/RWKV-Runner.app/Contents/MacOS/RWKV-Runner build/bin/RWKV-Runner_darwin_universal
|
||||
cd build/bin && zip -r RWKV-Runner_macos_universal.zip RWKV-Runner.app Readme_Install.txt
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: RWKV-Runner_macos_universal.zip
|
||||
path: build/bin/RWKV-Runner_macos_universal.zip
|
||||
|
||||
20
.github/workflows/release.yml
vendored
20
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
|
||||
@@ -38,17 +38,17 @@ jobs:
|
||||
runs-on: windows-2022
|
||||
needs: create-draft
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
id: cp310
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- uses: crazy-max/ghaction-chocolatey@v2
|
||||
- uses: crazy-max/ghaction-chocolatey@v3
|
||||
with:
|
||||
args: install upx
|
||||
- run: |
|
||||
@@ -78,10 +78,10 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
needs: create-draft
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- run: |
|
||||
@@ -108,10 +108,10 @@ jobs:
|
||||
runs-on: macos-13
|
||||
needs: create-draft
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
- uses: actions/setup-go@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.20.5'
|
||||
- run: |
|
||||
@@ -137,5 +137,5 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [ windows, linux, macos ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- run: gh release edit ${{github.ref_name}} --draft=false
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,7 +19,6 @@ __pycache__
|
||||
/cmd-helper.bat
|
||||
/install-py-dep.bat
|
||||
/backend-python/wkv_cuda
|
||||
/backend-python/rwkv*
|
||||
*.exe
|
||||
*.old
|
||||
.DS_Store
|
||||
|
||||
@@ -1,42 +1,25 @@
|
||||
## Changes
|
||||
|
||||
### Upgrades
|
||||
|
||||
- web-rwkv-py 0.1.2 (Support V4, V5 and V6) https://github.com/cryscan/web-rwkv-py
|
||||
- webgpu 0.3.13 https://github.com/cgisky1980/ai00_rwkv_server
|
||||
|
||||
### Features
|
||||
|
||||
- add markdown renderer switch
|
||||
- allow loading conversation
|
||||
- allow setting history message number
|
||||
- expose penalty_decay, top_k
|
||||
- add AVOID_PENALTY_TOKENS
|
||||
- add [parse_api_log.py](https://github.com/josStorer/RWKV-Runner/blob/master/parse_api_log.py), this script can extract
|
||||
formatted data from api.log
|
||||
|
||||
### Improvements
|
||||
|
||||
- improve macos experience
|
||||
- improve fine-tune performance
|
||||
- add better custom tokenizer support and tokenizer-midipiano.json
|
||||
- improve path processing
|
||||
- add EOS state cache point
|
||||
- reduce package size
|
||||
- add Docker support (#291) @LonghronShen
|
||||
|
||||
### Fixes
|
||||
|
||||
- fix WSL2 WindowsOptionalFeature: Microsoft-Windows-Subsystem-Linux -> VirtualMachinePlatform
|
||||
- fix finetune errorsMap ($modelInfo)
|
||||
- fix a generation exception caused by potentially dangerous regex being passed into the stop array
|
||||
- fix max_tokens parameter of Chat page not being passed to backend
|
||||
- fix the issue where penalty_decay and global_penalty are not being passed to the backend default config when running
|
||||
the model through client
|
||||
|
||||
### Improvements
|
||||
|
||||
- prevent 'torch' has no attribute 'cuda' error in torch_gc, so user can use CPU or WebGPU (#302)
|
||||
|
||||
### Chores
|
||||
|
||||
- update defaultPresets
|
||||
- update defaultModelConfigs
|
||||
- rename manifest tag "Main" -> "Official"
|
||||
- update manifest.json
|
||||
- update Related Repositories
|
||||
- other minor changes
|
||||
- bump dependencies
|
||||
- add pre-release workflow
|
||||
- dep_check.py now ignores GPUtil
|
||||
|
||||
## Install
|
||||
|
||||
|
||||
55
Dockerfile
Normal file
55
Dockerfile
Normal file
@@ -0,0 +1,55 @@
|
||||
FROM node:21-slim AS frontend
|
||||
|
||||
RUN echo "registry=https://registry.npmmirror.com/" > ~/.npmrc
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY manifest.json manifest.json
|
||||
COPY frontend frontend
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
RUN npm ci
|
||||
RUN npm run build
|
||||
|
||||
FROM nvidia/cuda:11.6.1-devel-ubuntu20.04 AS runtime
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update && \
|
||||
apt install -yq git curl wget build-essential ninja-build aria2 jq software-properties-common
|
||||
|
||||
RUN add-apt-repository -y ppa:deadsnakes/ppa && \
|
||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
|
||||
apt install -y g++-11 python3.10 python3.10-distutils python3.10-dev && \
|
||||
curl -sS http://mirrors.aliyun.com/pypi/get-pip.py | python3.10
|
||||
|
||||
RUN python3.10 -m pip install cmake
|
||||
|
||||
FROM runtime AS librwkv
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN git clone https://github.com/RWKV/rwkv.cpp.git && \
|
||||
cd rwkv.cpp && \
|
||||
git submodule update --init --recursive && \
|
||||
mkdir -p build && \
|
||||
cd build && \
|
||||
cmake -G Ninja .. && \
|
||||
cmake --build .
|
||||
|
||||
FROM runtime AS final
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./backend-python/requirements.txt ./backend-python/requirements.txt
|
||||
|
||||
RUN python3.10 -m pip install --quiet -r ./backend-python/requirements.txt
|
||||
|
||||
COPY . .
|
||||
COPY --from=frontend /app/frontend/dist /app/frontend/dist
|
||||
COPY --from=librwkv /app/rwkv.cpp/build/librwkv.so /app/backend-python/rwkv_pip/cpp/librwkv.so
|
||||
|
||||
EXPOSE 27777
|
||||
|
||||
CMD ["python3.10", "./backend-python/main.py", "--port", "27777", "--host", "0.0.0.0", "--webui"]
|
||||
@@ -12,6 +12,7 @@ compatible with the OpenAI API, which means that every ChatGPT client is an RWKV
|
||||
|
||||
[![license][license-image]][license-url]
|
||||
[![release][release-image]][release-url]
|
||||
[![py-version][py-version-image]][py-version-url]
|
||||
|
||||
English | [简体中文](README_ZH.md) | [日本語](README_JA.md)
|
||||
|
||||
@@ -31,6 +32,10 @@ English | [简体中文](README_ZH.md) | [日本語](README_JA.md)
|
||||
|
||||
[release-url]: https://github.com/josStorer/RWKV-Runner/releases/latest
|
||||
|
||||
[py-version-image]: https://img.shields.io/pypi/pyversions/fastapi.svg
|
||||
|
||||
[py-version-url]: https://github.com/josStorer/RWKV-Runner/tree/master/backend-python
|
||||
|
||||
[download-url]: https://github.com/josStorer/RWKV-Runner/releases
|
||||
|
||||
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
[![license][license-image]][license-url]
|
||||
[![release][release-image]][release-url]
|
||||
[![py-version][py-version-image]][py-version-url]
|
||||
|
||||
[English](README.md) | [简体中文](README_ZH.md) | 日本語
|
||||
|
||||
@@ -31,6 +32,10 @@
|
||||
|
||||
[release-url]: https://github.com/josStorer/RWKV-Runner/releases/latest
|
||||
|
||||
[py-version-image]: https://img.shields.io/pypi/pyversions/fastapi.svg
|
||||
|
||||
[py-version-url]: https://github.com/josStorer/RWKV-Runner/tree/master/backend-python
|
||||
|
||||
[download-url]: https://github.com/josStorer/RWKV-Runner/releases
|
||||
|
||||
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
||||
|
||||
@@ -11,6 +11,7 @@ API兼容的接口,这意味着一切ChatGPT客户端都是RWKV客户端。
|
||||
|
||||
[![license][license-image]][license-url]
|
||||
[![release][release-image]][release-url]
|
||||
[![py-version][py-version-image]][py-version-url]
|
||||
|
||||
[English](README.md) | 简体中文 | [日本語](README_JA.md)
|
||||
|
||||
@@ -30,6 +31,10 @@ API兼容的接口,这意味着一切ChatGPT客户端都是RWKV客户端。
|
||||
|
||||
[release-url]: https://github.com/josStorer/RWKV-Runner/releases/latest
|
||||
|
||||
[py-version-image]: https://img.shields.io/pypi/pyversions/fastapi.svg
|
||||
|
||||
[py-version-url]: https://github.com/josStorer/RWKV-Runner/tree/master/backend-python
|
||||
|
||||
[download-url]: https://github.com/josStorer/RWKV-Runner/releases
|
||||
|
||||
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
|
||||
|
||||
28
backend-python/convert_safetensors.py
vendored
28
backend-python/convert_safetensors.py
vendored
@@ -54,19 +54,21 @@ def convert_file(pt_filename: str, sf_filename: str, rename={}, transpose_names=
|
||||
loaded[k].unsqueeze(1).repeat(1, n_emb // loaded[k].shape[0])
|
||||
)
|
||||
|
||||
for k in kk:
|
||||
new_k = rename_key(rename, k).lower()
|
||||
v = loaded[k].half()
|
||||
del loaded[k]
|
||||
for transpose_name in transpose_names:
|
||||
if transpose_name in k:
|
||||
v = v.transpose(0, 1)
|
||||
print(f"{new_k}\t{v.shape}\t{v.dtype}")
|
||||
loaded[new_k] = {
|
||||
"dtype": str(v.dtype).split(".")[-1],
|
||||
"shape": v.shape,
|
||||
"data": v.numpy().tobytes(),
|
||||
}
|
||||
with torch.no_grad():
|
||||
for k in kk:
|
||||
new_k = rename_key(rename, k).lower()
|
||||
v = loaded[k].half()
|
||||
del loaded[k]
|
||||
for transpose_name in transpose_names:
|
||||
if transpose_name in new_k:
|
||||
dims = len(v.shape)
|
||||
v = v.transpose(dims - 2, dims - 1)
|
||||
print(f"{new_k}\t{v.shape}\t{v.dtype}")
|
||||
loaded[new_k] = {
|
||||
"dtype": str(v.dtype).split(".")[-1],
|
||||
"shape": v.shape,
|
||||
"data": v.numpy().tobytes(),
|
||||
}
|
||||
|
||||
dirname = os.path.dirname(sf_filename)
|
||||
os.makedirs(dirname, exist_ok=True)
|
||||
|
||||
@@ -7,7 +7,6 @@ import lm_dataformat
|
||||
import ftfy
|
||||
import tqdm
|
||||
import tiktoken
|
||||
import GPUtil
|
||||
|
||||
import torch
|
||||
import rwkv
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
torch
|
||||
torchvision
|
||||
torchaudio
|
||||
rwkv==0.8.22
|
||||
rwkv==0.8.25
|
||||
langchain==0.0.322
|
||||
fastapi==0.104.0
|
||||
fastapi==0.109.1
|
||||
uvicorn==0.23.2
|
||||
sse-starlette==1.6.5
|
||||
pydantic==2.4.2
|
||||
@@ -19,7 +19,7 @@ midi2audio==0.1.1
|
||||
mido==1.3.0
|
||||
safetensors==0.4.0
|
||||
PyMuPDF==1.23.5
|
||||
python-multipart==0.0.6
|
||||
python-multipart==0.0.7
|
||||
Cython==3.0.4
|
||||
cyac==1.9
|
||||
torch_directml==0.1.13.1.dev230413
|
||||
torch-directml==0.1.13.1.dev230413
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
torch
|
||||
torchvision
|
||||
torchaudio
|
||||
rwkv==0.8.22
|
||||
rwkv==0.8.25
|
||||
langchain==0.0.322
|
||||
fastapi==0.104.0
|
||||
fastapi==0.109.1
|
||||
uvicorn==0.23.2
|
||||
sse-starlette==1.6.5
|
||||
pydantic==2.4.2
|
||||
@@ -19,5 +19,5 @@ midi2audio==0.1.1
|
||||
mido==1.3.0
|
||||
safetensors==0.4.0
|
||||
PyMuPDF==1.23.5
|
||||
python-multipart==0.0.6
|
||||
python-multipart==0.0.7
|
||||
Cython==3.0.4
|
||||
|
||||
@@ -144,6 +144,7 @@ async def eval_rwkv(
|
||||
return
|
||||
set_rwkv_config(model, global_var.get(global_var.Model_Config))
|
||||
set_rwkv_config(model, body)
|
||||
print(get_rwkv_config(model))
|
||||
|
||||
response, prompt_tokens, completion_tokens = "", 0, 0
|
||||
for response, delta, prompt_tokens, completion_tokens in model.generate(
|
||||
@@ -155,23 +156,27 @@ async def eval_rwkv(
|
||||
if stream:
|
||||
yield json.dumps(
|
||||
{
|
||||
"object": "chat.completion.chunk"
|
||||
if chat_mode
|
||||
else "text_completion",
|
||||
"object": (
|
||||
"chat.completion.chunk"
|
||||
if chat_mode
|
||||
else "text_completion"
|
||||
),
|
||||
# "response": response,
|
||||
"model": model.name,
|
||||
"choices": [
|
||||
{
|
||||
"delta": {"content": delta},
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": delta,
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
(
|
||||
{
|
||||
"delta": {"content": delta},
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": delta,
|
||||
"index": 0,
|
||||
"finish_reason": None,
|
||||
}
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
@@ -193,23 +198,25 @@ async def eval_rwkv(
|
||||
if stream:
|
||||
yield json.dumps(
|
||||
{
|
||||
"object": "chat.completion.chunk"
|
||||
if chat_mode
|
||||
else "text_completion",
|
||||
"object": (
|
||||
"chat.completion.chunk" if chat_mode else "text_completion"
|
||||
),
|
||||
# "response": response,
|
||||
"model": model.name,
|
||||
"choices": [
|
||||
{
|
||||
"delta": {},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": "",
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
(
|
||||
{
|
||||
"delta": {},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": "",
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
@@ -225,20 +232,22 @@ async def eval_rwkv(
|
||||
"total_tokens": prompt_tokens + completion_tokens,
|
||||
},
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"role": Role.Assistant.value,
|
||||
"content": response,
|
||||
},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": response,
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
(
|
||||
{
|
||||
"message": {
|
||||
"role": Role.Assistant.value,
|
||||
"content": response,
|
||||
},
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
if chat_mode
|
||||
else {
|
||||
"text": response,
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
)
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -86,32 +86,53 @@ def switch_model(body: SwitchModelBody, response: Response, request: Request):
|
||||
|
||||
if body.deploy:
|
||||
global_var.set(global_var.Deploy_Mode, True)
|
||||
if global_var.get(global_var.Model_Config) is None:
|
||||
global_var.set(
|
||||
global_var.Model_Config, get_rwkv_config(global_var.get(global_var.Model))
|
||||
)
|
||||
|
||||
saved_model_config = global_var.get(global_var.Model_Config)
|
||||
init_model_config = get_rwkv_config(global_var.get(global_var.Model))
|
||||
if saved_model_config is not None:
|
||||
merge_model(init_model_config, saved_model_config)
|
||||
global_var.set(global_var.Model_Config, init_model_config)
|
||||
global_var.set(global_var.Model_Status, global_var.ModelStatus.Working)
|
||||
|
||||
return "success"
|
||||
|
||||
|
||||
def merge_model(to_model: BaseModel, from_model: BaseModel):
|
||||
from_model_fields = [x for x in from_model.dict().keys()]
|
||||
to_model_fields = [x for x in to_model.dict().keys()]
|
||||
|
||||
for field_name in from_model_fields:
|
||||
if field_name in to_model_fields:
|
||||
from_value = getattr(from_model, field_name)
|
||||
|
||||
if from_value is not None:
|
||||
setattr(to_model, field_name, from_value)
|
||||
|
||||
|
||||
@router.post("/update-config", tags=["Configs"])
|
||||
def update_config(body: ModelConfigBody):
|
||||
"""
|
||||
Will not update the model config immediately, but set it when completion called to avoid modifications during generation
|
||||
"""
|
||||
|
||||
print(body)
|
||||
global_var.set(global_var.Model_Config, body)
|
||||
model_config = global_var.get(global_var.Model_Config)
|
||||
if model_config is None:
|
||||
model_config = ModelConfigBody()
|
||||
global_var.set(global_var.Model_Config, model_config)
|
||||
merge_model(model_config, body)
|
||||
print("Updated Model Config:", model_config)
|
||||
|
||||
return "success"
|
||||
|
||||
|
||||
@router.get("/status", tags=["Configs"])
|
||||
def status():
|
||||
import GPUtil
|
||||
try:
|
||||
import GPUtil
|
||||
|
||||
gpus = GPUtil.getGPUs()
|
||||
gpus = GPUtil.getGPUs()
|
||||
except:
|
||||
gpus = []
|
||||
if len(gpus) == 0:
|
||||
device_name = "CPU"
|
||||
else:
|
||||
|
||||
@@ -76,6 +76,31 @@ class AddStateBody(BaseModel):
|
||||
logits: Any
|
||||
|
||||
|
||||
def copy_tensor_to_cpu(tensors):
|
||||
import torch
|
||||
import numpy as np
|
||||
|
||||
devices: List[torch.device] = []
|
||||
copied: Union[Any, None] = None
|
||||
|
||||
tensors_type = type(tensors)
|
||||
if tensors_type == list:
|
||||
if hasattr(tensors[0], "device"): # torch state
|
||||
devices = [tensor.device for tensor in tensors]
|
||||
copied = [tensor.cpu() for tensor in tensors]
|
||||
else: # WebGPU logits
|
||||
copied = tensors
|
||||
elif tensors_type == torch.Tensor: # torch logits
|
||||
devices = [tensors.device]
|
||||
copied = tensors.cpu()
|
||||
elif tensors_type == np.ndarray: # rwkv.cpp
|
||||
copied = tensors
|
||||
else: # WebGPU state
|
||||
copied = tensors.back()
|
||||
|
||||
return copied, devices
|
||||
|
||||
|
||||
# @router.post("/add-state", tags=["State Cache"])
|
||||
def add_state(body: AddStateBody):
|
||||
global trie, dtrie, loop_del_trie_id
|
||||
@@ -91,23 +116,24 @@ def add_state(body: AddStateBody):
|
||||
|
||||
try:
|
||||
devices: List[torch.device] = []
|
||||
logits_device: Union[torch.device, None] = None
|
||||
state: Union[Any, None] = None
|
||||
logits: Union[Any, None] = None
|
||||
|
||||
if body.state is not None:
|
||||
if type(body.state) == list and hasattr(body.state[0], "device"): # torch
|
||||
devices = [tensor.device for tensor in body.state]
|
||||
state = [tensor.cpu() for tensor in body.state]
|
||||
elif type(body.state) == np.ndarray: # rwkv.cpp
|
||||
state = body.state
|
||||
else: # WebGPU
|
||||
state = body.state.back()
|
||||
state, devices = copy_tensor_to_cpu(body.state)
|
||||
if body.logits is not None:
|
||||
logits, logits_devices = copy_tensor_to_cpu(body.logits)
|
||||
if len(logits_devices) > 0:
|
||||
logits_device = logits_devices[0]
|
||||
|
||||
id: int = trie.insert(body.prompt)
|
||||
dtrie[id] = {
|
||||
"tokens": body.tokens,
|
||||
"state": state,
|
||||
"logits": body.logits,
|
||||
"logits": logits,
|
||||
"devices": devices,
|
||||
"logits_device": logits_device,
|
||||
}
|
||||
|
||||
if len(trie) >= max_trie_len:
|
||||
@@ -125,6 +151,7 @@ def add_state(body: AddStateBody):
|
||||
)
|
||||
return "success"
|
||||
except Exception as e:
|
||||
print(e) # should not happen
|
||||
raise HTTPException(
|
||||
status.HTTP_400_BAD_REQUEST, f"insert failed, bad prompt.\n{e}"
|
||||
)
|
||||
@@ -192,18 +219,33 @@ def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
|
||||
if id != -1:
|
||||
prompt: str = trie[id]
|
||||
v = dtrie[id]
|
||||
tokens: List[Union[str, int]] = copy.deepcopy(v["tokens"])
|
||||
devices: List[torch.device] = v["devices"]
|
||||
logits_device: Union[torch.device, None] = v["logits_device"]
|
||||
state: Union[Any, None] = v["state"]
|
||||
logits: Union[Any, None] = v["logits"]
|
||||
|
||||
if type(state) == list and hasattr(state[0], "device"): # torch
|
||||
state = [tensor.to(devices[i]) for i, tensor in enumerate(state)]
|
||||
state = [
|
||||
tensor.to(devices[i])
|
||||
if devices[i] != torch.device("cpu")
|
||||
else tensor.clone()
|
||||
for i, tensor in enumerate(state)
|
||||
]
|
||||
logits = (
|
||||
logits.to(logits_device)
|
||||
if logits_device != torch.device("cpu")
|
||||
else logits.clone()
|
||||
)
|
||||
else: # rwkv.cpp, WebGPU
|
||||
logits = np.copy(logits)
|
||||
|
||||
quick_log(request, body, "Hit:\n" + prompt)
|
||||
return {
|
||||
"prompt": prompt,
|
||||
"tokens": v["tokens"],
|
||||
"tokens": tokens,
|
||||
"state": state,
|
||||
"logits": v["logits"],
|
||||
"logits": logits,
|
||||
}
|
||||
else:
|
||||
return {"prompt": "", "tokens": [], "state": None, "logits": None}
|
||||
|
||||
7
backend-python/rwkv_pip/model.py
vendored
7
backend-python/rwkv_pip/model.py
vendored
@@ -552,7 +552,12 @@ class RWKV(MyModule):
|
||||
elif ".ln_x" in x: # need fp32 for group_norm
|
||||
w[x] = w[x].float()
|
||||
else:
|
||||
if (len(w[x].shape) == 2) and ("emb" not in x):
|
||||
if (
|
||||
(len(w[x].shape) == 2)
|
||||
and ("emb" not in x)
|
||||
and ("_w1" not in x)
|
||||
and ("_w2" not in x)
|
||||
):
|
||||
if WTYPE != torch.uint8:
|
||||
w[x] = w[x].to(dtype=WTYPE)
|
||||
else:
|
||||
|
||||
2224
backend-python/rwkv_pip/tokenizer-midipiano.json
vendored
Normal file
2224
backend-python/rwkv_pip/tokenizer-midipiano.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11
backend-python/rwkv_pip/utils.py
vendored
11
backend-python/rwkv_pip/utils.py
vendored
@@ -171,10 +171,17 @@ class PIPELINE:
|
||||
all_tokens += [token]
|
||||
for xxx in occurrence:
|
||||
occurrence[xxx] *= args.alpha_decay
|
||||
|
||||
ttt = self.decode([token])
|
||||
www = 1
|
||||
if ttt in " \t0123456789":
|
||||
www = 0
|
||||
# elif ttt in '\r\n,.;?!"\':+-*/=#@$%^&_`~|<>\\()[]{},。;“”:?!()【】':
|
||||
# www = 0.5
|
||||
if token not in occurrence:
|
||||
occurrence[token] = 1
|
||||
occurrence[token] = www
|
||||
else:
|
||||
occurrence[token] += 1
|
||||
occurrence[token] += www
|
||||
# print(occurrence) # debug
|
||||
|
||||
# output
|
||||
|
||||
20
backend-python/rwkv_pip/webgpu/model.py
vendored
20
backend-python/rwkv_pip/webgpu/model.py
vendored
@@ -19,12 +19,26 @@ class RWKV:
|
||||
self.version = str(self.info.version).lower()
|
||||
self.wrp = getattr(wrp, self.version)
|
||||
|
||||
layer = (
|
||||
int(s.lstrip("layer"))
|
||||
for s in strategy.split()
|
||||
for s in s.split(",")
|
||||
if s.startswith("layer")
|
||||
)
|
||||
|
||||
chunk_size = (
|
||||
int(s.lstrip("chunk"))
|
||||
for s in strategy.split()
|
||||
for s in s.split(",")
|
||||
if s.startswith("chunk")
|
||||
)
|
||||
|
||||
args = {
|
||||
"file": model_path,
|
||||
"turbo": True,
|
||||
"quant": 32 if "i8" in strategy else 0,
|
||||
"quant_nf4": 26 if "i4" in strategy else 0,
|
||||
"token_chunk_size": 32,
|
||||
"quant": next(layer, 31) if "i8" in strategy else 0,
|
||||
"quant_nf4": next(layer, 26) if "i4" in strategy else 0,
|
||||
"token_chunk_size": next(chunk_size, 32),
|
||||
"lora": None,
|
||||
}
|
||||
self.model = self.wrp.Model(**args)
|
||||
|
||||
@@ -40,6 +40,7 @@ class AbstractRWKV(ABC):
|
||||
self.penalty_alpha_presence = 0
|
||||
self.penalty_alpha_frequency = 1
|
||||
self.penalty_decay = 0.996
|
||||
self.global_penalty = False
|
||||
|
||||
@abstractmethod
|
||||
def adjust_occurrence(self, occurrence: Dict, token: int):
|
||||
@@ -314,22 +315,25 @@ class AbstractRWKV(ABC):
|
||||
yield response, "", prompt_token_len, completion_token_len
|
||||
break
|
||||
elif type(stop) == list:
|
||||
stop_exist_regex = "|".join(stop)
|
||||
matched = re.search(stop_exist_regex, response)
|
||||
if matched:
|
||||
try:
|
||||
state_cache.add_state(
|
||||
state_cache.AddStateBody(
|
||||
prompt=prompt + response,
|
||||
tokens=self.model_tokens,
|
||||
state=self.model_state,
|
||||
logits=logits,
|
||||
exit_flag = False
|
||||
for s in stop:
|
||||
if s in response:
|
||||
try:
|
||||
state_cache.add_state(
|
||||
state_cache.AddStateBody(
|
||||
prompt=prompt + response,
|
||||
tokens=self.model_tokens,
|
||||
state=self.model_state,
|
||||
logits=logits,
|
||||
)
|
||||
)
|
||||
)
|
||||
except HTTPException:
|
||||
pass
|
||||
response = response.split(matched.group())[0]
|
||||
yield response, "", prompt_token_len, completion_token_len
|
||||
except HTTPException:
|
||||
pass
|
||||
exit_flag = True
|
||||
response = response.split(s)[0]
|
||||
yield response, "", prompt_token_len, completion_token_len
|
||||
break
|
||||
if exit_flag:
|
||||
break
|
||||
out_last = begin + i + 1
|
||||
if i == self.max_tokens_per_generation - 1:
|
||||
@@ -372,18 +376,18 @@ class TextRWKV(AbstractRWKV):
|
||||
self.bot = "Assistant"
|
||||
self.END_OF_LINE = 11
|
||||
|
||||
self.AVOID_REPEAT_TOKENS = []
|
||||
self.AVOID_REPEAT_TOKENS = set()
|
||||
AVOID_REPEAT = ",:?!"
|
||||
for i in AVOID_REPEAT:
|
||||
dd = self.pipeline.encode(i)
|
||||
assert len(dd) == 1
|
||||
self.AVOID_REPEAT_TOKENS += dd
|
||||
self.AVOID_PENALTY_TOKENS = []
|
||||
AVOID_PENALTY = "\n,.:,。:<>[]{}()/\\|;;" # \n,.:?!,。:?!"“”<>[]{}/\\|;;~`@#$%^&*()_+-=0123456789
|
||||
self.AVOID_REPEAT_TOKENS.add(dd[0])
|
||||
self.AVOID_PENALTY_TOKENS = set()
|
||||
AVOID_PENALTY = '\n,.:?!,。:?!"“”<>[]{}/\\|;;~`@#$%^&*()_+-=0123456789 '
|
||||
for i in AVOID_PENALTY:
|
||||
dd = self.pipeline.encode(i)
|
||||
assert len(dd) == 1
|
||||
self.AVOID_PENALTY_TOKENS += dd
|
||||
if len(dd) == 1:
|
||||
self.AVOID_PENALTY_TOKENS.add(dd[0])
|
||||
|
||||
self.__preload()
|
||||
|
||||
@@ -397,21 +401,18 @@ class TextRWKV(AbstractRWKV):
|
||||
|
||||
def adjust_forward_logits(self, logits: List[float], occurrence: Dict, i: int):
|
||||
for n in occurrence:
|
||||
if n not in self.AVOID_PENALTY_TOKENS:
|
||||
logits[n] -= (
|
||||
self.penalty_alpha_presence
|
||||
+ occurrence[n] * self.penalty_alpha_frequency
|
||||
)
|
||||
# if n not in self.AVOID_PENALTY_TOKENS:
|
||||
logits[n] -= (
|
||||
self.penalty_alpha_presence
|
||||
+ occurrence[n] * self.penalty_alpha_frequency
|
||||
)
|
||||
|
||||
if i == 0:
|
||||
# set global_penalty to False to get the same generated results as the official RWKV Gradio
|
||||
if self.global_penalty and i == 0:
|
||||
for token in self.model_tokens:
|
||||
token = int(token)
|
||||
for xxx in occurrence:
|
||||
occurrence[xxx] *= self.penalty_decay
|
||||
if token not in occurrence:
|
||||
occurrence[token] = 1
|
||||
else:
|
||||
occurrence[token] += 1
|
||||
if token not in self.AVOID_PENALTY_TOKENS:
|
||||
self.adjust_occurrence(occurrence, token)
|
||||
|
||||
# Model only saw '\n\n' as [187, 187] before, but the tokenizer outputs [535] for it at the end
|
||||
def fix_tokens(self, tokens) -> List[int]:
|
||||
@@ -670,12 +671,13 @@ def RWKV(model: str, strategy: str, tokenizer: Union[str, None]) -> AbstractRWKV
|
||||
|
||||
class ModelConfigBody(BaseModel):
|
||||
max_tokens: int = Field(default=None, gt=0, le=102400)
|
||||
temperature: float = Field(default=None, ge=0, le=2)
|
||||
temperature: float = Field(default=None, ge=0, le=3)
|
||||
top_p: float = Field(default=None, ge=0, le=1)
|
||||
presence_penalty: float = Field(default=None, ge=-2, le=2)
|
||||
frequency_penalty: float = Field(default=None, ge=-2, le=2)
|
||||
penalty_decay: float = Field(default=None, ge=0.99, le=0.999)
|
||||
top_k: int = Field(default=None, ge=0, le=25)
|
||||
global_penalty: bool = Field(default=None)
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
@@ -686,6 +688,7 @@ class ModelConfigBody(BaseModel):
|
||||
"presence_penalty": 0,
|
||||
"frequency_penalty": 1,
|
||||
"penalty_decay": 0.996,
|
||||
"global_penalty": False,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -709,6 +712,8 @@ def set_rwkv_config(model: AbstractRWKV, body: ModelConfigBody):
|
||||
model.penalty_decay = body.penalty_decay
|
||||
if body.top_k is not None:
|
||||
model.top_k = body.top_k
|
||||
if body.global_penalty is not None:
|
||||
model.global_penalty = body.global_penalty
|
||||
|
||||
|
||||
def get_rwkv_config(model: AbstractRWKV) -> ModelConfigBody:
|
||||
@@ -720,4 +725,5 @@ def get_rwkv_config(model: AbstractRWKV) -> ModelConfigBody:
|
||||
frequency_penalty=model.penalty_alpha_frequency,
|
||||
penalty_decay=model.penalty_decay,
|
||||
top_k=model.top_k,
|
||||
global_penalty=model.global_penalty,
|
||||
)
|
||||
|
||||
@@ -19,9 +19,12 @@ def set_torch():
|
||||
|
||||
|
||||
def torch_gc():
|
||||
import torch
|
||||
try:
|
||||
import torch
|
||||
|
||||
if torch.cuda.is_available():
|
||||
with torch.cuda.device(0):
|
||||
torch.cuda.empty_cache()
|
||||
torch.cuda.ipc_collect()
|
||||
if torch.cuda.is_available():
|
||||
with torch.cuda.device(0):
|
||||
torch.cuda.empty_cache()
|
||||
torch.cuda.ipc_collect()
|
||||
except:
|
||||
pass # prevent 'torch' has no attribute 'cuda' error, so user can use CPU or WebGPU
|
||||
|
||||
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
services:
|
||||
rmkv_runner:
|
||||
image: rwkv-runner:latest
|
||||
build: .
|
||||
# Append "--rwkv.cpp" parameter to use rwkv.cpp
|
||||
# command: python3.10 ./backend-python/main.py --port 27777 --host 0.0.0.0 --webui --rwkv.cpp
|
||||
volumes:
|
||||
- /mnt:/mnt
|
||||
ports:
|
||||
- "27777:27777"
|
||||
# Comment the following lines if use rwkv.cpp
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
@@ -22,6 +22,12 @@ else
|
||||
sudo apt -y install python3-pip
|
||||
fi
|
||||
|
||||
if dpkg -s "python3-dev" >/dev/null 2>&1; then
|
||||
echo "python3-dev installed"
|
||||
else
|
||||
sudo apt -y install python3-dev
|
||||
fi
|
||||
|
||||
if dpkg -s "ninja-build" >/dev/null 2>&1; then
|
||||
echo "ninja installed"
|
||||
else
|
||||
|
||||
2
frontend/package-lock.json
generated
2
frontend/package-lock.json
generated
@@ -6430,7 +6430,7 @@
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.0.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",
|
||||
"integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
|
||||
@@ -341,5 +341,11 @@
|
||||
"Load Conversation": "会話を読み込む",
|
||||
"The latest X messages will be sent to the server. If you are using the RWKV-Runner server, please use the default value because RWKV-Runner has built-in state cache management which only calculates increments. Sending all messages will have lower cost. If you are using ChatGPT, adjust this value according to your needs to reduce ChatGPT expenses.": "最新のX件のメッセージがサーバーに送信されます。RWKV-Runnerサーバーを使用している場合は、デフォルト値を使用してください。RWKV-Runnerには組み込みの状態キャッシュ管理があり、増分のみを計算します。すべてのメッセージを送信すると、コストが低くなります。ChatGPTを使用している場合は、ChatGPTの費用を削減するために必要に応じてこの値を調整してください。",
|
||||
"History Message Number": "履歴メッセージ数",
|
||||
"Send All Message": "すべてのメッセージを送信"
|
||||
"Send All Message": "すべてのメッセージを送信",
|
||||
"Quantized Layers": "量子化されたレイヤー",
|
||||
"Number of the neural network layers quantized with current precision, the more you quantize, the lower the VRAM usage, but the quality correspondingly decreases.": "現在の精度で量子化されたニューラルネットワークのレイヤーの数、量子化するほどVRAMの使用量が低くなりますが、品質も相応に低下します。",
|
||||
"Parallel Token Chunk Size": "並列トークンチャンクサイズ",
|
||||
"Maximum tokens to be processed in parallel at once. For high end GPUs, this could be 64 or 128 (faster).": "一度に並列で処理される最大トークン数。高性能なGPUの場合、64または128になります(高速)。",
|
||||
"Global Penalty": "グローバルペナルティ",
|
||||
"When generating a response, whether to include the submitted prompt as a penalty factor. By turning this off, you will get the same generated results as official RWKV Gradio. If you find duplicate results in the generated results, turning this on can help avoid generating duplicates.": "レスポンスを生成する際、提出されたプロンプトをペナルティ要因として含めるかどうか。これをオフにすると、公式RWKV Gradioと同じ生成結果を得ることができます。生成された結果に重複がある場合、これをオンにすることで重複の生成を回避するのに役立ちます。"
|
||||
}
|
||||
@@ -341,5 +341,11 @@
|
||||
"Load Conversation": "读取对话",
|
||||
"The latest X messages will be sent to the server. If you are using the RWKV-Runner server, please use the default value because RWKV-Runner has built-in state cache management which only calculates increments. Sending all messages will have lower cost. If you are using ChatGPT, adjust this value according to your needs to reduce ChatGPT expenses.": "最近的X条消息会发送至服务器. 如果你正在使用RWKV-Runner服务器, 请使用默认值, 因为RWKV-Runner内置了state缓存管理, 只计算增量, 发送所有消息将具有更低的成本. 如果你正在使用ChatGPT, 则根据你的需要调整此值, 这可以降低ChatGPT的费用",
|
||||
"History Message Number": "历史消息数量",
|
||||
"Send All Message": "发送所有消息"
|
||||
"Send All Message": "发送所有消息",
|
||||
"Quantized Layers": "量化层数",
|
||||
"Number of the neural network layers quantized with current precision, the more you quantize, the lower the VRAM usage, but the quality correspondingly decreases.": "神经网络以当前精度量化的层数, 量化越多, 占用显存越低, 但质量相应下降",
|
||||
"Parallel Token Chunk Size": "并行Token块大小",
|
||||
"Maximum tokens to be processed in parallel at once. For high end GPUs, this could be 64 or 128 (faster).": "一次最多可以并行处理的token数量. 对于高端显卡, 这可以是64或128 (更快)",
|
||||
"Global Penalty": "全局惩罚",
|
||||
"When generating a response, whether to include the submitted prompt as a penalty factor. By turning this off, you will get the same generated results as official RWKV Gradio. If you find duplicate results in the generated results, turning this on can help avoid generating duplicates.": "生成响应时, 是否将提交的prompt也纳入到惩罚项. 关闭此项将得到与RWKV官方Gradio完全一致的生成结果. 如果你发现生成结果出现重复, 那么开启此项有助于避免生成重复"
|
||||
}
|
||||
@@ -10,9 +10,10 @@ export const NumberInput: FC<{
|
||||
onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => void
|
||||
style?: CSSProperties,
|
||||
toFixed?: number
|
||||
}> = ({ value, min, max, step, onChange, style, toFixed = 2 }) => {
|
||||
disabled?: boolean
|
||||
}> = ({ value, min, max, step, onChange, style, toFixed = 2, disabled }) => {
|
||||
return (
|
||||
<Input type="number" style={style} value={value.toString()} min={min} max={max} step={step}
|
||||
<Input type="number" style={style} value={value.toString()} min={min} max={max} step={step} disabled={disabled}
|
||||
onChange={(e, data) => {
|
||||
onChange?.(e, { value: Number(data.value) });
|
||||
}}
|
||||
|
||||
@@ -212,7 +212,9 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
temperature: modelConfig.apiParameters.temperature,
|
||||
top_p: modelConfig.apiParameters.topP,
|
||||
presence_penalty: modelConfig.apiParameters.presencePenalty,
|
||||
frequency_penalty: modelConfig.apiParameters.frequencyPenalty
|
||||
frequency_penalty: modelConfig.apiParameters.frequencyPenalty,
|
||||
penalty_decay: modelConfig.apiParameters.penaltyDecay,
|
||||
global_penalty: modelConfig.apiParameters.globalPenalty
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ export const ValuedSlider: FC<{
|
||||
input?: boolean
|
||||
onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => void,
|
||||
toFixed?: number
|
||||
}> = ({ value, min, max, step, input, onChange, toFixed }) => {
|
||||
disabled?: boolean
|
||||
}> = ({ value, min, max, step, input, onChange, toFixed, disabled }) => {
|
||||
const sliderRef = useRef<HTMLInputElement>(null);
|
||||
useEffect(() => {
|
||||
if (step && sliderRef.current && sliderRef.current.parentElement) {
|
||||
@@ -24,10 +25,10 @@ export const ValuedSlider: FC<{
|
||||
<div className="flex items-center">
|
||||
<Slider ref={sliderRef} className="grow" style={{ minWidth: '50%' }} value={value} min={min}
|
||||
max={max} step={step}
|
||||
onChange={onChange} />
|
||||
onChange={onChange} disabled={disabled} />
|
||||
{input
|
||||
? <NumberInput style={{ minWidth: 0 }} value={value} min={min} max={max} step={step} onChange={onChange}
|
||||
toFixed={toFixed} />
|
||||
toFixed={toFixed} disabled={disabled} />
|
||||
: <Text>{value}</Text>}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -247,7 +247,7 @@ const SidePanel: FC = observer(() => {
|
||||
<Labeled flex breakline label={t('Temperature')}
|
||||
desc={t('Sampling temperature, it\'s like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
content={
|
||||
<ValuedSlider value={params.temperature} min={0} max={2} step={0.1}
|
||||
<ValuedSlider value={params.temperature} min={0} max={3} step={0.1}
|
||||
input
|
||||
onChange={(e, data) => {
|
||||
commonStore.setChatParams({
|
||||
@@ -258,7 +258,7 @@ const SidePanel: FC = observer(() => {
|
||||
<Labeled flex breakline label={t('Top_P')}
|
||||
desc={t('Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
content={
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.1} input
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.05} input
|
||||
onChange={(e, data) => {
|
||||
commonStore.setChatParams({
|
||||
topP: data.value
|
||||
@@ -534,6 +534,7 @@ const ChatPanel: FC = observer(() => {
|
||||
messages: messages.slice(-commonStore.chatParams.historyN),
|
||||
stream: true,
|
||||
model: commonStore.settings.apiChatModelName, // 'gpt-3.5-turbo'
|
||||
max_tokens: commonStore.chatParams.maxResponseToken,
|
||||
temperature: commonStore.chatParams.temperature,
|
||||
top_p: commonStore.chatParams.topP,
|
||||
presence_penalty: commonStore.chatParams.presencePenalty,
|
||||
|
||||
@@ -188,7 +188,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
<Labeled flex breakline label={t('Temperature')}
|
||||
desc={t('Sampling temperature, it\'s like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
content={
|
||||
<ValuedSlider value={params.temperature} min={0} max={2} step={0.1}
|
||||
<ValuedSlider value={params.temperature} min={0} max={3} step={0.1}
|
||||
input
|
||||
onChange={(e, data) => {
|
||||
setParams({
|
||||
@@ -199,7 +199,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
<Labeled flex breakline label={t('Top_P')}
|
||||
desc={t('Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
content={
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.1} input
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.05} input
|
||||
onChange={(e, data) => {
|
||||
setParams({
|
||||
topP: data.value
|
||||
|
||||
@@ -275,7 +275,7 @@ const CompositionPanel: FC = observer(() => {
|
||||
<Labeled flex breakline label={t('Temperature')}
|
||||
desc={t('Sampling temperature, it\'s like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
content={
|
||||
<ValuedSlider value={params.temperature} min={0} max={2} step={0.1}
|
||||
<ValuedSlider value={params.temperature} min={0} max={3} step={0.1}
|
||||
input
|
||||
onChange={(e, data) => {
|
||||
setParams({
|
||||
@@ -286,7 +286,7 @@ const CompositionPanel: FC = observer(() => {
|
||||
<Labeled flex breakline label={t('Top_P')}
|
||||
desc={t('Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
content={
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.1} input
|
||||
<ValuedSlider value={params.topP} min={0} max={1} step={0.05} input
|
||||
onChange={(e, data) => {
|
||||
setParams({
|
||||
topP: data.value
|
||||
|
||||
@@ -35,6 +35,7 @@ import { ResetConfigsButton } from '../components/ResetConfigsButton';
|
||||
import { useMediaQuery } from 'usehooks-ts';
|
||||
import { ApiParameters, Device, ModelParameters, Precision } from '../types/configs';
|
||||
import { convertModel, convertToGGML, convertToSt } from '../utils/convert-model';
|
||||
import { defaultPenaltyDecay } from './defaultConfigs';
|
||||
|
||||
const ConfigSelector: FC<{
|
||||
selectedIndex: number,
|
||||
@@ -66,14 +67,17 @@ const Configs: FC = observer(() => {
|
||||
const [selectedIndex, setSelectedIndex] = React.useState(commonStore.currentModelConfigIndex);
|
||||
const [selectedConfig, setSelectedConfig] = React.useState(commonStore.modelConfigs[selectedIndex]);
|
||||
const [displayStrategyImg, setDisplayStrategyImg] = React.useState(false);
|
||||
const advancedHeaderRef = useRef<HTMLDivElement>(null);
|
||||
const advancedHeaderRef1 = useRef<HTMLDivElement>(null);
|
||||
const advancedHeaderRef2 = useRef<HTMLDivElement>(null);
|
||||
const mq = useMediaQuery('(min-width: 640px)');
|
||||
const navigate = useNavigate();
|
||||
const port = selectedConfig.apiParameters.apiPort;
|
||||
|
||||
useEffect(() => {
|
||||
if (advancedHeaderRef.current)
|
||||
(advancedHeaderRef.current.firstElementChild as HTMLElement).style.padding = '0';
|
||||
if (advancedHeaderRef1.current)
|
||||
(advancedHeaderRef1.current.firstElementChild as HTMLElement).style.padding = '0';
|
||||
if (advancedHeaderRef2.current)
|
||||
(advancedHeaderRef2.current.firstElementChild as HTMLElement).style.padding = '0';
|
||||
}, []);
|
||||
|
||||
const updateSelectedIndex = useCallback((newIndex: number) => {
|
||||
@@ -113,7 +117,9 @@ const Configs: FC = observer(() => {
|
||||
temperature: selectedConfig.apiParameters.temperature,
|
||||
top_p: selectedConfig.apiParameters.topP,
|
||||
presence_penalty: selectedConfig.apiParameters.presencePenalty,
|
||||
frequency_penalty: selectedConfig.apiParameters.frequencyPenalty
|
||||
frequency_penalty: selectedConfig.apiParameters.frequencyPenalty,
|
||||
penalty_decay: selectedConfig.apiParameters.penaltyDecay,
|
||||
global_penalty: selectedConfig.apiParameters.globalPenalty
|
||||
});
|
||||
toast(t('Config Saved'), { autoClose: 300, type: 'success' });
|
||||
};
|
||||
@@ -176,7 +182,7 @@ const Configs: FC = observer(() => {
|
||||
<Labeled label={t('Temperature') + ' *'}
|
||||
desc={t('Sampling temperature, it\'s like giving alcohol to a model, the higher the stronger the randomness and creativity, while the lower, the more focused and deterministic it will be.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.temperature} min={0} max={2} step={0.1}
|
||||
<ValuedSlider value={selectedConfig.apiParameters.temperature} min={0} max={3} step={0.1}
|
||||
input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
@@ -187,35 +193,74 @@ const Configs: FC = observer(() => {
|
||||
<Labeled label={t('Top_P') + ' *'}
|
||||
desc={t('Just like feeding sedatives to the model. Consider the results of the top n% probability mass, 0.1 considers the top 10%, with higher quality but more conservative, 1 considers all results, with lower quality but more diverse.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.topP} min={0} max={1} step={0.1} input
|
||||
<ValuedSlider value={selectedConfig.apiParameters.topP} min={0} max={1} step={0.05} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
topP: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('Presence Penalty') + ' *'}
|
||||
desc={t('Positive values penalize new tokens based on whether they appear in the text so far, increasing the model\'s likelihood to talk about new topics.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.presencePenalty} min={-2} max={2}
|
||||
step={0.1} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
presencePenalty: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('Frequency Penalty') + ' *'}
|
||||
desc={t('Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model\'s likelihood to repeat the same line verbatim.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.frequencyPenalty} min={-2} max={2}
|
||||
step={0.1} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
frequencyPenalty: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Accordion className="sm:col-span-2" collapsible
|
||||
openItems={!commonStore.apiParamsCollapsed && 'advanced'}
|
||||
onToggle={(e, data) => {
|
||||
if (data.value === 'advanced')
|
||||
commonStore.setApiParamsCollapsed(!commonStore.apiParamsCollapsed);
|
||||
}}>
|
||||
<AccordionItem value="advanced">
|
||||
<AccordionHeader ref={advancedHeaderRef1} size="small">{t('Advanced')}</AccordionHeader>
|
||||
<AccordionPanel>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||
<Labeled label={t('Presence Penalty') + ' *'}
|
||||
desc={t('Positive values penalize new tokens based on whether they appear in the text so far, increasing the model\'s likelihood to talk about new topics.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.presencePenalty} min={-2} max={2}
|
||||
step={0.1} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
presencePenalty: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('Frequency Penalty') + ' *'}
|
||||
desc={t('Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model\'s likelihood to repeat the same line verbatim.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.frequencyPenalty} min={-2} max={2}
|
||||
step={0.1} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
frequencyPenalty: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled
|
||||
label={t('Penalty Decay')
|
||||
+ ((!selectedConfig.apiParameters.penaltyDecay || selectedConfig.apiParameters.penaltyDecay === defaultPenaltyDecay)
|
||||
? ` (${t('Default')})` : '')
|
||||
+ ' *'}
|
||||
desc={t('If you don\'t know what it is, keep it default.')}
|
||||
content={
|
||||
<ValuedSlider value={selectedConfig.apiParameters.penaltyDecay || defaultPenaltyDecay}
|
||||
min={0.99} max={0.999} step={0.001} toFixed={3} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
penaltyDecay: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
<Labeled label={t('Global Penalty') + ' *'}
|
||||
desc={t('When generating a response, whether to include the submitted prompt as a penalty factor. By turning this off, you will get the same generated results as official RWKV Gradio. If you find duplicate results in the generated results, turning this on can help avoid generating duplicates.')}
|
||||
content={
|
||||
<Switch checked={selectedConfig.apiParameters.globalPenalty}
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigApiParams({
|
||||
globalPenalty: data.checked
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
</div>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
@@ -279,9 +324,9 @@ const Configs: FC = observer(() => {
|
||||
}}>
|
||||
<Option value="CPU">CPU</Option>
|
||||
<Option value="CPU (rwkv.cpp)">{t('CPU (rwkv.cpp, Faster)')!}</Option>
|
||||
{commonStore.platform === 'darwin' && <Option value="MPS">MPS</Option>}
|
||||
{/*{commonStore.platform === 'darwin' && <Option value="MPS">MPS</Option>}*/}
|
||||
<Option value="CUDA">CUDA</Option>
|
||||
<Option value="CUDA-Beta">{t('CUDA (Beta, Faster)')!}</Option>
|
||||
{/*<Option value="CUDA-Beta">{t('CUDA (Beta, Faster)')!}</Option>*/}
|
||||
<Option value="WebGPU">WebGPU</Option>
|
||||
<Option value="WebGPU (Python)">WebGPU (Python)</Option>
|
||||
<Option value="Custom">{t('Custom')!}</Option>
|
||||
@@ -331,6 +376,40 @@ const Configs: FC = observer(() => {
|
||||
}} />
|
||||
} />
|
||||
}
|
||||
{
|
||||
selectedConfig.modelParameters.device.startsWith('WebGPU') &&
|
||||
<Labeled label={t('Parallel Token Chunk Size')}
|
||||
desc={t('Maximum tokens to be processed in parallel at once. For high end GPUs, this could be 64 or 128 (faster).')}
|
||||
content={
|
||||
<ValuedSlider
|
||||
value={selectedConfig.modelParameters.tokenChunkSize || 32}
|
||||
min={16} max={256} step={16} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigModelParams({
|
||||
tokenChunkSize: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
}
|
||||
{
|
||||
selectedConfig.modelParameters.device.startsWith('WebGPU') &&
|
||||
<Labeled label={t('Quantized Layers')}
|
||||
desc={t('Number of the neural network layers quantized with current precision, the more you quantize, the lower the VRAM usage, but the quality correspondingly decreases.')}
|
||||
content={
|
||||
<ValuedSlider
|
||||
disabled={selectedConfig.modelParameters.precision !== 'int8' && selectedConfig.modelParameters.precision !== 'nf4'}
|
||||
value={selectedConfig.modelParameters.precision === 'int8' ? (selectedConfig.modelParameters.quantizedLayers || 31) :
|
||||
selectedConfig.modelParameters.precision === 'nf4' ? (selectedConfig.modelParameters.quantizedLayers || 26) :
|
||||
selectedConfig.modelParameters.maxStoredLayers
|
||||
} min={0}
|
||||
max={selectedConfig.modelParameters.maxStoredLayers} step={1} input
|
||||
onChange={(e, data) => {
|
||||
setSelectedConfigModelParams({
|
||||
quantizedLayers: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
}
|
||||
{selectedConfig.modelParameters.device.startsWith('CUDA') && <div />}
|
||||
{
|
||||
displayStrategyImg &&
|
||||
@@ -376,7 +455,7 @@ const Configs: FC = observer(() => {
|
||||
commonStore.setModelParamsCollapsed(!commonStore.modelParamsCollapsed);
|
||||
}}>
|
||||
<AccordionItem value="advanced">
|
||||
<AccordionHeader ref={advancedHeaderRef} size="small">{t('Advanced')}</AccordionHeader>
|
||||
<AccordionHeader ref={advancedHeaderRef2} size="small">{t('Advanced')}</AccordionHeader>
|
||||
<AccordionPanel>
|
||||
<div className="flex flex-col">
|
||||
<div className="flex grow">
|
||||
|
||||
@@ -155,7 +155,7 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
||||
|
||||
const getTags = () => {
|
||||
return Array.from(new Set(
|
||||
['Recommended',
|
||||
['Recommended', 'Official',
|
||||
...commonStore.modelSourceList.map(item => item.tags || []).flat()
|
||||
.filter(i => !i.includes('Other') && !i.includes('Local'))
|
||||
, 'Other', 'Local']));
|
||||
|
||||
@@ -207,7 +207,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-1B5-v2-20231025-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-1B6-v2-20240208-ctx4096.pth',
|
||||
device: 'WebGPU',
|
||||
precision: 'nf4',
|
||||
storedLayers: 41,
|
||||
@@ -225,7 +225,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'WebGPU',
|
||||
precision: 'nf4',
|
||||
storedLayers: 41,
|
||||
@@ -243,7 +243,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'WebGPU',
|
||||
precision: 'nf4',
|
||||
storedLayers: 41,
|
||||
@@ -333,7 +333,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-1B5-v2-20231025-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-1B6-v2-20240208-ctx4096.pth',
|
||||
device: 'MPS',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
@@ -352,7 +352,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'MPS',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
@@ -371,7 +371,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'MPS',
|
||||
precision: 'fp32',
|
||||
storedLayers: 41,
|
||||
@@ -412,7 +412,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-1B5-v2-20231025-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-1B6-v2-20240208-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
@@ -431,7 +431,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 6,
|
||||
@@ -450,7 +450,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-1B5-v2-20231025-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-1B6-v2-20240208-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
@@ -469,7 +469,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 24,
|
||||
@@ -488,7 +488,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 24,
|
||||
@@ -545,7 +545,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
@@ -564,7 +564,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'int8',
|
||||
storedLayers: 41,
|
||||
@@ -621,7 +621,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
@@ -640,7 +640,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'CUDA',
|
||||
precision: 'fp16',
|
||||
storedLayers: 41,
|
||||
@@ -809,7 +809,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-1B5-v2-20231025-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-1B6-v2-20240208-ctx4096.pth',
|
||||
device: 'WebGPU',
|
||||
precision: 'nf4',
|
||||
storedLayers: 41,
|
||||
@@ -827,7 +827,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-5-World-3B-v2-20231118-ctx16k.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'WebGPU',
|
||||
precision: 'nf4',
|
||||
storedLayers: 41,
|
||||
@@ -845,7 +845,7 @@ export const defaultModelConfigs: ModelConfig[] = [
|
||||
frequencyPenalty: 1
|
||||
},
|
||||
modelParameters: {
|
||||
modelName: 'RWKV-4-World-CHNtuned-3B-v1-20230625-ctx4096.pth',
|
||||
modelName: 'RWKV-x060-World-3B-v2-20240228-ctx4096.pth',
|
||||
device: 'WebGPU',
|
||||
precision: 'nf4',
|
||||
storedLayers: 41,
|
||||
|
||||
@@ -127,6 +127,7 @@ class CommonStore {
|
||||
// configs
|
||||
currentModelConfigIndex: number = 0;
|
||||
modelConfigs: ModelConfig[] = [];
|
||||
apiParamsCollapsed: boolean = true;
|
||||
modelParamsCollapsed: boolean = true;
|
||||
// models
|
||||
activeModelListTags: string[] = [];
|
||||
@@ -177,7 +178,7 @@ class CommonStore {
|
||||
autoUpdatesCheck: true,
|
||||
giteeUpdatesSource: getUserLanguage() === 'zh',
|
||||
cnMirror: getUserLanguage() === 'zh',
|
||||
useHfMirror: false,
|
||||
useHfMirror: getUserLanguage() === 'zh',
|
||||
host: '127.0.0.1',
|
||||
dpiScaling: 100,
|
||||
customModelsPath: './models',
|
||||
@@ -324,6 +325,10 @@ class CommonStore {
|
||||
this.advancedCollapsed = value;
|
||||
}
|
||||
|
||||
setApiParamsCollapsed(value: boolean) {
|
||||
this.apiParamsCollapsed = value;
|
||||
}
|
||||
|
||||
setModelParamsCollapsed(value: boolean) {
|
||||
this.modelParamsCollapsed = value;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ export type ApiParameters = {
|
||||
presencePenalty: number;
|
||||
frequencyPenalty: number;
|
||||
penaltyDecay?: number;
|
||||
globalPenalty?: boolean;
|
||||
}
|
||||
export type Device = 'CPU' | 'CPU (rwkv.cpp)' | 'CUDA' | 'CUDA-Beta' | 'WebGPU' | 'WebGPU (Python)' | 'MPS' | 'Custom';
|
||||
export type Precision = 'fp16' | 'int8' | 'fp32' | 'nf4' | 'Q5_1';
|
||||
@@ -16,6 +17,8 @@ export type ModelParameters = {
|
||||
precision: Precision;
|
||||
storedLayers: number;
|
||||
maxStoredLayers: number;
|
||||
quantizedLayers?: number;
|
||||
tokenChunkSize?: number;
|
||||
useCustomCuda?: boolean;
|
||||
customStrategy?: string;
|
||||
useCustomTokenizer?: boolean;
|
||||
|
||||
@@ -194,6 +194,10 @@ export const getStrategy = (modelConfig: ModelConfig | undefined = undefined) =>
|
||||
case 'WebGPU':
|
||||
case 'WebGPU (Python)':
|
||||
strategy += params.precision === 'nf4' ? 'fp16i4' : params.precision === 'int8' ? 'fp16i8' : 'fp16';
|
||||
if (params.quantizedLayers)
|
||||
strategy += ` layer${params.quantizedLayers}`;
|
||||
if (params.tokenChunkSize)
|
||||
strategy += ` chunk${params.tokenChunkSize}`;
|
||||
break;
|
||||
case 'CUDA':
|
||||
case 'CUDA-Beta':
|
||||
|
||||
10
go.mod
10
go.mod
@@ -9,7 +9,7 @@ require (
|
||||
github.com/minio/selfupdate v0.6.0
|
||||
github.com/nyaosorg/go-windows-su v0.2.1
|
||||
github.com/ubuntu/gowsl v0.0.0-20230615094051-94945650cc1e
|
||||
github.com/wailsapp/wails/v2 v2.7.1
|
||||
github.com/wailsapp/wails/v2 v2.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -38,9 +38,9 @@ require (
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.10 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
golang.org/x/crypto v0.14.0 // indirect
|
||||
golang.org/x/crypto v0.18.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
)
|
||||
|
||||
20
go.sum
20
go.sum
@@ -79,20 +79,20 @@ github.com/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhy
|
||||
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/wails/v2 v2.7.1 h1:HAzp2c5ODOzsLC6ZMDVtNOB72ozM7/SJecJPB2Ur+UU=
|
||||
github.com/wailsapp/wails/v2 v2.7.1/go.mod h1:oIJVwwso5fdOgprBYWXBBqtx6PaSvxg8/KTQHNGkadc=
|
||||
github.com/wailsapp/wails/v2 v2.8.0 h1:b2NNn99uGPiN6P5bDsnPwOJZWtAOUhNLv7Vl+YxMTr4=
|
||||
github.com/wailsapp/wails/v2 v2.8.0/go.mod h1:EFUGWkUX3KofO4fmKR/GmsLy3HhPH7NbyOEaMt8lBF0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -109,14 +109,14 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.6.8",
|
||||
"version": "1.7.3",
|
||||
"introduction": {
|
||||
"en": "RWKV is an open-source, commercially usable large language model with high flexibility and great potential for development.\n### About This Tool\nThis tool aims to lower the barrier of entry for using large language models, making it accessible to everyone. It provides fully automated dependency and model management. You simply need to click and run, following the instructions, to deploy a local large language model. The tool itself is very compact and only requires a single executable file for one-click deployment.\nAdditionally, this tool offers an interface that is fully compatible with the OpenAI API. This means you can use any ChatGPT client as a client for RWKV, enabling capability expansion beyond just chat functionality.\n### Preset Configuration Rules at the Bottom\nThis tool comes with a series of preset configurations to reduce complexity. The naming rules for each configuration represent the following in order: device - required VRAM/memory - model size - model language.\nFor example, \"GPU-8G-3B-EN\" indicates that this configuration is for a graphics card with 8GB of VRAM, a model size of 3 billion parameters, and it uses an English language model.\nLarger model sizes have higher performance and VRAM requirements. Among configurations with the same model size, those with higher VRAM usage will have faster runtime.\nFor example, if you have 12GB of VRAM but running the \"GPU-12G-7B-EN\" configuration is slow, you can downgrade to \"GPU-8G-3B-EN\" for a significant speed improvement.\n### About RWKV\nRWKV is an RNN with Transformer-level LLM performance, which can also be directly trained like a GPT transformer (parallelizable). And it's 100% attention-free. You only need the hidden state at position t to compute the state at position t+1. You can use the \"GPT\" mode to quickly compute the hidden state for the \"RNN\" mode.<br/>So it's combining the best of RNN and transformer - great performance, fast inference, saves VRAM, fast training, \"infinite\" ctx_len, and free sentence embedding (using the final hidden state).",
|
||||
"zh": "RWKV是一个开源且允许商用的大语言模型,灵活性很高且极具发展潜力。\n### 关于本工具\n本工具旨在降低大语言模型的使用门槛,做到人人可用,本工具提供了全自动化的依赖和模型管理,你只需要直接点击运行,跟随引导,即可完成本地大语言模型的部署,工具本身体积极小,只需要一个exe即可完成一键部署。\n此外,本工具提供了与OpenAI API完全兼容的接口,这意味着你可以把任意ChatGPT客户端用作RWKV的客户端,实现能力拓展,而不局限于聊天。\n### 底部的预设配置规则\n本工具内置了一系列预设配置,以降低使用难度,每个配置名的规则,依次代表着:设备-所需显存/内存-模型规模-模型语言。\n例如,GPU-8G-3B-CN,表示该配置用于显卡,需要8G显存,模型规模为30亿参数,使用的是中文模型。\n模型规模越大,性能要求越高,显存要求也越高,而同样模型规模的配置中,显存占用越高的,运行速度越快。\n例如当你有12G显存,但运行GPU-12G-7B-CN配置速度比较慢,可降级成GPU-8G-3B-CN,将会大幅提速。\n### 关于RWKV\nRWKV是具有Transformer级别LLM性能的RNN,也可以像GPT Transformer一样直接进行训练(可并行化)。而且它是100% attention-free的。你只需在位置t处获得隐藏状态即可计算位置t + 1处的状态。你可以使用“GPT”模式快速计算用于“RNN”模式的隐藏状态。\n因此,它将RNN和Transformer的优点结合起来 - 高性能、快速推理、节省显存、快速训练、“无限”上下文长度以及免费的语句嵌入(使用最终隐藏状态)。"
|
||||
@@ -15,6 +15,47 @@
|
||||
}
|
||||
],
|
||||
"models": [
|
||||
{
|
||||
"name": "RWKV-x060-World-1B6-v2-20240208-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "RWKV-6 Global Languages 1.6B v2",
|
||||
"zh": "RWKV-6 全球语言 1.6B v2",
|
||||
"ja": "RWKV-6 グローバル言語 1.6B v2"
|
||||
},
|
||||
"size": 3199845663,
|
||||
"SHA256": "5c9c877fb60a65cab269af175328b6aaf16d02b8b09738923254f9986e5dc440",
|
||||
"lastUpdated": "2024-02-08T17:56:51",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-6-world/blob/main/RWKV-x060-World-1B6-v2-20240208-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-6-world/resolve/main/RWKV-x060-World-1B6-v2-20240208-ctx4096.pth",
|
||||
"tags": [
|
||||
"Official",
|
||||
"RWKV-6",
|
||||
"Global",
|
||||
"CN",
|
||||
"JP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RWKV-x060-World-3B-v2-20240228-ctx4096.pth",
|
||||
"desc": {
|
||||
"en": "RWKV-6 Global Languages 3B v2",
|
||||
"zh": "RWKV-6 全球语言 3B v2",
|
||||
"ja": "RWKV-6 グローバル言語 3B v2"
|
||||
},
|
||||
"size": 6199859158,
|
||||
"SHA256": "f1235079a07084472de86996846a6533e41e3964b153cdc1e8462cc138d8521d",
|
||||
"lastUpdated": "2024-02-29T03:53:53",
|
||||
"url": "https://huggingface.co/BlinkDL/rwkv-6-world/blob/main/RWKV-x060-World-3B-v2-20240228-ctx4096.pth",
|
||||
"downloadUrl": "https://huggingface.co/BlinkDL/rwkv-6-world/resolve/main/RWKV-x060-World-3B-v2-20240228-ctx4096.pth",
|
||||
"tags": [
|
||||
"Official",
|
||||
"RWKV-6",
|
||||
"Global",
|
||||
"Recommended",
|
||||
"CN",
|
||||
"JP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RWKV-5-World-0.1B-v1-20230803-ctx4096.pth",
|
||||
"desc": {
|
||||
@@ -252,6 +293,27 @@
|
||||
],
|
||||
"customTokenizer": "backend-python/rwkv_pip/rwkv_vocab_v20230424_special_token.txt"
|
||||
},
|
||||
{
|
||||
"name": "Mobius-r5-chat-12b-128k.pth",
|
||||
"desc": {
|
||||
"en": "RWKV-5 Mobius 12B Ctx128k",
|
||||
"zh": "RWKV-5 Mobius 12B 128k上下文",
|
||||
"ja": "RWKV-5 Mobius 12B 128kコンテキスト"
|
||||
},
|
||||
"size": 23157427004,
|
||||
"SHA256": "2190d59e130f8d9b580e5531874f34f7eaeb7b7b6d04fb1439b7f5c5d7dbaafe",
|
||||
"lastUpdated": "2024-02-24T01:33:27",
|
||||
"url": "https://huggingface.co/TimeMobius/Mobius-Chat-12B-128k/blob/main/Mobius-r5-chat-12b-128k.pth",
|
||||
"downloadUrl": "https://huggingface.co/TimeMobius/Mobius-Chat-12B-128k/resolve/main/Mobius-r5-chat-12b-128k.pth",
|
||||
"tags": [
|
||||
"Finetuned",
|
||||
"RWKV-5",
|
||||
"Global",
|
||||
"Recommended",
|
||||
"CN",
|
||||
"JP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RWKV-4-World-CHNtuned-0.1B-v1-20230617-ctx4096.pth",
|
||||
"desc": {
|
||||
|
||||
14
scripts/merge_manifest.py
Normal file
14
scripts/merge_manifest.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import glob
|
||||
import os, sys
|
||||
|
||||
MAIN_IMAGE_NAME=sys.argv[1]
|
||||
TARGET_TAG="latest" if len(sys.argv) < 3 else sys.argv[2]
|
||||
|
||||
args=["docker manifest create {}:{}".format(MAIN_IMAGE_NAME, TARGET_TAG)]
|
||||
for i in glob.glob("/tmp/images/*/*.txt"):
|
||||
with open(i, "r") as file:
|
||||
args += " --amend {}@{}".format(MAIN_IMAGE_NAME, file.readline().strip())
|
||||
cmd_create="".join(args)
|
||||
cmd_push="docker manifest push {}:{}".format(MAIN_IMAGE_NAME, TARGET_TAG)
|
||||
os.system(cmd_create)
|
||||
os.system(cmd_push)
|
||||
Reference in New Issue
Block a user