chess : tuning performance

This commit is contained in:
Georgi Gerganov 2023-11-30 10:50:47 +02:00
parent 70741ba794
commit 15c4fdce45
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735
3 changed files with 19 additions and 14 deletions

View File

@ -155,8 +155,8 @@ std::string Chessboard::getRules(const std::string& prompt) const {
"# leading space is very important!\n" "# leading space is very important!\n"
"\n"; "\n";
if (prompt.empty()) { if (prompt.empty()) {
// result += "move ::= \" \" ((piece | frompos) \" \" \"to \"?)? topos\n"; result += "move ::= \" \" ((piece | frompos) \" \" \"to \"?)? topos\n";
result += "move ::= \" \" frompos \" \" \"to \"? topos\n"; //result += "move ::= \" \" frompos \" \" \"to \"? topos\n";
} }
else { else {
// result += "move ::= prompt \" \" ((piece | frompos) \" \" \"to \"?)? topos\n" // 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]); from_pos.insert(positions[m.first]);
to_pos.insert(positions[m.second]); to_pos.insert(positions[m.second]);
} }
// if (!pieces.empty()) { if (!pieces.empty()) {
// result += "piece ::= ("; result += "piece ::= (";
// for (auto& p : pieces) result += " \"" + p + "\" |"; for (auto& p : pieces) result += " \"" + p + "\" |";
// result.pop_back(); result.pop_back();
// result += ")\n\n"; result += ")\n\n";
// } }
if (!from_pos.empty()) { if (!from_pos.empty()) {
result += "frompos ::= ("; result += "frompos ::= (";
for (auto& p : from_pos) result += " \"" + p + "\" |"; for (auto& p : from_pos) result += " \"" + p + "\" |";
@ -711,4 +711,4 @@ bool Chessboard::move(const Move& m) {
board[m.first] = nullptr; board[m.first] = nullptr;
board[m.second]->pos = m.second; board[m.second]->pos = m.second;
return true; return true;
} }

View File

@ -188,7 +188,7 @@
// 'base-en-q5_1': 57, // '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 dst = 'whisper.bin';
let size_mb = 75; let size_mb = 75;
@ -272,6 +272,7 @@
let audio = renderedBuffer.getChannelData(0); let audio = renderedBuffer.getChannelData(0);
if (instance) { if (instance) {
printTextarea('js: number of samples: ' + audio.length);
Module.set_audio(instance, audio); Module.set_audio(instance, audio);
} }
}); });
@ -338,7 +339,9 @@
} }
function onStop() { function onStop() {
printTextarea('js: stopping recording ...');
stopRecording(); stopRecording();
var interval = setInterval(function() { var interval = setInterval(function() {
var moves = Module.get_moves(); var moves = Module.get_moves();

View File

@ -55,19 +55,21 @@ void wchess_main(size_t i) {
wparams.print_progress = false; wparams.print_progress = false;
wparams.print_timestamps = true; wparams.print_timestamps = true;
wparams.print_special = false; wparams.print_special = false;
wparams.no_timestamps = true;
wparams.max_tokens = 32; 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 = 0.0f;
wparams.temperature_inc = 1.0f; wparams.temperature_inc = 2.0f;
wparams.greedy.best_of = 1; wparams.greedy.best_of = 1;
wparams.beam_search.beam_size = 5; wparams.beam_search.beam_size = 1;
wparams.language = "en"; wparams.language = "en";
wparams.grammar_penalty = 100.0; 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); printf("command: using %d threads\n", wparams.n_threads);