Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whisper pipeline: implement 'initial_prompt' and 'hotwords' parameters #1378

Merged
merged 17 commits into from
Dec 19, 2024

Conversation

as-suvorov
Copy link
Contributor

@as-suvorov as-suvorov commented Dec 13, 2024

Adds:

  • initial_prompt parameter (faster_whisper reference) - injects initial prompt tokens as a previous transcription into the first processing window
  • hotwords parameter (faster_whisper reference) - injects hotwords tokens as a previous transcription into the all processing windows
  • Whisper pipeline usage notes in samples

Closes #1150
Ticket: 156888

@github-actions github-actions bot added category: whisper Whisper pipeline category: Python API Python API for GenAI category: samples GenAI samples category: GenAI C++ API Changes in GenAI C++ public headers labels Dec 13, 2024
@as-suvorov as-suvorov added this to the 2025.0 milestone Dec 13, 2024
@as-suvorov as-suvorov marked this pull request as draft December 13, 2024 10:13
@as-suvorov as-suvorov marked this pull request as ready for review December 13, 2024 14:52
Comment on lines +575 to +576
OPENVINO_ASSERT(!config.initial_prompt.has_value(), "'initial_prompt' parameter is not supported on NPU device.");
OPENVINO_ASSERT(!config.hotwords.has_value(), "'hotwords' parameter is not supported on NPU device.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TolyaTalamanov
I wanted to add support of both parameters to static pipeline, but realized it could affect first token performance.
We need to increase decoder input size from 4 to say half of max window (448/2):
https://github.com/openvinotoolkit/openvino.genai/pull/1378/files#diff-d12890f3f3d40e33557c7aa7fd3b13593d022cb3921484837159ccf9a6e48d4aR548
reshape_to_static(decoder_model, 4, 4, last_hidden_state_shape); -> reshape_to_static(decoder_model, 448/2, 448/2, last_hidden_state_shape);

As I understand this could reduce performance in case of neither initial_prompt nor hotwords are set.

src/cpp/src/whisper/context_tokens.cpp Outdated Show resolved Hide resolved
src/cpp/src/whisper/context_tokens.cpp Outdated Show resolved Hide resolved
src/cpp/src/whisper/context_tokens.cpp Outdated Show resolved Hide resolved
src/cpp/src/whisper/context_tokens.cpp Outdated Show resolved Hide resolved
@as-suvorov as-suvorov requested a review from Wovchena December 17, 2024 13:59
samples/cpp/whisper_speech_recognition/README.md Outdated Show resolved Hide resolved
samples/cpp/whisper_speech_recognition/README.md Outdated Show resolved Hide resolved
src/python/py_whisper_pipeline.cpp Show resolved Hide resolved
src/cpp/src/whisper/context_tokens.cpp Show resolved Hide resolved
@as-suvorov as-suvorov requested a review from Wovchena December 18, 2024 08:52
@Wovchena Wovchena added this pull request to the merge queue Dec 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 18, 2024
@Wovchena Wovchena added this pull request to the merge queue Dec 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 18, 2024
@Wovchena Wovchena added this pull request to the merge queue Dec 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 19, 2024
@Wovchena Wovchena added this pull request to the merge queue Dec 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 19, 2024
@Wovchena Wovchena added this pull request to the merge queue Dec 19, 2024
Merged via the queue into openvinotoolkit:master with commit 0be7b3d Dec 19, 2024
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: GenAI C++ API Changes in GenAI C++ public headers category: Python API Python API for GenAI category: samples GenAI samples category: whisper Whisper pipeline no-match-files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Initial Prompt and Hotwords in WhisperPipeline (similar to faster-whisper)
3 participants