Compare commits

..

16 Commits

Author SHA1 Message Date
josc146
602004ad34 release v1.5.8 2023-11-30 13:04:02 +08:00
josc146
a8b4f0bb7e lora finetune version check 2023-11-30 13:01:38 +08:00
josc146
24cc8be085 add high loss warning 2023-11-30 12:40:16 +08:00
josc146
a96d7aef8d display mainInstrument of track 2023-11-30 12:36:03 +08:00
josc146
cbe299583b improve details of MIDI Input 2023-11-30 11:57:52 +08:00
josc146
68c70a362b darkmode of midi tracks 2023-11-30 11:56:45 +08:00
josc146
a78c346371 fix NoteOff ElapsedTime of MIDI Tracks 2023-11-30 11:55:10 +08:00
github-actions[bot]
102763b94d release v1.5.7 2023-11-29 15:01:26 +00:00
josc146
ad65765ba8 release v1.5.7 2023-11-29 22:59:47 +08:00
josc146
d04fd7cb87 fix lib 2023-11-29 22:59:42 +08:00
github-actions[bot]
b398cbb591 release v1.5.6 2023-11-29 13:22:21 +00:00
josc146
19b97e985c release v1.5.6 2023-11-29 21:21:50 +08:00
josc146
93bf74a320 fix NoteOff 2023-11-29 21:21:42 +08:00
josc146
7daae23bbb update defaultConfigs 2023-11-29 21:21:29 +08:00
josc146
0d0a3f15cc chore 2023-11-29 21:21:14 +08:00
github-actions[bot]
04fbb38861 release v1.5.5 2023-11-29 11:32:40 +00:00
15 changed files with 116 additions and 28 deletions

View File

@@ -1,9 +1,9 @@
## Changes
- MIDI Input Audio Tracks (Experimental, playing tracks is not supported yet, please save to generation area to preview)
- fix autoPlayed midi cannot be stopped
- try to use local soundfont by default
- improve details
- fix NoteOff ElapsedTime of MIDI Tracks
- improve details of MIDI Input
- add high loss warning
- lora finetune version check
## Install

View File

@@ -8,15 +8,15 @@ endif
build-windows:
@echo ---- build for windows
wails build -upx -ldflags "-s -w" -platform windows/amd64
wails build -upx -ldflags '-s -w -extldflags "-static"' -platform windows/amd64
build-macos:
@echo ---- build for macos
wails build -ldflags "-s -w" -platform darwin/universal
wails build -ldflags '-s -w' -platform darwin/universal
build-linux:
@echo ---- build for linux
wails build -upx -ldflags "-s -w" -platform linux/amd64
wails build -upx -ldflags '-s -w' -platform linux/amd64
build-web:
@echo ---- build for web

View File

@@ -86,6 +86,12 @@ func (a *App) OpenMidiPort(index int) error {
channel := bytes[0] & 0x0f
switch msgType {
case 0x8:
elapsed := time.Since(lastNoteTime)
lastNoteTime = time.Now()
runtime.EventsEmit(a.ctx, "midiMessage", &MIDIMessage{
MessageType: "ElapsedTime",
Value: int(elapsed.Milliseconds()),
})
note := bytes[1]
runtime.EventsEmit(a.ctx, "midiMessage", &MIDIMessage{
MessageType: "NoteOff",

View File

@@ -23,6 +23,7 @@ def file_cleaner(file):
return cleaner
expected_max_version = float(sys.argv[2]) if len(sys.argv) > 2 else 100
model_file = open(sys.argv[1], "rb")
cleaner = file_cleaner(model_file)
cleaner_thread = threading.Thread(target=cleaner, daemon=True)
@@ -34,8 +35,23 @@ gc.collect()
n_embd = w["emb.weight"].shape[1]
n_layer = 0
keys = list(w.keys())
version = 4
for x in keys:
layer_id = int(x.split(".")[1]) if ("blocks." in x) else 0
n_layer = max(n_layer, layer_id + 1)
print(f"--n_layer {n_layer} --n_embd {n_embd}", end="")
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(w[x].shape) > 1:
if w[x].shape[1] > 1:
version = max(5.2, version)
if "time_maa" in x:
version = max(6, version)
if version <= expected_max_version:
print(f"--n_layer {n_layer} --n_embd {n_embd}", end="")
else:
raise Exception(f"RWKV{version} is not supported")

View File

@@ -47,7 +47,7 @@ else
fi
echo "loading $loadModel"
modelInfo=$(python3 ./finetune/get_layer_and_embd.py $loadModel)
modelInfo=$(python3 ./finetune/get_layer_and_embd.py $loadModel 4)
echo $modelInfo
if [[ $modelInfo =~ "--n_layer" ]]; then
python3 ./finetune/lora/train.py $modelInfo $@ --proj_dir lora-models --data_type binidx --lora \

View File

@@ -295,5 +295,13 @@
"Sax": "サックス",
"Flute": "フルート",
"Lead": "リード",
"Pad": "パッド"
"Pad": "パッド",
"MIDI Input": "MIDI入力",
"Select the MIDI input device to be used.": "使用するMIDI入力デバイスを選択します。",
"Start Time": "開始時間",
"Content Duration": "内容の長さ",
"Please select a MIDI device first": "まずMIDIデバイスを選択してください",
"Piano is the main instrument": "ピアノはメインの楽器です",
"Loss is too high, please check the training data, and ensure your gpu driver is up to date.": "Lossが大きすぎます、トレーニングデータを確認し、GPUドライバが最新であることを確認してください。",
"This version of RWKV is not supported yet.": "このバージョンのRWKVはまだサポートされていません。"
}

View File

@@ -295,5 +295,13 @@
"Sax": "萨克斯",
"Flute": "长笛",
"Lead": "主音",
"Pad": "和音"
"Pad": "和音",
"MIDI Input": "MIDI输入",
"Select the MIDI input device to be used.": "选择要使用的MIDI输入设备",
"Start Time": "开始时间",
"Content Duration": "内容时长",
"Please select a MIDI device first": "请先选择一个MIDI设备",
"Piano is the main instrument": "钢琴为主",
"Loss is too high, please check the training data, and ensure your gpu driver is up to date.": "Loss过高请检查训练数据并确保你的显卡驱动是最新的",
"This version of RWKV is not supported yet.": "暂不支持此版本的RWKV"
}

View File

@@ -91,7 +91,7 @@ const velocityToBin = (velocity: number) => {
};
const midiMessageToToken = (msg: MidiMessage) => {
if (msg.messageType === 'NoteOn') {
if (msg.messageType === 'NoteOn' || msg.messageType === 'NoteOff') {
const instrument = InstrumentTypeTokenMap[commonStore.instrumentType];
const note = msg.note.toString(16);
const velocity = velocityToBin(msg.velocity).toString(16);
@@ -146,9 +146,15 @@ const Track: React.FC<TrackProps> = observer(({
const { t } = useTranslation();
const trackIndex = commonStore.tracks.findIndex(t => t.id === id)!;
const track = commonStore.tracks[trackIndex];
const trackClass = isSelected ? 'bg-blue-600' : 'bg-gray-700';
const trackClass = isSelected ? 'bg-blue-600' : (commonStore.settings.darkMode ? 'bg-blue-900' : 'bg-gray-700');
const controlX = useRef(0);
let trackName = t('Track') + ' ' + id;
if (track.mainInstrument)
trackName = t('Track') + ' - ' + t('Piano is the main instrument')!.replace(t('Piano')!, t(track.mainInstrument)) + (track.content && (' - ' + track.content));
else if (track.content)
trackName = t('Track') + ' - ' + track.content;
return (
<Draggable
axis="x"
@@ -183,7 +189,7 @@ const Track: React.FC<TrackProps> = observer(({
}}
onClick={() => onSelect(id)}
>
<span className="text-white">{t('Track') + ' ' + (track.content || id)}</span>
<span className="text-white">{trackName}</span>
</div>
</Draggable>
);
@@ -298,7 +304,8 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
}, 1);
}}
>
<div ref={currentTimeControlRef} className="h-2 bg-gray-700 cursor-move rounded"
<div ref={currentTimeControlRef}
className={classnames('h-2 cursor-move rounded', commonStore.settings.darkMode ? 'bg-neutral-600' : 'bg-gray-700')}
style={{ width: currentTimeControlWidth }} />
</Draggable>
<div className={classnames(
@@ -329,7 +336,8 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
<div className="relative cursor-move"
ref={playStartTimeControlRef}>
<ArrowAutofitWidth20Regular />
<div className="border-l absolute border-gray-700"
<div
className={classnames('border-l absolute', commonStore.settings.darkMode ? 'border-white' : 'border-gray-700')}
style={{
height: (tracksRef.current && commonStore.tracks.length > 0)
? tracksRef.current.clientHeight
@@ -365,6 +373,11 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
if (commonStore.recordingTrackId === track.id) {
commonStore.setRecordingTrackId('');
} else {
if (commonStore.activeMidiDeviceIndex === -1) {
toast(t('Please select a MIDI device first'), { type: 'warning' });
return;
}
dropRecordingTime = true;
setSelectedTrackId(track.id);
@@ -393,6 +406,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
appearance="subtle" onClick={() => {
const tracks = commonStore.tracks.slice().filter(t => t.id !== track.id);
commonStore.setTracks(tracks);
refreshTracksTotalTime();
}} />
</div>
<div className="relative grow overflow-hidden">
@@ -413,6 +427,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
onClick={() => {
commonStore.setTracks([...commonStore.tracks, {
id: uuid(),
mainInstrument: '',
content: '',
rawContent: [],
offsetTime: 0,
@@ -431,7 +446,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
<Card size="small" appearance="outline" style={{ minHeight: '150px', maxHeight: '200px' }}>
<div className="flex flex-col gap-1 overflow-hidden">
<Text size={100}>{`${t('Start Time')}: ${selectedTrack.offsetTime} ms`}</Text>
<Text size={100}>{`${t('Content Time')}: ${selectedTrack.contentTime} ms`}</Text>
<Text size={100}>{`${t('Content Duration')}: ${selectedTrack.contentTime} ms`}</Text>
<div className="overflow-y-auto overflow-x-hidden" ref={contentPreviewRef}>
{selectedTrackId === commonStore.recordingTrackId
? commonStore.recordingContent
@@ -472,14 +487,14 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
if (msg.messageType === 'ElapsedTime') {
accContentTime += msg.value;
currentTime = track.offsetTime + accContentTime;
} else if (msg.messageType === 'NoteOn') {
} else if (msg.messageType === 'NoteOn' || msg.messageType === 'NoteOff') {
const insertIndex = sortedTimestamp.findIndex(t => t >= currentTime);
globalMessages.splice(insertIndex + 1, 0, msg);
sortedTimestamp.splice(insertIndex + 1, 0, 0); // placeholder
}
}
}
const result = globalMessages.map(m => midiMessageToToken(m)).join('');
const result = ('<pad> ' + globalMessages.map(m => midiMessageToToken(m)).join('')).trim();
commonStore.setCompositionSubmittedPrompt(result);
setPrompt(result);
}}>

View File

@@ -98,6 +98,13 @@ const CompositionPanel: FC = observer(() => {
}
}, []);
useEffect(() => {
if (!(commonStore.activeMidiDeviceIndex in commonStore.midiPorts)) {
commonStore.setActiveMidiDeviceIndex(-1);
CloseMidiPort();
}
}, [commonStore.midiPorts]);
const generateNs = (autoPlay: boolean) => {
fetch(getServerRoot(port) + '/text-to-midi', {
method: 'POST',
@@ -270,7 +277,9 @@ const CompositionPanel: FC = observer(() => {
content={
<div className="flex flex-col gap-1">
<Dropdown style={{ minWidth: 0 }}
value={commonStore.activeMidiDeviceIndex === -1 ? t('None')! : commonStore.midiPorts[commonStore.activeMidiDeviceIndex].name}
value={(commonStore.activeMidiDeviceIndex === -1 || !(commonStore.activeMidiDeviceIndex in commonStore.midiPorts))
? t('None')!
: commonStore.midiPorts[commonStore.activeMidiDeviceIndex].name}
selectedOptions={[commonStore.activeMidiDeviceIndex.toString()]}
onOptionSelect={(_, data) => {
if (data.optionValue) {

View File

@@ -66,6 +66,11 @@ const parseLossData = (data: string) => {
const loss = parseFloat(lastMatch[8]);
commonStore.setChartTitle(`Epoch ${epoch}: ${lastMatch[2]} - ${lastMatch[3]}/${lastMatch[4]} - ${lastMatch[5]}/${lastMatch[6]} - ${lastMatch[7]} Loss=${loss}`);
addLossDataToChart(epoch, loss);
if (loss > 5)
toast(t('Loss is too high, please check the training data, and ensure your gpu driver is up to date.'), {
type: 'warning',
toastId: 'train_loss_high'
});
return true;
};
@@ -134,6 +139,7 @@ const errorsMap = Object.entries({
'cuda_home environment variable is not set': 'Matched CUDA is not installed',
'unsupported gpu architecture': 'Matched CUDA is not installed',
'error building extension \'fused_adam\'': 'Matched CUDA is not installed',
'rwkv{version} is not supported': 'This version of RWKV is not supported yet.',
'modelinfo is invalid': 'Failed to load model, try to increase the virtual memory (Swap of WSL) or use a smaller base model.'
});

View File

@@ -211,7 +211,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
frequencyPenalty: 1
},
modelParameters: {
modelName: 'RWKV-4-MIDI-120M-v1-20230714-ctx4096.pth',
modelName: 'RWKV-5-MIDI-120M-v1-20230728-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
@@ -229,7 +229,7 @@ export const defaultModelConfigsMac: ModelConfig[] = [
frequencyPenalty: 1
},
modelParameters: {
modelName: 'RWKV-4-MIDI-560M-v1-20230717-ctx4096.pth',
modelName: 'RWKV-5-MIDI-560M-v1-20230902-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
@@ -687,7 +687,7 @@ export const defaultModelConfigs: ModelConfig[] = [
frequencyPenalty: 1
},
modelParameters: {
modelName: 'RWKV-4-MIDI-120M-v1-20230714-ctx4096.pth',
modelName: 'RWKV-5-MIDI-120M-v1-20230728-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,
@@ -705,7 +705,7 @@ export const defaultModelConfigs: ModelConfig[] = [
frequencyPenalty: 1
},
modelParameters: {
modelName: 'RWKV-4-MIDI-560M-v1-20230717-ctx4096.pth',
modelName: 'RWKV-5-MIDI-560M-v1-20230902-ctx4096.pth',
device: 'CPU',
precision: 'fp32',
storedLayers: 41,

View File

@@ -140,7 +140,8 @@ async function initHardwareMonitor() {
async function initMidi() {
EventsOn('midiError', (data: string) => {
toast('MIDI Error: ' + data, { type: 'error' });
if (commonStore.platform === 'windows')
toast('MIDI Error: ' + data, { type: 'error' });
});
EventsOn('midiPorts', (data: MidiPort[]) => {
commonStore.setMidiPorts(data);

View File

@@ -14,6 +14,7 @@ export type CompositionParams = {
}
export type Track = {
id: string;
mainInstrument: string;
content: string;
rawContent: MidiMessage[];
offsetTime: number;

View File

@@ -22,7 +22,7 @@ import { DownloadStatus } from '../types/downloads';
import { ModelSourceItem } from '../types/models';
import { Language, Languages, SettingsType } from '../types/settings';
import { DataProcessParameters, LoraFinetuneParameters } from '../types/train';
import { tracksMinimalTotalTime } from '../types/composition';
import { InstrumentTypeNameMap, tracksMinimalTotalTime } from '../types/composition';
export type Cache = {
version: string
@@ -482,6 +482,12 @@ export function getHfDownloadUrl(url: string) {
}
export function refreshTracksTotalTime() {
if (commonStore.tracks.length === 0) {
commonStore.setTrackTotalTime(tracksMinimalTotalTime);
commonStore.setTrackCurrentTime(0);
commonStore.setTrackPlayStartTime(0);
return;
}
const endTimes = commonStore.tracks.map(t => t.offsetTime + t.contentTime);
const totalTime = Math.max(...endTimes) + tracksMinimalTotalTime;
if (commonStore.trackPlayStartTime > totalTime)
@@ -498,11 +504,23 @@ export function flushMidiRecordingContent() {
.reduce((sum, current) =>
sum + (current.messageType === 'ElapsedTime' ? current.value : 0)
, 0);
const sortedInstrumentFrequency = Object.entries(commonStore.recordingRawContent
.filter(c => c.messageType === 'NoteOn')
.map(c => c.instrument)
.reduce((frequencyCount, current) => (frequencyCount[current] = (frequencyCount[current] || 0) + 1, frequencyCount)
, {} as { [key: string]: number }))
.sort((a, b) => b[1] - a[1]);
let mainInstrument: string = '';
if (sortedInstrumentFrequency.length > 0)
mainInstrument = InstrumentTypeNameMap[Number(sortedInstrumentFrequency[0][0])];
tracks[recordingTrackIndex] = {
...recordingTrack,
content: commonStore.recordingContent,
rawContent: commonStore.recordingRawContent,
contentTime: contentTime
contentTime: contentTime,
mainInstrument: mainInstrument
};
commonStore.setTracks(tracks);
refreshTracksTotalTime();

View File

@@ -1,5 +1,5 @@
{
"version": "1.5.4",
"version": "1.5.7",
"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的优点结合起来 - 高性能、快速推理、节省显存、快速训练、“无限”上下文长度以及免费的语句嵌入(使用最终隐藏状态)。"