mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-01-01 18:26:40 +00:00
whisper : add support for new distilled Whisper models
This commit is contained in:
parent
8a2bee6717
commit
b8c93c5f3b
12
whisper.cpp
12
whisper.cpp
@ -3942,6 +3942,7 @@ static void whisper_process_logits(
|
|||||||
// suppress task tokens
|
// suppress task tokens
|
||||||
logits[vocab.token_translate] = -INFINITY;
|
logits[vocab.token_translate] = -INFINITY;
|
||||||
logits[vocab.token_transcribe] = -INFINITY;
|
logits[vocab.token_transcribe] = -INFINITY;
|
||||||
|
logits[vocab.token_prev] = -INFINITY;
|
||||||
|
|
||||||
if (params.logits_filter_callback) {
|
if (params.logits_filter_callback) {
|
||||||
params.logits_filter_callback(&ctx, &state, tokens_cur.data(), tokens_cur.size(), logits.data(), params.logits_filter_callback_user_data);
|
params.logits_filter_callback(&ctx, &state, tokens_cur.data(), tokens_cur.size(), logits.data(), params.logits_filter_callback_user_data);
|
||||||
@ -4560,6 +4561,7 @@ int whisper_full_with_state(
|
|||||||
|
|
||||||
// these tokens determine the task that will be performed
|
// these tokens determine the task that will be performed
|
||||||
std::vector<whisper_token> prompt_init = { whisper_token_sot(ctx) };
|
std::vector<whisper_token> prompt_init = { whisper_token_sot(ctx) };
|
||||||
|
|
||||||
if (whisper_is_multilingual(ctx)) {
|
if (whisper_is_multilingual(ctx)) {
|
||||||
const int lang_id = whisper_lang_id(params.language);
|
const int lang_id = whisper_lang_id(params.language);
|
||||||
state->lang_id = lang_id;
|
state->lang_id = lang_id;
|
||||||
@ -4571,6 +4573,16 @@ int whisper_full_with_state(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const bool is_distil = ctx->model.hparams.n_text_layer == 2;
|
||||||
|
|
||||||
|
// distilled models require the "no_timestamps" token
|
||||||
|
// TODO: add input parameter (#1229)
|
||||||
|
if (is_distil) {
|
||||||
|
prompt_init.push_back(whisper_token_not(ctx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int seek = seek_start;
|
int seek = seek_start;
|
||||||
|
|
||||||
std::vector<whisper_token> prompt;
|
std::vector<whisper_token> prompt;
|
||||||
|
Loading…
Reference in New Issue
Block a user