Skip to content

Latest commit

 

History

History
280 lines (198 loc) · 13.8 KB

README_JA.md

File metadata and controls

280 lines (198 loc) · 13.8 KB

RWKV Runner

このプロジェクトは、すべてを自動化することで、大規模な言語モデルを使用する際の障壁をなくすことを目的としています。必要なのは、 わずか数メガバイトの軽量な実行プログラムだけです。さらに、このプロジェクトは OpenAI API と互換性のあるインターフェイスを提供しており、 すべての ChatGPT クライアントは RWKV クライアントであることを意味します。

license release

English | 简体中文 | 日本語

インストール

Windows MacOS Linux

FAQs | プレビュー | ダウンロード | シンプルなデプロイの例 | サーバーデプロイ例 | MIDIハードウェア入力

ヒント

  • サーバーに backend-python をデプロイし、このプログラムをクライアントとして使用することができます。設定されたAPI URLにサーバーアドレスを入力してください。

  • もし、あなたがデプロイし、外部に公開するサービスを提供している場合、APIゲートウェイを使用してリクエストのサイズを制限し、 長すぎるプロンプトの提出がリソースを占有しないようにしてください。さらに、実際の状況に応じて、リクエストの max_tokens の上限を制限してください:https://github.com/josStorer/RWKV-Runner/blob/master/backend-python/utils/rwkv.py#L567 、デフォルトは le=102400 ですが、極端な場合には単一の応答が大量のリソースを消費する可能性があります。

  • デフォルトの設定はカスタム CUDA カーネルアクセラレーションを有効にしています。互換性の問題 (文字化けを出力する) が発生する可能性がある場合は、コンフィグページに移動し、Use Custom CUDA kernel to Accelerate をオフにしてください、あるいは、GPUドライバーをアップグレードしてみてください。

  • Windows Defender がこれをウイルスだと主張する場合は、v1.3.7_win.zip をダウンロードして最新版に自動更新させるか、信頼済みリストに追加してみてください (Windows Security -> Virus & threat protection -> Manage settings -> Exclusions -> Add or remove exclusions -> Add an exclusion -> Folder -> RWKV-Runner)。

  • 異なるタスクについては、API パラメータを調整することで、より良い結果を得ることができます。例えば、翻訳タスクの場合、Temperature を 1 に、Top_P を 0.3 に設定してみてください。

特徴

  • RWKV モデル管理とワンクリック起動
  • フロントエンドとバックエンドの分離は、クライアントを使用しない場合でも、フロントエンドサービス、またはバックエンド推論サービス、またはWebUIを備えたバックエンド推論サービスを個別に展開することを可能にします。 シンプルなデプロイの例 | サーバーデプロイ例
  • OpenAI API と互換性があり、すべての ChatGPT クライアントを RWKV クライアントにします。モデル起動後、 http:https://127.0.0.1:8000/docs を開いて詳細をご覧ください。
  • 依存関係の自動インストールにより、軽量な実行プログラムのみを必要とします
  • 事前設定された多段階のVRAM設定、ほとんどのコンピュータで動作します。配置ページで、ストラテジーをWebGPUに切り替えると、AMD、インテル、その他のグラフィックカードでも動作します
  • ユーザーフレンドリーなチャット、完成、および作曲インターフェイスが含まれています。また、チャットプリセット、添付ファイルのアップロード、MIDIハードウェア入力、トラック編集もサポートしています。 プレビュー | MIDIハードウェア入力
  • 内蔵WebUIオプション、Webサービスのワンクリック開始、ハードウェアリソースの共有
  • 分かりやすく操作しやすいパラメータ設定、各種操作ガイダンスプロンプトとともに
  • 内蔵モデル変換ツール
  • ダウンロード管理とリモートモデル検査機能内蔵
  • 内蔵のLoRA微調整機能を搭載しています (Windowsのみ)
  • このプログラムは、OpenAI ChatGPTとGPT Playgroundのクライアントとしても使用できます(設定ページで API URLAPI Key を入力してください)
  • 多言語ローカライズ
  • テーマ切り替え
  • 自動アップデート

Simple Deploy Example

git clone https://github.com/josStorer/RWKV-Runner

# Then
cd RWKV-Runner
python ./backend-python/main.py #The backend inference service has been started, request /switch-model API to load the model, refer to the API documentation: http:https://127.0.0.1:8000/docs

# Or
cd RWKV-Runner/frontend
npm ci
npm run build #Compile the frontend
cd ..
python ./backend-python/webui_server.py #Start the frontend service separately
# Or
python ./backend-python/main.py --webui #Start the frontend and backend service at the same time

# Help Info
python ./backend-python/main.py -h

API 同時実行ストレステスト

ab -p body.json -T application/json -c 20 -n 100 -l http:https://127.0.0.1:8000/chat/completions

body.json:

{
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}

埋め込み API の例

注意: v1.4.0 では、埋め込み API の品質が向上しました。生成される結果は、以前のバージョンとは互換性がありません。 もし、embeddings API を使って知識ベースなどを生成している場合は、再生成してください。

LangChain を使用している場合は、OpenAIEmbeddings(openai_api_base="http:https://127.0.0.1:8000", openai_api_key="sk-") を使用してください

import numpy as np
import requests


def cosine_similarity(a, b):
    return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))


values = [
    "I am a girl",
    "我是个女孩",
    "私は女の子です",
    "广东人爱吃福建人",
    "我是个人类",
    "I am a human",
    "that dog is so cute",
    "私はねこむすめです、にゃん♪",
    "宇宙级特大事件!号外号外!"
]

embeddings = []
for v in values:
    r = requests.post("http:https://127.0.0.1:8000/embeddings", json={"input": v})
    embedding = r.json()["data"][0]["embedding"]
    embeddings.append(embedding)

compared_embedding = embeddings[0]

embeddings_cos_sim = [cosine_similarity(compared_embedding, e) for e in embeddings]

for i in np.argsort(embeddings_cos_sim)[::-1]:
    print(f"{embeddings_cos_sim[i]:.10f} - {values[i]}")

MIDI Input

Tip: You can download https://github.com/josStorer/sgm_plus and unzip it to the program's assets/sound-font directory to use it as an offline sound source. Please note that if you are compiling the program from source code, do not place it in the source code directory.

MIDIキーボードをお持ちでない場合、Virtual Midi Controller 3 LE などの仮想MIDI入力ソフトウェアを使用することができます。loopMIDI を組み合わせて、通常のコンピュータキーボードをMIDI入力として使用できます。

USB MIDI Connection

  • USB MIDI devices are plug-and-play, and you can select your input device in the Composition page
  • image

Mac MIDI Bluetooth Connection

  • For Mac users who want to use Bluetooth input, please install Bluetooth MIDI Connect, then click the tray icon to connect after launching, afterwards, you can select your input device in the Composition page.
  • image

Windows MIDI Bluetooth Connection

  • Windows seems to have implemented Bluetooth MIDI support only for UWP (Universal Windows Platform) apps. Therefore, it requires multiple steps to establish a connection. We need to create a local virtual MIDI device and then launch a UWP application. Through this UWP application, we will redirect Bluetooth MIDI input to the virtual MIDI device, and then this software will listen to the input from the virtual MIDI device.
  • So, first, you need to download loopMIDI to create a virtual MIDI device. Click the plus sign in the bottom left corner to create the device.
  • image
  • Next, you need to download Bluetooth LE Explorer to discover and connect to Bluetooth MIDI devices. Click "Start" to search for devices, and then click "Pair" to bind the MIDI device.
  • image
  • Finally, you need to install MIDIberry, This UWP application can redirect Bluetooth MIDI input to the virtual MIDI device. After launching it, double-click your actual Bluetooth MIDI device name in the input field, and in the output field, double-click the virtual MIDI device name we created earlier.
  • image
  • Now, you can select the virtual MIDI device as the input in the Composition page. Bluetooth LE Explorer no longer needs to run, and you can also close the loopMIDI window, it will run automatically in the background. Just keep MIDIberry open.
  • image

関連リポジトリ:

Preview

ホームページ

image

チャット

image

image

補完

image

作曲

Tip: You can download https://github.com/josStorer/sgm_plus and unzip it to the program's assets/sound-font directory to use it as an offline sound source. Please note that if you are compiling the program from source code, do not place it in the source code directory.

image

image

コンフィグ

image

モデル管理

image

ダウンロード管理

image

LoRA Finetune

image

設定

image