From 15c4fdce45b99bcdb82c8294cf733dabb5e8e1af Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 30 Nov 2023 10:50:47 +0200 Subject: [PATCH] chess : tuning performance --- examples/wchess/libwchess/Chessboard.cpp | 18 +++++++++--------- examples/wchess/wchess.wasm/index-tmpl.html | 5 ++++- examples/wchess/wchess.wasm/wchess.wasm.cpp | 10 ++++++---- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/examples/wchess/libwchess/Chessboard.cpp b/examples/wchess/libwchess/Chessboard.cpp index d32f6681..7b839a77 100644 --- a/examples/wchess/libwchess/Chessboard.cpp +++ b/examples/wchess/libwchess/Chessboard.cpp @@ -155,8 +155,8 @@ std::string Chessboard::getRules(const std::string& prompt) const { "# leading space is very important!\n" "\n"; if (prompt.empty()) { - // result += "move ::= \" \" ((piece | frompos) \" \" \"to \"?)? topos\n"; - result += "move ::= \" \" frompos \" \" \"to \"? topos\n"; + result += "move ::= \" \" ((piece | frompos) \" \" \"to \"?)? topos\n"; + //result += "move ::= \" \" frompos \" \" \"to \"? topos\n"; } else { // result += "move ::= prompt \" \" ((piece | frompos) \" \" \"to \"?)? topos\n" @@ -174,12 +174,12 @@ std::string Chessboard::getRules(const std::string& prompt) const { from_pos.insert(positions[m.first]); to_pos.insert(positions[m.second]); } - // if (!pieces.empty()) { - // result += "piece ::= ("; - // for (auto& p : pieces) result += " \"" + p + "\" |"; - // result.pop_back(); - // result += ")\n\n"; - // } + if (!pieces.empty()) { + result += "piece ::= ("; + for (auto& p : pieces) result += " \"" + p + "\" |"; + result.pop_back(); + result += ")\n\n"; + } if (!from_pos.empty()) { result += "frompos ::= ("; for (auto& p : from_pos) result += " \"" + p + "\" |"; @@ -711,4 +711,4 @@ bool Chessboard::move(const Move& m) { board[m.first] = nullptr; board[m.second]->pos = m.second; return true; -} \ No newline at end of file +} diff --git a/examples/wchess/wchess.wasm/index-tmpl.html b/examples/wchess/wchess.wasm/index-tmpl.html index 45ac834b..7d41b4d3 100644 --- a/examples/wchess/wchess.wasm/index-tmpl.html +++ b/examples/wchess/wchess.wasm/index-tmpl.html @@ -188,7 +188,7 @@ // 'base-en-q5_1': 57, // }; - let url = 'https://whisper.ggerganov.com/ggml-model-whisper-tiny.en.bin'; + let url = 'https://whisper.ggerganov.com/ggml-model-whisper-tiny.en-q8_0.bin'; let dst = 'whisper.bin'; let size_mb = 75; @@ -272,6 +272,7 @@ let audio = renderedBuffer.getChannelData(0); if (instance) { + printTextarea('js: number of samples: ' + audio.length); Module.set_audio(instance, audio); } }); @@ -338,7 +339,9 @@ } function onStop() { + printTextarea('js: stopping recording ...'); stopRecording(); + var interval = setInterval(function() { var moves = Module.get_moves(); diff --git a/examples/wchess/wchess.wasm/wchess.wasm.cpp b/examples/wchess/wchess.wasm/wchess.wasm.cpp index 2a8ee917..30c9cca4 100644 --- a/examples/wchess/wchess.wasm/wchess.wasm.cpp +++ b/examples/wchess/wchess.wasm/wchess.wasm.cpp @@ -55,19 +55,21 @@ void wchess_main(size_t i) { wparams.print_progress = false; wparams.print_timestamps = true; wparams.print_special = false; + wparams.no_timestamps = true; wparams.max_tokens = 32; - // wparams.audio_ctx = 768; // partial encoder context for better performance + wparams.audio_ctx = 768; // partial encoder context for better performance - wparams.temperature = 0.4f; - wparams.temperature_inc = 1.0f; + wparams.temperature = 0.0f; + wparams.temperature_inc = 2.0f; wparams.greedy.best_of = 1; - wparams.beam_search.beam_size = 5; + wparams.beam_search.beam_size = 1; wparams.language = "en"; wparams.grammar_penalty = 100.0; + wparams.initial_prompt = "bishop to c3, rook to d4, knight to e5, d4 d5, knight to c3, c3, queen to d4, king b1, pawn to a1, bishop to b2, knight to c3,"; printf("command: using %d threads\n", wparams.n_threads);