Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7df10cb66 | ||
|
|
46e9a2f5b2 | ||
|
|
69b8d2e0a1 | ||
|
|
0ddd2e9fea | ||
|
|
01c95f5bc4 | ||
|
|
e0bf44d82f | ||
|
|
f328e84ea7 | ||
|
|
c81f5015a1 | ||
|
|
e2b086e2f7 | ||
|
|
da632565d5 | ||
|
|
556b667cc0 | ||
|
|
82c9825da8 | ||
|
|
26b30f0dbe | ||
|
|
be3b69c65c | ||
|
|
07cab6949e |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -98,6 +98,7 @@ jobs:
|
|||||||
rm ./backend-python/get-pip.py
|
rm ./backend-python/get-pip.py
|
||||||
rm ./backend-python/rwkv_pip/cpp/librwkv.dylib
|
rm ./backend-python/rwkv_pip/cpp/librwkv.dylib
|
||||||
rm ./backend-python/rwkv_pip/cpp/rwkv.dll
|
rm ./backend-python/rwkv_pip/cpp/rwkv.dll
|
||||||
|
rm ./backend-python/rwkv_pip/webgpu/web_rwkv_py.cp310-win_amd64.pyd
|
||||||
make
|
make
|
||||||
mv build/bin/RWKV-Runner build/bin/RWKV-Runner_linux_x64
|
mv build/bin/RWKV-Runner build/bin/RWKV-Runner_linux_x64
|
||||||
|
|
||||||
@@ -124,6 +125,7 @@ jobs:
|
|||||||
rm ./backend-python/get-pip.py
|
rm ./backend-python/get-pip.py
|
||||||
rm ./backend-python/rwkv_pip/cpp/rwkv.dll
|
rm ./backend-python/rwkv_pip/cpp/rwkv.dll
|
||||||
rm ./backend-python/rwkv_pip/cpp/librwkv.so
|
rm ./backend-python/rwkv_pip/cpp/librwkv.so
|
||||||
|
rm ./backend-python/rwkv_pip/webgpu/web_rwkv_py.cp310-win_amd64.pyd
|
||||||
make
|
make
|
||||||
cp build/darwin/Readme_Install.txt build/bin/Readme_Install.txt
|
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
|
cp build/bin/RWKV-Runner.app/Contents/MacOS/RWKV-Runner build/bin/RWKV-Runner_darwin_universal
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
- rwkv.cpp(ggml) support
|
- add WebGPU Python Mode (https://github.com/cryscan/web-rwkv-py)
|
||||||
- allow playing mid with external player
|
- bump MIDI-LLM-tokenizer (fix note off)
|
||||||
- allow overriding Core API URL
|
- fix refreshBuiltInModels
|
||||||
- chore
|
- chore
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|||||||
@@ -204,6 +204,10 @@ func (a *App) OpenFileFolder(path string, relative bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) StartFile(path string) error {
|
func (a *App) StartFile(path string) error {
|
||||||
_, err := CmdHelper(path)
|
cmd, err := CmdHelper(true, path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = cmd.Start()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *App) StartServer(python string, port int, host string, webui bool, rwkvBeta bool, rwkvcpp bool) (string, error) {
|
func (a *App) StartServer(python string, port int, host string, webui bool, rwkvBeta bool, rwkvcpp bool, webgpu bool) (string, error) {
|
||||||
var err error
|
var err error
|
||||||
if python == "" {
|
if python == "" {
|
||||||
python, err = GetPython()
|
python, err = GetPython()
|
||||||
@@ -28,6 +28,9 @@ func (a *App) StartServer(python string, port int, host string, webui bool, rwkv
|
|||||||
if rwkvcpp {
|
if rwkvcpp {
|
||||||
args = append(args, "--rwkv.cpp")
|
args = append(args, "--rwkv.cpp")
|
||||||
}
|
}
|
||||||
|
if webgpu {
|
||||||
|
args = append(args, "--webgpu")
|
||||||
|
}
|
||||||
args = append(args, "--port", strconv.Itoa(port), "--host", host)
|
args = append(args, "--port", strconv.Itoa(port), "--host", host)
|
||||||
return Cmd(args...)
|
return Cmd(args...)
|
||||||
}
|
}
|
||||||
@@ -55,6 +58,17 @@ func (a *App) ConvertSafetensors(modelPath string, outPath string) (string, erro
|
|||||||
return Cmd(args...)
|
return Cmd(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) ConvertSafetensorsWithPython(python string, modelPath string, outPath string) (string, error) {
|
||||||
|
var err error
|
||||||
|
if python == "" {
|
||||||
|
python, err = GetPython()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return Cmd(python, "./backend-python/convert_safetensors.py", "--input", modelPath, "--output", outPath)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) ConvertGGML(python string, modelPath string, outPath string, Q51 bool) (string, error) {
|
func (a *App) ConvertGGML(python string, modelPath string, outPath string, Q51 bool) (string, error) {
|
||||||
var err error
|
var err error
|
||||||
if python == "" {
|
if python == "" {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CmdHelper(args ...string) (*exec.Cmd, error) {
|
func CmdHelper(hideWindow bool, args ...string) (*exec.Cmd, error) {
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
return nil, errors.New("unsupported OS")
|
return nil, errors.New("unsupported OS")
|
||||||
}
|
}
|
||||||
@@ -43,22 +43,21 @@ func CmdHelper(args ...string) (*exec.Cmd, error) {
|
|||||||
}
|
}
|
||||||
cmd := exec.Command(cmdHelper, args...)
|
cmd := exec.Command(cmdHelper, args...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
//go:custom_build windows cmd.SysProcAttr.HideWindow = true
|
//go:custom_build windows cmd.SysProcAttr.HideWindow = hideWindow
|
||||||
err = cmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Cmd(args ...string) (string, error) {
|
func Cmd(args ...string) (string, error) {
|
||||||
switch platform := runtime.GOOS; platform {
|
switch platform := runtime.GOOS; platform {
|
||||||
case "windows":
|
case "windows":
|
||||||
cmd, err := CmdHelper(args...)
|
cmd, err := CmdHelper(true, args...)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
_, err = cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
cmd.Wait()
|
|
||||||
return "", nil
|
return "", nil
|
||||||
case "darwin":
|
case "darwin":
|
||||||
ex, err := os.Executable()
|
ex, err := os.Executable()
|
||||||
|
|||||||
27
backend-python/convert_safetensors.py
vendored
27
backend-python/convert_safetensors.py
vendored
@@ -30,6 +30,33 @@ def convert_file(pt_filename: str, sf_filename: str, rename={}, transpose_names=
|
|||||||
if "state_dict" in loaded:
|
if "state_dict" in loaded:
|
||||||
loaded = loaded["state_dict"]
|
loaded = loaded["state_dict"]
|
||||||
|
|
||||||
|
kk = list(loaded.keys())
|
||||||
|
version = 4
|
||||||
|
for x in kk:
|
||||||
|
if "ln_x" in x:
|
||||||
|
version = max(5, version)
|
||||||
|
if "gate.weight" in x:
|
||||||
|
version = max(5.1, version)
|
||||||
|
if int(version) == 5 and "att.time_decay" in x:
|
||||||
|
if len(loaded[x].shape) > 1:
|
||||||
|
if loaded[x].shape[1] > 1:
|
||||||
|
version = max(5.2, version)
|
||||||
|
if "time_maa" in x:
|
||||||
|
version = max(6, version)
|
||||||
|
|
||||||
|
if version == 5.1 and "midi" in pt_filename.lower():
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
np.set_printoptions(precision=4, suppress=True, linewidth=200)
|
||||||
|
kk = list(loaded.keys())
|
||||||
|
_, n_emb = loaded["emb.weight"].shape
|
||||||
|
for k in kk:
|
||||||
|
if "time_decay" in k or "time_faaaa" in k:
|
||||||
|
# print(k, mm[k].shape)
|
||||||
|
loaded[k] = (
|
||||||
|
loaded[k].unsqueeze(1).repeat(1, n_emb // loaded[k].shape[0])
|
||||||
|
)
|
||||||
|
|
||||||
loaded = {k: v.clone().half() for k, v in loaded.items()}
|
loaded = {k: v.clone().half() for k, v in loaded.items()}
|
||||||
# for k, v in loaded.items():
|
# for k, v in loaded.items():
|
||||||
# print(f'{k}\t{v.shape}\t{v.dtype}')
|
# print(f'{k}\t{v.shape}\t{v.dtype}')
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ def get_args(args: Union[Sequence[str], None] = None):
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="whether to use rwkv.cpp (default: False)",
|
help="whether to use rwkv.cpp (default: False)",
|
||||||
)
|
)
|
||||||
|
group.add_argument(
|
||||||
|
"--webgpu",
|
||||||
|
action="store_true",
|
||||||
|
help="whether to use webgpu (default: False)",
|
||||||
|
)
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import base64
|
|||||||
from fastapi import APIRouter, Request, status, HTTPException
|
from fastapi import APIRouter, Request, status, HTTPException
|
||||||
from sse_starlette.sse import EventSourceResponse
|
from sse_starlette.sse import EventSourceResponse
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
import numpy as np
|
|
||||||
import tiktoken
|
import tiktoken
|
||||||
from utils.rwkv import *
|
from utils.rwkv import *
|
||||||
from utils.log import quick_log
|
from utils.log import quick_log
|
||||||
@@ -396,6 +395,8 @@ class EmbeddingsBody(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
def embedding_base64(embedding: List[float]) -> str:
|
def embedding_base64(embedding: List[float]) -> str:
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
return base64.b64encode(np.array(embedding).astype(np.float32)).decode("utf-8")
|
return base64.b64encode(np.array(embedding).astype(np.float32)).decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ def switch_model(body: SwitchModelBody, response: Response, request: Request):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
print(traceback.format_exc())
|
||||||
|
|
||||||
quick_log(request, body, f"Exception: {e}")
|
quick_log(request, body, f"Exception: {e}")
|
||||||
global_var.set(global_var.Model_Status, global_var.ModelStatus.Offline)
|
global_var.set(global_var.Model_Status, global_var.ModelStatus.Offline)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -37,10 +37,14 @@ def text_to_midi(body: TextToMidiBody):
|
|||||||
async def midi_to_text(file_data: UploadFile):
|
async def midi_to_text(file_data: UploadFile):
|
||||||
vocab_config = "backend-python/utils/midi_vocab_config.json"
|
vocab_config = "backend-python/utils/midi_vocab_config.json"
|
||||||
cfg = VocabConfig.from_json(vocab_config)
|
cfg = VocabConfig.from_json(vocab_config)
|
||||||
|
filter_config = "backend-python/utils/midi_filter_config.json"
|
||||||
|
filter_cfg = FilterConfig.from_json(filter_config)
|
||||||
mid = mido.MidiFile(file=file_data.file)
|
mid = mido.MidiFile(file=file_data.file)
|
||||||
text = convert_midi_to_str(cfg, mid)
|
output_list = convert_midi_to_str(cfg, filter_cfg, mid)
|
||||||
|
if len(output_list) == 0:
|
||||||
|
raise HTTPException(status.HTTP_400_BAD_REQUEST, "bad midi file")
|
||||||
|
|
||||||
return {"text": text}
|
return {"text": output_list[0]}
|
||||||
|
|
||||||
|
|
||||||
class TxtToMidiBody(BaseModel):
|
class TxtToMidiBody(BaseModel):
|
||||||
|
|||||||
@@ -87,18 +87,34 @@ def add_state(body: AddStateBody):
|
|||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
devices: List[torch.device] = []
|
||||||
|
state: Union[Any, None] = None
|
||||||
|
|
||||||
|
if body.state is not None:
|
||||||
|
if type(body.state) == list or type(body.state) == np.ndarray:
|
||||||
|
devices = [
|
||||||
|
(
|
||||||
|
tensor.device
|
||||||
|
if hasattr(tensor, "device")
|
||||||
|
else torch.device("cpu")
|
||||||
|
)
|
||||||
|
for tensor in body.state
|
||||||
|
]
|
||||||
|
state = (
|
||||||
|
[tensor.cpu() for tensor in body.state]
|
||||||
|
if hasattr(body.state[0], "device")
|
||||||
|
else copy.deepcopy(body.state)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
pass # WebGPU
|
||||||
|
|
||||||
id: int = trie.insert(body.prompt)
|
id: int = trie.insert(body.prompt)
|
||||||
devices: List[torch.device] = [
|
|
||||||
(tensor.device if hasattr(tensor, "device") else torch.device("cpu"))
|
|
||||||
for tensor in body.state
|
|
||||||
]
|
|
||||||
dtrie[id] = {
|
dtrie[id] = {
|
||||||
"tokens": copy.deepcopy(body.tokens),
|
"tokens": copy.deepcopy(body.tokens),
|
||||||
"state": [tensor.cpu() for tensor in body.state]
|
"state": state,
|
||||||
if hasattr(body.state[0], "device")
|
|
||||||
else copy.deepcopy(body.state),
|
|
||||||
"logits": copy.deepcopy(body.logits),
|
"logits": copy.deepcopy(body.logits),
|
||||||
"devices": devices,
|
"devices": devices,
|
||||||
}
|
}
|
||||||
@@ -174,6 +190,7 @@ def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
|
|||||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
raise HTTPException(status.HTTP_400_BAD_REQUEST, "trie not loaded")
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
id = -1
|
id = -1
|
||||||
try:
|
try:
|
||||||
@@ -185,14 +202,16 @@ def longest_prefix_state(body: LongestPrefixStateBody, request: Request):
|
|||||||
v = dtrie[id]
|
v = dtrie[id]
|
||||||
devices: List[torch.device] = v["devices"]
|
devices: List[torch.device] = v["devices"]
|
||||||
prompt: str = trie[id]
|
prompt: str = trie[id]
|
||||||
|
state: Union[Any, None] = v["state"]
|
||||||
|
|
||||||
|
if state is not None and type(state) == list and hasattr(state[0], "device"):
|
||||||
|
state = [tensor.to(devices[i]) for i, tensor in enumerate(state)]
|
||||||
|
|
||||||
quick_log(request, body, "Hit:\n" + prompt)
|
quick_log(request, body, "Hit:\n" + prompt)
|
||||||
return {
|
return {
|
||||||
"prompt": prompt,
|
"prompt": prompt,
|
||||||
"tokens": v["tokens"],
|
"tokens": v["tokens"],
|
||||||
"state": [tensor.to(devices[i]) for i, tensor in enumerate(v["state"])]
|
"state": state,
|
||||||
if hasattr(v["state"][0], "device")
|
|
||||||
else v["state"],
|
|
||||||
"logits": v["logits"],
|
"logits": v["logits"],
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
|||||||
4
backend-python/rwkv_pip/cpp/model.py
vendored
4
backend-python/rwkv_pip/cpp/model.py
vendored
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List
|
from typing import Any, List, Union
|
||||||
from . import rwkv_cpp_model
|
from . import rwkv_cpp_model
|
||||||
from . import rwkv_cpp_shared_library
|
from . import rwkv_cpp_shared_library
|
||||||
|
|
||||||
@@ -10,5 +10,5 @@ class RWKV:
|
|||||||
self.w = {} # fake weight
|
self.w = {} # fake weight
|
||||||
self.w["emb.weight"] = [0] * self.model.n_vocab
|
self.w["emb.weight"] = [0] * self.model.n_vocab
|
||||||
|
|
||||||
def forward(self, tokens: List[int], state: Any | None):
|
def forward(self, tokens: List[int], state: Union[Any, None] = None):
|
||||||
return self.model.eval_sequence_in_chunks(tokens, state, use_numpy=True)
|
return self.model.eval_sequence_in_chunks(tokens, state, use_numpy=True)
|
||||||
|
|||||||
2
backend-python/rwkv_pip/utils.py
vendored
2
backend-python/rwkv_pip/utils.py
vendored
@@ -84,6 +84,8 @@ class PIPELINE:
|
|||||||
return e / e.sum(axis=axis, keepdims=True)
|
return e / e.sum(axis=axis, keepdims=True)
|
||||||
|
|
||||||
def sample_logits(self, logits, temperature=1.0, top_p=0.85, top_k=0):
|
def sample_logits(self, logits, temperature=1.0, top_p=0.85, top_k=0):
|
||||||
|
if type(logits) == list:
|
||||||
|
logits = np.array(logits)
|
||||||
np_logits = type(logits) == np.ndarray
|
np_logits = type(logits) == np.ndarray
|
||||||
if np_logits:
|
if np_logits:
|
||||||
probs = self.np_softmax(logits, axis=-1)
|
probs = self.np_softmax(logits, axis=-1)
|
||||||
|
|||||||
21
backend-python/rwkv_pip/webgpu/model.py
vendored
Normal file
21
backend-python/rwkv_pip/webgpu/model.py
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from typing import Any, List, Union
|
||||||
|
|
||||||
|
try:
|
||||||
|
import web_rwkv_py as wrp
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
try:
|
||||||
|
from . import web_rwkv_py as wrp
|
||||||
|
except ImportError:
|
||||||
|
raise ModuleNotFoundError(
|
||||||
|
"web_rwkv_py not found, install it from https://github.com/cryscan/web-rwkv-py"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class RWKV:
|
||||||
|
def __init__(self, model_path: str, strategy=None):
|
||||||
|
self.model = wrp.v5.Model(model_path, turbo=False)
|
||||||
|
self.w = {} # fake weight
|
||||||
|
self.w["emb.weight"] = [0] * wrp.peek_info(model_path).num_vocab
|
||||||
|
|
||||||
|
def forward(self, tokens: List[int], state: Union[Any, None] = None):
|
||||||
|
return wrp.v5.run_one(self.model, tokens, state)
|
||||||
BIN
backend-python/rwkv_pip/webgpu/web_rwkv_py.cp310-win_amd64.pyd
vendored
Normal file
BIN
backend-python/rwkv_pip/webgpu/web_rwkv_py.cp310-win_amd64.pyd
vendored
Normal file
Binary file not shown.
71
backend-python/utils/midi.py
vendored
71
backend-python/utils/midi.py
vendored
@@ -52,6 +52,8 @@ class VocabConfig:
|
|||||||
bin_name_to_program_name: Dict[str, str]
|
bin_name_to_program_name: Dict[str, str]
|
||||||
# Mapping from program number to instrument name.
|
# Mapping from program number to instrument name.
|
||||||
instrument_names: Dict[str, str]
|
instrument_names: Dict[str, str]
|
||||||
|
# Manual override for velocity bins. Each element is the max velocity value for that bin by index.
|
||||||
|
velocity_bins_override: Optional[List[int]] = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.validate()
|
self.validate()
|
||||||
@@ -116,6 +118,12 @@ class VocabConfig:
|
|||||||
raise ValueError("velocity_bins must be at least 2")
|
raise ValueError("velocity_bins must be at least 2")
|
||||||
if len(self.bin_instrument_names) > 16:
|
if len(self.bin_instrument_names) > 16:
|
||||||
raise ValueError("bin_instruments must have at most 16 values")
|
raise ValueError("bin_instruments must have at most 16 values")
|
||||||
|
if self.velocity_bins_override:
|
||||||
|
print("VocabConfig is using velocity_bins_override. Ignoring velocity_exp.")
|
||||||
|
if len(self.velocity_bins_override) != self.velocity_bins:
|
||||||
|
raise ValueError(
|
||||||
|
"velocity_bins_override must have same length as velocity_bins"
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
self.ch10_instrument_bin_name
|
self.ch10_instrument_bin_name
|
||||||
and self.ch10_instrument_bin_name not in self.bin_instrument_names
|
and self.ch10_instrument_bin_name not in self.bin_instrument_names
|
||||||
@@ -156,6 +164,11 @@ class VocabUtils:
|
|||||||
|
|
||||||
def velocity_to_bin(self, velocity: float) -> int:
|
def velocity_to_bin(self, velocity: float) -> int:
|
||||||
velocity = max(0, min(velocity, self.cfg.velocity_events - 1))
|
velocity = max(0, min(velocity, self.cfg.velocity_events - 1))
|
||||||
|
if self.cfg.velocity_bins_override:
|
||||||
|
for i, v in enumerate(self.cfg.velocity_bins_override):
|
||||||
|
if velocity <= v:
|
||||||
|
return i
|
||||||
|
return 0
|
||||||
binsize = self.cfg.velocity_events / (self.cfg.velocity_bins - 1)
|
binsize = self.cfg.velocity_events / (self.cfg.velocity_bins - 1)
|
||||||
if self.cfg.velocity_exp == 1.0:
|
if self.cfg.velocity_exp == 1.0:
|
||||||
return ceil(velocity / binsize)
|
return ceil(velocity / binsize)
|
||||||
@@ -176,6 +189,8 @@ class VocabUtils:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def bin_to_velocity(self, bin: int) -> int:
|
def bin_to_velocity(self, bin: int) -> int:
|
||||||
|
if self.cfg.velocity_bins_override:
|
||||||
|
return self.cfg.velocity_bins_override[bin]
|
||||||
binsize = self.cfg.velocity_events / (self.cfg.velocity_bins - 1)
|
binsize = self.cfg.velocity_events / (self.cfg.velocity_bins - 1)
|
||||||
if self.cfg.velocity_exp == 1.0:
|
if self.cfg.velocity_exp == 1.0:
|
||||||
return max(0, ceil(bin * binsize - 1))
|
return max(0, ceil(bin * binsize - 1))
|
||||||
@@ -358,13 +373,32 @@ class AugmentConfig:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class FilterConfig:
|
||||||
|
# Whether to filter out MIDI files with duplicate MD5 hashes.
|
||||||
|
deduplicate_md5: bool
|
||||||
|
# Minimum time delay between notes in a file before splitting into multiple documents.
|
||||||
|
piece_split_delay: float
|
||||||
|
# Minimum length of a piece in milliseconds.
|
||||||
|
min_piece_length: float
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, path: str):
|
||||||
|
with open(path, "r") as f:
|
||||||
|
config = json.load(f)
|
||||||
|
return cls(**config)
|
||||||
|
|
||||||
|
|
||||||
def mix_volume(velocity: int, volume: int, expression: int) -> float:
|
def mix_volume(velocity: int, volume: int, expression: int) -> float:
|
||||||
return velocity * (volume / 127.0) * (expression / 127.0)
|
return velocity * (volume / 127.0) * (expression / 127.0)
|
||||||
|
|
||||||
|
|
||||||
def convert_midi_to_str(
|
def convert_midi_to_str(
|
||||||
cfg: VocabConfig, mid: mido.MidiFile, augment: AugmentValues = None
|
cfg: VocabConfig,
|
||||||
) -> str:
|
filter_cfg: FilterConfig,
|
||||||
|
mid: mido.MidiFile,
|
||||||
|
augment: AugmentValues = None,
|
||||||
|
) -> List[str]:
|
||||||
utils = VocabUtils(cfg)
|
utils = VocabUtils(cfg)
|
||||||
if augment is None:
|
if augment is None:
|
||||||
augment = AugmentValues.default()
|
augment = AugmentValues.default()
|
||||||
@@ -390,7 +424,9 @@ def convert_midi_to_str(
|
|||||||
} # {channel: {(note, program) -> True}}
|
} # {channel: {(note, program) -> True}}
|
||||||
started_flag = False
|
started_flag = False
|
||||||
|
|
||||||
|
output_list = []
|
||||||
output = ["<start>"]
|
output = ["<start>"]
|
||||||
|
output_length_ms = 0.0
|
||||||
token_data_buffer: List[
|
token_data_buffer: List[
|
||||||
Tuple[int, int, int, float]
|
Tuple[int, int, int, float]
|
||||||
] = [] # need to sort notes between wait tokens
|
] = [] # need to sort notes between wait tokens
|
||||||
@@ -432,16 +468,33 @@ def convert_midi_to_str(
|
|||||||
token_data_buffer = []
|
token_data_buffer = []
|
||||||
|
|
||||||
def consume_note_program_data(prog: int, chan: int, note: int, vel: float):
|
def consume_note_program_data(prog: int, chan: int, note: int, vel: float):
|
||||||
nonlocal output, started_flag, delta_time_ms, cfg, utils, token_data_buffer
|
nonlocal output, output_length_ms, started_flag, delta_time_ms, cfg, utils, token_data_buffer
|
||||||
is_token_valid = (
|
is_token_valid = (
|
||||||
utils.prog_data_to_token_data(prog, chan, note, vel) is not None
|
utils.prog_data_to_token_data(prog, chan, note, vel) is not None
|
||||||
)
|
)
|
||||||
if not is_token_valid:
|
if not is_token_valid:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if delta_time_ms > filter_cfg.piece_split_delay * 1000.0:
|
||||||
|
# check if any notes are still held
|
||||||
|
silent = True
|
||||||
|
for channel in channel_notes.keys():
|
||||||
|
if len(channel_notes[channel]) > 0:
|
||||||
|
silent = False
|
||||||
|
break
|
||||||
|
if silent:
|
||||||
|
flush_token_data_buffer()
|
||||||
|
output.append("<end>")
|
||||||
|
if output_length_ms > filter_cfg.min_piece_length * 1000.0:
|
||||||
|
output_list.append(" ".join(output))
|
||||||
|
output = ["<start>"]
|
||||||
|
output_length_ms = 0.0
|
||||||
|
started_flag = False
|
||||||
if started_flag:
|
if started_flag:
|
||||||
wait_tokens = utils.data_to_wait_tokens(delta_time_ms)
|
wait_tokens = utils.data_to_wait_tokens(delta_time_ms)
|
||||||
if len(wait_tokens) > 0:
|
if len(wait_tokens) > 0:
|
||||||
flush_token_data_buffer()
|
flush_token_data_buffer()
|
||||||
|
output_length_ms += delta_time_ms
|
||||||
output += wait_tokens
|
output += wait_tokens
|
||||||
delta_time_ms = 0.0
|
delta_time_ms = 0.0
|
||||||
token_data_buffer.append((prog, chan, note, vel * augment.velocity_mod_factor))
|
token_data_buffer.append((prog, chan, note, vel * augment.velocity_mod_factor))
|
||||||
@@ -510,7 +563,9 @@ def convert_midi_to_str(
|
|||||||
|
|
||||||
flush_token_data_buffer()
|
flush_token_data_buffer()
|
||||||
output.append("<end>")
|
output.append("<end>")
|
||||||
return " ".join(output)
|
if output_length_ms > filter_cfg.min_piece_length * 1000.0:
|
||||||
|
output_list.append(" ".join(output))
|
||||||
|
return output_list
|
||||||
|
|
||||||
|
|
||||||
def generate_program_change_messages(cfg: VocabConfig):
|
def generate_program_change_messages(cfg: VocabConfig):
|
||||||
@@ -633,10 +688,10 @@ def token_to_midi_message(
|
|||||||
if utils.cfg.decode_fix_repeated_notes:
|
if utils.cfg.decode_fix_repeated_notes:
|
||||||
if (channel, note) in state.active_notes:
|
if (channel, note) in state.active_notes:
|
||||||
del state.active_notes[(channel, note)]
|
del state.active_notes[(channel, note)]
|
||||||
yield mido.Message(
|
yield mido.Message(
|
||||||
"note_off", note=note, time=ticks, channel=channel
|
"note_off", note=note, time=ticks, channel=channel
|
||||||
), state
|
), state
|
||||||
ticks = 0
|
ticks = 0
|
||||||
state.active_notes[(channel, note)] = state.total_time
|
state.active_notes[(channel, note)] = state.total_time
|
||||||
yield mido.Message(
|
yield mido.Message(
|
||||||
"note_on", note=note, velocity=velocity, time=ticks, channel=channel
|
"note_on", note=note, velocity=velocity, time=ticks, channel=channel
|
||||||
|
|||||||
5
backend-python/utils/midi_filter_config.json
Normal file
5
backend-python/utils/midi_filter_config.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"deduplicate_md5": true,
|
||||||
|
"piece_split_delay": 10.0,
|
||||||
|
"min_piece_length": 30.0
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ from typing import Dict, Iterable, List, Tuple, Union, Type
|
|||||||
from utils.log import quick_log
|
from utils.log import quick_log
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
import numpy as np
|
|
||||||
from routes import state_cache
|
from routes import state_cache
|
||||||
import global_var
|
import global_var
|
||||||
|
|
||||||
@@ -68,6 +67,8 @@ class AbstractRWKV(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_embedding(self, input: str, fast_mode: bool) -> Tuple[List[float], int]:
|
def get_embedding(self, input: str, fast_mode: bool) -> Tuple[List[float], int]:
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
if fast_mode:
|
if fast_mode:
|
||||||
embedding, token_len = self.__fast_embedding(
|
embedding, token_len = self.__fast_embedding(
|
||||||
self.fix_tokens(self.pipeline.encode(input)), None
|
self.fix_tokens(self.pipeline.encode(input)), None
|
||||||
@@ -222,6 +223,8 @@ class AbstractRWKV(ABC):
|
|||||||
def generate(
|
def generate(
|
||||||
self, prompt: str, stop: Union[str, List[str], None] = None
|
self, prompt: str, stop: Union[str, List[str], None] = None
|
||||||
) -> Iterable[Tuple[str, str, int, int]]:
|
) -> Iterable[Tuple[str, str, int, int]]:
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
quick_log(None, None, "Generation Prompt:\n" + prompt)
|
quick_log(None, None, "Generation Prompt:\n" + prompt)
|
||||||
cache = None
|
cache = None
|
||||||
delta_prompt = prompt
|
delta_prompt = prompt
|
||||||
@@ -231,7 +234,7 @@ class AbstractRWKV(ABC):
|
|||||||
)
|
)
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
pass
|
pass
|
||||||
if cache is None or cache["prompt"] == "":
|
if cache is None or cache["prompt"] == "" or cache["state"] is None:
|
||||||
self.model_state = None
|
self.model_state = None
|
||||||
self.model_tokens = []
|
self.model_tokens = []
|
||||||
else:
|
else:
|
||||||
@@ -511,6 +514,7 @@ def get_tokenizer(tokenizer_len: int):
|
|||||||
def RWKV(model: str, strategy: str, tokenizer: Union[str, None]) -> AbstractRWKV:
|
def RWKV(model: str, strategy: str, tokenizer: Union[str, None]) -> AbstractRWKV:
|
||||||
rwkv_beta = global_var.get(global_var.Args).rwkv_beta
|
rwkv_beta = global_var.get(global_var.Args).rwkv_beta
|
||||||
rwkv_cpp = getattr(global_var.get(global_var.Args), "rwkv.cpp")
|
rwkv_cpp = getattr(global_var.get(global_var.Args), "rwkv.cpp")
|
||||||
|
webgpu = global_var.get(global_var.Args).webgpu
|
||||||
|
|
||||||
if "midi" in model.lower() or "abc" in model.lower():
|
if "midi" in model.lower() or "abc" in model.lower():
|
||||||
os.environ["RWKV_RESCALE_LAYER"] = "999"
|
os.environ["RWKV_RESCALE_LAYER"] = "999"
|
||||||
@@ -526,6 +530,11 @@ def RWKV(model: str, strategy: str, tokenizer: Union[str, None]) -> AbstractRWKV
|
|||||||
from rwkv_pip.cpp.model import (
|
from rwkv_pip.cpp.model import (
|
||||||
RWKV as Model,
|
RWKV as Model,
|
||||||
)
|
)
|
||||||
|
elif webgpu:
|
||||||
|
print("Using webgpu")
|
||||||
|
from rwkv_pip.webgpu.model import (
|
||||||
|
RWKV as Model,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
from rwkv_pip.model import (
|
from rwkv_pip.model import (
|
||||||
RWKV as Model,
|
RWKV as Model,
|
||||||
|
|||||||
5
build/darwin/Readme_Install.txt
vendored
5
build/darwin/Readme_Install.txt
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
Client Download URL:
|
||||||
|
客户端下载地址:
|
||||||
|
クライアントのダウンロードURL:
|
||||||
|
https://github.com/josStorer/RWKV-Runner/releases/latest/download/RWKV-Runner_macos_universal.zip
|
||||||
|
|
||||||
For Mac and Linux users, please manually install Python 3.10 (usually the latest systems come with it built-in). You can specify the Python interpreter to use in Settings. (which python3)
|
For Mac and Linux users, please manually install Python 3.10 (usually the latest systems come with it built-in). You can specify the Python interpreter to use in Settings. (which python3)
|
||||||
对于Mac和Linux用户,请手动安装 Python3.10 (通常最新的系统已经内置了). 你可以在设置中指定使用的Python解释器. (which python3)
|
对于Mac和Linux用户,请手动安装 Python3.10 (通常最新的系统已经内置了). 你可以在设置中指定使用的Python解释器. (which python3)
|
||||||
MacおよびLinuxのユーザーの方は、Python3.10を手動でインストールしてください(通常、最新のシステムには既に組み込まれています)。 設定メニューで使用するPythonインタプリタを指定することができます。 (which python3)
|
MacおよびLinuxのユーザーの方は、Python3.10を手動でインストールしてください(通常、最新のシステムには既に組み込まれています)。 設定メニューで使用するPythonインタプリタを指定することができます。 (which python3)
|
||||||
|
|||||||
5
build/linux/Readme_Install.txt
vendored
5
build/linux/Readme_Install.txt
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
Client Download URL:
|
||||||
|
客户端下载地址:
|
||||||
|
クライアントのダウンロードURL:
|
||||||
|
https://github.com/josStorer/RWKV-Runner/releases/latest/download/RWKV-Runner_linux_x64
|
||||||
|
|
||||||
For Mac and Linux users, please manually install Python 3.10 (usually the latest systems come with it built-in). You can specify the Python interpreter to use in Settings.
|
For Mac and Linux users, please manually install Python 3.10 (usually the latest systems come with it built-in). You can specify the Python interpreter to use in Settings.
|
||||||
对于Mac和Linux用户,请手动安装 Python3.10 (通常最新的系统已经内置了). 你可以在设置中指定使用的Python解释器.
|
对于Mac和Linux用户,请手动安装 Python3.10 (通常最新的系统已经内置了). 你可以在设置中指定使用的Python解释器.
|
||||||
MacおよびLinuxのユーザーの方は、Python3.10を手動でインストールしてください(通常、最新のシステムには既に組み込まれています)。 設定メニューで使用するPythonインタプリタを指定することができます。
|
MacおよびLinuxのユーザーの方は、Python3.10を手動でインストールしてください(通常、最新のシステムには既に組み込まれています)。 設定メニューで使用するPythonインタプリタを指定することができます。
|
||||||
|
|||||||
5
build/windows/Readme_Install.txt
vendored
5
build/windows/Readme_Install.txt
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
Client Download URL:
|
||||||
|
客户端下载地址:
|
||||||
|
クライアントのダウンロードURL:
|
||||||
|
https://github.com/josStorer/RWKV-Runner/releases/latest/download/RWKV-Runner_windows_x64.exe
|
||||||
|
|
||||||
Please execute this program in an empty directory. All related dependencies will be placed in this directory.
|
Please execute this program in an empty directory. All related dependencies will be placed in this directory.
|
||||||
请将本程序放在一个空目录内执行, 所有相关依赖均会放置于此目录.
|
请将本程序放在一个空目录内执行, 所有相关依赖均会放置于此目录.
|
||||||
このプログラムを空のディレクトリで実行してください。関連するすべての依存関係は、このディレクトリに配置されます。
|
このプログラムを空のディレクトリで実行してください。関連するすべての依存関係は、このディレクトリに配置されます。
|
||||||
|
|||||||
@@ -319,5 +319,6 @@
|
|||||||
"CPU (rwkv.cpp, Faster)": "CPU (rwkv.cpp, 高速)",
|
"CPU (rwkv.cpp, Faster)": "CPU (rwkv.cpp, 高速)",
|
||||||
"Play With External Player": "外部プレーヤーで再生",
|
"Play With External Player": "外部プレーヤーで再生",
|
||||||
"Core API URL": "コアAPI URL",
|
"Core API URL": "コアAPI URL",
|
||||||
"Override core API URL(/chat/completions and /completions). If you don't know what this is, leave it blank.": "コアAPI URLを上書きします(/chat/completions と /completions)。何であるかわからない場合は空白のままにしてください。"
|
"Override core API URL(/chat/completions and /completions). If you don't know what this is, leave it blank.": "コアAPI URLを上書きします(/chat/completions と /completions)。何であるかわからない場合は空白のままにしてください。",
|
||||||
|
"Please change Strategy to CPU (rwkv.cpp) to use ggml format": "StrategyをCPU (rwkv.cpp)に変更して、ggml形式を使用してください"
|
||||||
}
|
}
|
||||||
@@ -319,5 +319,6 @@
|
|||||||
"CPU (rwkv.cpp, Faster)": "CPU (rwkv.cpp, 更快)",
|
"CPU (rwkv.cpp, Faster)": "CPU (rwkv.cpp, 更快)",
|
||||||
"Play With External Player": "使用外部播放器播放",
|
"Play With External Player": "使用外部播放器播放",
|
||||||
"Core API URL": "核心 API URL",
|
"Core API URL": "核心 API URL",
|
||||||
"Override core API URL(/chat/completions and /completions). If you don't know what this is, leave it blank.": "覆盖核心的 API URL (/chat/completions 和 /completions)。如果你不知道这是什么,请留空"
|
"Override core API URL(/chat/completions and /completions). If you don't know what this is, leave it blank.": "覆盖核心的 API URL (/chat/completions 和 /completions)。如果你不知道这是什么,请留空",
|
||||||
|
"Please change Strategy to CPU (rwkv.cpp) to use ggml format": "请将Strategy改为CPU (rwkv.cpp)以使用ggml格式"
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
|
|
||||||
const modelConfig = commonStore.getCurrentModelConfig();
|
const modelConfig = commonStore.getCurrentModelConfig();
|
||||||
const webgpu = modelConfig.modelParameters.device === 'WebGPU';
|
const webgpu = modelConfig.modelParameters.device === 'WebGPU';
|
||||||
|
const webgpuPython = modelConfig.modelParameters.device === 'WebGPU (Python)';
|
||||||
const cpp = modelConfig.modelParameters.device === 'CPU (rwkv.cpp)';
|
const cpp = modelConfig.modelParameters.device === 'CPU (rwkv.cpp)';
|
||||||
let modelName = '';
|
let modelName = '';
|
||||||
let modelPath = '';
|
let modelPath = '';
|
||||||
@@ -77,7 +78,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (webgpu) {
|
if (webgpu || webgpuPython) {
|
||||||
if (!['.st', '.safetensors'].some(ext => modelPath.endsWith(ext))) {
|
if (!['.st', '.safetensors'].some(ext => modelPath.endsWith(ext))) {
|
||||||
const stModelPath = modelPath.replace(/\.pth$/, '.st');
|
const stModelPath = modelPath.replace(/\.pth$/, '.st');
|
||||||
if (await FileExists(stModelPath)) {
|
if (await FileExists(stModelPath)) {
|
||||||
@@ -92,7 +93,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
toastWithButton(t('Please convert model to safe tensors format first'), t('Convert'), () => {
|
toastWithButton(t('Please convert model to safe tensors format first'), t('Convert'), () => {
|
||||||
convertToSt(modelConfig);
|
convertToSt(modelConfig, navigate);
|
||||||
});
|
});
|
||||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||||
return;
|
return;
|
||||||
@@ -100,7 +101,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!webgpu) {
|
if (!webgpu && !webgpuPython) {
|
||||||
if (['.st', '.safetensors'].some(ext => modelPath.endsWith(ext))) {
|
if (['.st', '.safetensors'].some(ext => modelPath.endsWith(ext))) {
|
||||||
toast(t('Please change Strategy to WebGPU to use safetensors format'), { type: 'error' });
|
toast(t('Please change Strategy to WebGPU to use safetensors format'), { type: 'error' });
|
||||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||||
@@ -138,6 +139,14 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cpp) {
|
||||||
|
if (['.bin'].some(ext => modelPath.endsWith(ext))) {
|
||||||
|
toast(t('Please change Strategy to CPU (rwkv.cpp) to use ggml format'), { type: 'error' });
|
||||||
|
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!await FileExists(modelPath)) {
|
if (!await FileExists(modelPath)) {
|
||||||
showDownloadPrompt(t('Model file not found'), modelName);
|
showDownloadPrompt(t('Model file not found'), modelName);
|
||||||
commonStore.setStatus({ status: ModelStatus.Offline });
|
commonStore.setStatus({ status: ModelStatus.Offline });
|
||||||
@@ -168,7 +177,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
const isUsingCudaBeta = modelConfig.modelParameters.device === 'CUDA-Beta';
|
const isUsingCudaBeta = modelConfig.modelParameters.device === 'CUDA-Beta';
|
||||||
|
|
||||||
startServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1',
|
startServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1',
|
||||||
!!modelConfig.enableWebUI, isUsingCudaBeta, cpp
|
!!modelConfig.enableWebUI, isUsingCudaBeta, cpp, webgpuPython
|
||||||
).catch((e) => {
|
).catch((e) => {
|
||||||
const errMsg = e.message || e;
|
const errMsg = e.message || e;
|
||||||
if (errMsg.includes('path contains space'))
|
if (errMsg.includes('path contains space'))
|
||||||
@@ -208,7 +217,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
|
|
||||||
const strategy = getStrategy(modelConfig);
|
const strategy = getStrategy(modelConfig);
|
||||||
let customCudaFile = '';
|
let customCudaFile = '';
|
||||||
if ((modelConfig.modelParameters.device.includes('CUDA') || modelConfig.modelParameters.device === 'Custom')
|
if ((modelConfig.modelParameters.device.startsWith('CUDA') || modelConfig.modelParameters.device === 'Custom')
|
||||||
&& modelConfig.modelParameters.useCustomCuda
|
&& modelConfig.modelParameters.useCustomCuda
|
||||||
&& !strategy.split('->').some(s => ['cuda', 'fp32'].every(v => s.includes(v)))) {
|
&& !strategy.split('->').some(s => ['cuda', 'fp32'].every(v => s.includes(v)))) {
|
||||||
if (commonStore.platform === 'windows') {
|
if (commonStore.platform === 'windows') {
|
||||||
@@ -256,7 +265,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
navigate({ pathname: '/' + buttonName.toLowerCase() });
|
navigate({ pathname: '/' + buttonName.toLowerCase() });
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((modelConfig.modelParameters.device === 'CUDA' || modelConfig.modelParameters.device === 'CUDA-Beta') &&
|
if (modelConfig.modelParameters.device.startsWith('CUDA') &&
|
||||||
modelConfig.modelParameters.storedLayers < modelConfig.modelParameters.maxStoredLayers &&
|
modelConfig.modelParameters.storedLayers < modelConfig.modelParameters.maxStoredLayers &&
|
||||||
commonStore.monitorData && commonStore.monitorData.totalVram !== 0 &&
|
commonStore.monitorData && commonStore.monitorData.totalVram !== 0 &&
|
||||||
(commonStore.monitorData.usedVram / commonStore.monitorData.totalVram) < 0.9)
|
(commonStore.monitorData.usedVram / commonStore.monitorData.totalVram) < 0.9)
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ const Configs: FC = observer(() => {
|
|||||||
</div>
|
</div>
|
||||||
} />
|
} />
|
||||||
{
|
{
|
||||||
selectedConfig.modelParameters.device !== 'WebGPU' ?
|
!selectedConfig.modelParameters.device.startsWith('WebGPU') ?
|
||||||
(selectedConfig.modelParameters.device !== 'CPU (rwkv.cpp)' ?
|
(selectedConfig.modelParameters.device !== 'CPU (rwkv.cpp)' ?
|
||||||
<ToolTipButton text={t('Convert')}
|
<ToolTipButton text={t('Convert')}
|
||||||
desc={t('Convert model with these configs. Using a converted model will greatly improve the loading speed, but model parameters of the converted model cannot be modified.')}
|
desc={t('Convert model with these configs. Using a converted model will greatly improve the loading speed, but model parameters of the converted model cannot be modified.')}
|
||||||
@@ -256,7 +256,7 @@ const Configs: FC = observer(() => {
|
|||||||
onClick={() => convertToGGML(selectedConfig, navigate)} />)
|
onClick={() => convertToGGML(selectedConfig, navigate)} />)
|
||||||
: <ToolTipButton text={t('Convert To Safe Tensors Format')}
|
: <ToolTipButton text={t('Convert To Safe Tensors Format')}
|
||||||
desc=""
|
desc=""
|
||||||
onClick={() => convertToSt(selectedConfig)} />
|
onClick={() => convertToSt(selectedConfig, navigate)} />
|
||||||
}
|
}
|
||||||
<Labeled label={t('Strategy')} content={
|
<Labeled label={t('Strategy')} content={
|
||||||
<Dropdown style={{ minWidth: 0 }} className="grow" value={t(selectedConfig.modelParameters.device)!}
|
<Dropdown style={{ minWidth: 0 }} className="grow" value={t(selectedConfig.modelParameters.device)!}
|
||||||
@@ -274,6 +274,7 @@ const Configs: FC = observer(() => {
|
|||||||
<Option value="CUDA">CUDA</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">WebGPU</Option>
|
||||||
|
<Option value="WebGPU (Python)">WebGPU (Python)</Option>
|
||||||
<Option value="Custom">{t('Custom')!}</Option>
|
<Option value="Custom">{t('Custom')!}</Option>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
} />
|
} />
|
||||||
@@ -281,7 +282,8 @@ const Configs: FC = observer(() => {
|
|||||||
selectedConfig.modelParameters.device !== 'Custom' && <Labeled label={t('Precision')}
|
selectedConfig.modelParameters.device !== 'Custom' && <Labeled label={t('Precision')}
|
||||||
desc={t('int8 uses less VRAM, but has slightly lower quality. fp16 has higher quality.')}
|
desc={t('int8 uses less VRAM, but has slightly lower quality. fp16 has higher quality.')}
|
||||||
content={
|
content={
|
||||||
<Dropdown style={{ minWidth: 0 }} className="grow"
|
<Dropdown disabled={selectedConfig.modelParameters.device === 'WebGPU (Python)'}
|
||||||
|
style={{ minWidth: 0 }} className="grow"
|
||||||
value={selectedConfig.modelParameters.precision}
|
value={selectedConfig.modelParameters.precision}
|
||||||
selectedOptions={[selectedConfig.modelParameters.precision]}
|
selectedOptions={[selectedConfig.modelParameters.precision]}
|
||||||
onOptionSelect={(_, data) => {
|
onOptionSelect={(_, data) => {
|
||||||
@@ -302,12 +304,12 @@ const Configs: FC = observer(() => {
|
|||||||
} />
|
} />
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
selectedConfig.modelParameters.device.includes('CUDA') &&
|
selectedConfig.modelParameters.device.startsWith('CUDA') &&
|
||||||
<Labeled label={t('Current Strategy')}
|
<Labeled label={t('Current Strategy')}
|
||||||
content={<Text> {getStrategy(selectedConfig)} </Text>} />
|
content={<Text> {getStrategy(selectedConfig)} </Text>} />
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
selectedConfig.modelParameters.device.includes('CUDA') &&
|
selectedConfig.modelParameters.device.startsWith('CUDA') &&
|
||||||
<Labeled label={t('Stored Layers')}
|
<Labeled label={t('Stored Layers')}
|
||||||
desc={t('Number of the neural network layers loaded into VRAM, the more you load, the faster the speed, but it consumes more VRAM. (If your VRAM is not enough, it will fail to load)')}
|
desc={t('Number of the neural network layers loaded into VRAM, the more you load, the faster the speed, but it consumes more VRAM. (If your VRAM is not enough, it will fail to load)')}
|
||||||
content={
|
content={
|
||||||
@@ -320,7 +322,7 @@ const Configs: FC = observer(() => {
|
|||||||
}} />
|
}} />
|
||||||
} />
|
} />
|
||||||
}
|
}
|
||||||
{selectedConfig.modelParameters.device.includes('CUDA') && <div />}
|
{selectedConfig.modelParameters.device.startsWith('CUDA') && <div />}
|
||||||
{
|
{
|
||||||
displayStrategyImg &&
|
displayStrategyImg &&
|
||||||
<img style={{ width: '80vh', height: 'auto', zIndex: 100 }}
|
<img style={{ width: '80vh', height: 'auto', zIndex: 100 }}
|
||||||
@@ -345,7 +347,7 @@ const Configs: FC = observer(() => {
|
|||||||
}
|
}
|
||||||
{selectedConfig.modelParameters.device === 'Custom' && <div />}
|
{selectedConfig.modelParameters.device === 'Custom' && <div />}
|
||||||
{
|
{
|
||||||
(selectedConfig.modelParameters.device.includes('CUDA') || selectedConfig.modelParameters.device === 'Custom') &&
|
(selectedConfig.modelParameters.device.startsWith('CUDA') || selectedConfig.modelParameters.device === 'Custom') &&
|
||||||
<Labeled label={t('Use Custom CUDA kernel to Accelerate')}
|
<Labeled label={t('Use Custom CUDA kernel to Accelerate')}
|
||||||
desc={t('Enabling this option can greatly improve inference speed and save some VRAM, but there may be compatibility issues (output garbled). If it fails to start, please turn off this option, or try to upgrade your gpu driver.')}
|
desc={t('Enabling this option can greatly improve inference speed and save some VRAM, but there may be compatibility issues (output garbled). If it fails to start, please turn off this option, or try to upgrade your gpu driver.')}
|
||||||
content={
|
content={
|
||||||
@@ -394,6 +396,7 @@ const Configs: FC = observer(() => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{mq && <div style={{ minHeight: '30px' }} />}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row-reverse sm:fixed bottom-2 right-2">
|
<div className="flex flex-row-reverse sm:fixed bottom-2 right-2">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export type ApiParameters = {
|
|||||||
presencePenalty: number;
|
presencePenalty: number;
|
||||||
frequencyPenalty: number;
|
frequencyPenalty: number;
|
||||||
}
|
}
|
||||||
export type Device = 'CPU' | 'CPU (rwkv.cpp)' | 'CUDA' | 'CUDA-Beta' | 'WebGPU' | 'MPS' | 'Custom';
|
export type Device = 'CPU' | 'CPU (rwkv.cpp)' | 'CUDA' | 'CUDA-Beta' | 'WebGPU' | 'WebGPU (Python)' | 'MPS' | 'Custom';
|
||||||
export type Precision = 'fp16' | 'int8' | 'fp32' | 'nf4' | 'Q5_1';
|
export type Precision = 'fp16' | 'int8' | 'fp32' | 'nf4' | 'Q5_1';
|
||||||
export type ModelParameters = {
|
export type ModelParameters = {
|
||||||
// different models can not have the same name
|
// different models can not have the same name
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
ConvertGGML,
|
ConvertGGML,
|
||||||
ConvertModel,
|
ConvertModel,
|
||||||
ConvertSafetensors,
|
ConvertSafetensors,
|
||||||
|
ConvertSafetensorsWithPython,
|
||||||
FileExists,
|
FileExists,
|
||||||
GetPyError
|
GetPyError
|
||||||
} from '../../wailsjs/go/backend_golang/App';
|
} from '../../wailsjs/go/backend_golang/App';
|
||||||
@@ -51,12 +52,22 @@ export const convertModel = async (selectedConfig: ModelConfig, navigate: Naviga
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const convertToSt = async (selectedConfig: ModelConfig) => {
|
export const convertToSt = async (selectedConfig: ModelConfig, navigate: NavigateFunction) => {
|
||||||
|
const webgpuPython = selectedConfig.modelParameters.device === 'WebGPU (Python)';
|
||||||
|
if (webgpuPython) {
|
||||||
|
const ok = await checkDependencies(navigate);
|
||||||
|
if (!ok)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`;
|
const modelPath = `${commonStore.settings.customModelsPath}/${selectedConfig.modelParameters.modelName}`;
|
||||||
if (await FileExists(modelPath)) {
|
if (await FileExists(modelPath)) {
|
||||||
toast(t('Start Converting'), { autoClose: 2000, type: 'info' });
|
toast(t('Start Converting'), { autoClose: 2000, type: 'info' });
|
||||||
const newModelPath = modelPath.replace(/\.pth$/, '.st');
|
const newModelPath = modelPath.replace(/\.pth$/, '.st');
|
||||||
ConvertSafetensors(modelPath, newModelPath).then(async () => {
|
const convert = webgpuPython ?
|
||||||
|
(input: string, output: string) => ConvertSafetensorsWithPython(commonStore.settings.customPythonPath, input, output)
|
||||||
|
: ConvertSafetensors;
|
||||||
|
convert(modelPath, newModelPath).then(async () => {
|
||||||
if (!await FileExists(newModelPath)) {
|
if (!await FileExists(newModelPath)) {
|
||||||
if (commonStore.platform === 'windows' || commonStore.platform === 'linux')
|
if (commonStore.platform === 'windows' || commonStore.platform === 'linux')
|
||||||
toast(t('Convert Failed') + ' - ' + await GetPyError(), { type: 'error' });
|
toast(t('Convert Failed') + ' - ' + await GetPyError(), { type: 'error' });
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ export async function refreshBuiltInModels(readCache: boolean = false) {
|
|||||||
await ReadJson('cache.json').then((cacheData: Cache) => {
|
await ReadJson('cache.json').then((cacheData: Cache) => {
|
||||||
if (cacheData.models)
|
if (cacheData.models)
|
||||||
cache.models = cacheData.models;
|
cache.models = cacheData.models;
|
||||||
else cache.models = manifest.models;
|
else cache.models = manifest.models.slice();
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
cache.models = manifest.models;
|
cache.models = manifest.models.slice();
|
||||||
});
|
});
|
||||||
else cache.models = manifest.models;
|
else cache.models = manifest.models.slice();
|
||||||
|
|
||||||
commonStore.setModelSourceList(cache.models);
|
commonStore.setModelSourceList(cache.models);
|
||||||
await saveCache().catch(() => {
|
await saveCache().catch(() => {
|
||||||
@@ -192,6 +192,7 @@ export const getStrategy = (modelConfig: ModelConfig | undefined = undefined) =>
|
|||||||
strategy += params.precision === 'int8' ? 'fp32i8' : 'fp32';
|
strategy += params.precision === 'int8' ? 'fp32i8' : 'fp32';
|
||||||
break;
|
break;
|
||||||
case 'WebGPU':
|
case 'WebGPU':
|
||||||
|
case 'WebGPU (Python)':
|
||||||
strategy += params.precision === 'nf4' ? 'fp16i4' : params.precision === 'int8' ? 'fp16i8' : 'fp16';
|
strategy += params.precision === 'nf4' ? 'fp16i4' : params.precision === 'int8' ? 'fp16i8' : 'fp16';
|
||||||
break;
|
break;
|
||||||
case 'CUDA':
|
case 'CUDA':
|
||||||
@@ -307,7 +308,7 @@ export function getServerRoot(defaultLocalPort: number, isCore: boolean = false)
|
|||||||
const coreCustomApiUrl = commonStore.settings.coreApiUrl.trim().replace(/\/$/, '');
|
const coreCustomApiUrl = commonStore.settings.coreApiUrl.trim().replace(/\/$/, '');
|
||||||
if (isCore && coreCustomApiUrl)
|
if (isCore && coreCustomApiUrl)
|
||||||
return coreCustomApiUrl;
|
return coreCustomApiUrl;
|
||||||
|
|
||||||
const defaultRoot = `http://127.0.0.1:${defaultLocalPort}`;
|
const defaultRoot = `http://127.0.0.1:${defaultLocalPort}`;
|
||||||
if (commonStore.status.status !== ModelStatus.Offline)
|
if (commonStore.status.status !== ModelStatus.Offline)
|
||||||
return defaultRoot;
|
return defaultRoot;
|
||||||
|
|||||||
4
frontend/wailsjs/go/backend_golang/App.d.ts
generated
vendored
4
frontend/wailsjs/go/backend_golang/App.d.ts
generated
vendored
@@ -16,6 +16,8 @@ export function ConvertModel(arg1:string,arg2:string,arg3:string,arg4:string):Pr
|
|||||||
|
|
||||||
export function ConvertSafetensors(arg1:string,arg2:string):Promise<string>;
|
export function ConvertSafetensors(arg1:string,arg2:string):Promise<string>;
|
||||||
|
|
||||||
|
export function ConvertSafetensorsWithPython(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||||
|
|
||||||
export function CopyFile(arg1:string,arg2:string):Promise<void>;
|
export function CopyFile(arg1:string,arg2:string):Promise<void>;
|
||||||
|
|
||||||
export function DeleteFile(arg1:string):Promise<void>;
|
export function DeleteFile(arg1:string):Promise<void>;
|
||||||
@@ -64,7 +66,7 @@ export function SaveJson(arg1:string,arg2:any):Promise<void>;
|
|||||||
|
|
||||||
export function StartFile(arg1:string):Promise<void>;
|
export function StartFile(arg1:string):Promise<void>;
|
||||||
|
|
||||||
export function StartServer(arg1:string,arg2:number,arg3:string,arg4:boolean,arg5:boolean,arg6:boolean):Promise<string>;
|
export function StartServer(arg1:string,arg2:number,arg3:string,arg4:boolean,arg5:boolean,arg6:boolean,arg7:boolean):Promise<string>;
|
||||||
|
|
||||||
export function StartWebGPUServer(arg1:number,arg2:string):Promise<string>;
|
export function StartWebGPUServer(arg1:number,arg2:string):Promise<string>;
|
||||||
|
|
||||||
|
|||||||
8
frontend/wailsjs/go/backend_golang/App.js
generated
8
frontend/wailsjs/go/backend_golang/App.js
generated
@@ -30,6 +30,10 @@ export function ConvertSafetensors(arg1, arg2) {
|
|||||||
return window['go']['backend_golang']['App']['ConvertSafetensors'](arg1, arg2);
|
return window['go']['backend_golang']['App']['ConvertSafetensors'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ConvertSafetensorsWithPython(arg1, arg2, arg3) {
|
||||||
|
return window['go']['backend_golang']['App']['ConvertSafetensorsWithPython'](arg1, arg2, arg3);
|
||||||
|
}
|
||||||
|
|
||||||
export function CopyFile(arg1, arg2) {
|
export function CopyFile(arg1, arg2) {
|
||||||
return window['go']['backend_golang']['App']['CopyFile'](arg1, arg2);
|
return window['go']['backend_golang']['App']['CopyFile'](arg1, arg2);
|
||||||
}
|
}
|
||||||
@@ -126,8 +130,8 @@ export function StartFile(arg1) {
|
|||||||
return window['go']['backend_golang']['App']['StartFile'](arg1);
|
return window['go']['backend_golang']['App']['StartFile'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StartServer(arg1, arg2, arg3, arg4, arg5, arg6) {
|
export function StartServer(arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
||||||
return window['go']['backend_golang']['App']['StartServer'](arg1, arg2, arg3, arg4, arg5, arg6);
|
return window['go']['backend_golang']['App']['StartServer'](arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StartWebGPUServer(arg1, arg2) {
|
export function StartWebGPUServer(arg1, arg2) {
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -109,7 +109,7 @@ func main() {
|
|||||||
err = wails.Run(&options.App{
|
err = wails.Run(&options.App{
|
||||||
Title: "RWKV-Runner",
|
Title: "RWKV-Runner",
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
Height: 680,
|
Height: 700,
|
||||||
MinWidth: 375,
|
MinWidth: 375,
|
||||||
MinHeight: 640,
|
MinHeight: 640,
|
||||||
EnableDefaultContextMenu: true,
|
EnableDefaultContextMenu: true,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.6.0",
|
"version": "1.6.2",
|
||||||
"introduction": {
|
"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).",
|
"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的优点结合起来 - 高性能、快速推理、节省显存、快速训练、“无限”上下文长度以及免费的语句嵌入(使用最终隐藏状态)。"
|
"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的优点结合起来 - 高性能、快速推理、节省显存、快速训练、“无限”上下文长度以及免费的语句嵌入(使用最终隐藏状态)。"
|
||||||
|
|||||||
Reference in New Issue
Block a user