Skip to content

Add PrefixSpeechLmOnnxLabelScorer - #218

Open
SimBe195 wants to merge 26 commits into
tokenizerfrom
prefix_speech_lm_scorer
Open

SimBe195 wants to merge 26 commits into
tokenizerfrom
prefix_speech_lm_scorer

Conversation

@SimBe195

@SimBe195 SimBe195 commented May 8, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds a new LabelScorer which can be used for Speech LLMs. Structurally it is roughly similar to the StateManagedOnnxLabelScorer from #206. The main difference is how the initial states are constructed. While the StateMangedOnnxLabelScorer only gets one or more start labels as initial history while the PrefixSpeechLmOnnxLabelScorer has a separate initializer ONNX model which gets an initial-prompt, encoder-states and suffix-prompt to produce the initial scores and states. Also, the StateManagedOnnxLabelScorer feeds in the encoder-states at every scoring step while the PrefixSpeechLmOnnxLabelScorer only feeds the encoder-states for the initialization.

Depends on #287.

Prompts can be given as token ids (initial-prompt-labels, suffix-prompt-labels) or as text
(initial-prompt, suffix-prompt), tokenized with the tokenizer configured under tokenizer.*.

@SimBe195
SimBe195 changed the base branch from master to state_manager_label_scorer May 8, 2026 12:04
Base automatically changed from state_manager_label_scorer to master May 22, 2026 11:52
Comment thread src/Nn/LabelScorer/ScoringContext.hh Resolved
SimBe195 and others added 4 commits July 3, 2026 13:34
---------

Co-authored-by: Eugen Beck <ebeck@apptek.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…288)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@larissakl

Copy link
Copy Markdown
Contributor

I have one suggestion for this label scorer (I can also implement this myself in a separate PR). Speech LLMs usually have a very large vocab, but only a very small percentage of label extensions survive in the beam search. However, all scores are copied from GPU to CPU in every step, therefore I think it would make sense to make RASR copy only the top-max-beam-size scores per hypothesis.
Concretely, I thought we could introduce a SparseScoreSpan (parallel to DenseScoreSpan) and a new SparseScoreAccessors, in which the getScore() function returns the actual score for labels in the list and the max score for all others. In this label scorer here, we would then need optional step model outputs (e.g. topk-scores and topk-indices) in the io-map. If they are set, only those are read, sorted, de-duplicated and cached as sparse scores. The actual top-k "pruning" then has to be implemented by the ONNX model, which should however not be a large change.

SimBe195 and others added 3 commits October 30, 2026 15:44
---------

Co-authored-by: Larissa <larissa.kleppel@rwth-aachen.de>
Co-authored-by: Eugen Beck <ebeck@apptek.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Adapt PrefixSpeechLmOnnxLabelScorer to the StatTrackingLabelScorer interface
(resetInternal/computeScoreAccessor(s)) and add timing statistics. Remove the
duplicate registration of state-managed-onnx outside of the MODULE_ONNX guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SimBe195 and others added 3 commits November 4, 2026 14:16
Add `initial-prompt` and `suffix-prompt` parameters as alternatives to the
`*-prompt-labels` token id parameters. Text prompts are tokenized with the
tokenizer configured in the `tokenizer` sub-component. Since RASR config
values can't contain newlines and lose leading/trailing whitespace, the
escape sequences \n, \t, \r, \\ and \xHH are replaced before tokenization.

Also document the label scorer in the SearchV2 docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Assign states to all scored contexts, not only to the one of several
  equal contexts that went through the step model
- Set historyLength when a context is scored instead of when it is created
- Support silence transitions via `silence-updates-history`
- Raise an error if a prompt is set but the initializer model has no input
  for it
- Create the tokenizer once in the constructor and forward-declare it in
  the header
- Remove unreachable checks, order definitions as in the header and only
  link RasrTokenizer with MODULE_ONNX

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The encoder states are only needed for the prefill, so release the input
buffer afterwards and build the ONNX encoder states value locally instead
of keeping it for the whole segment. The initial scores are kept in a
member since the prefill can't be recomputed after the cleanup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SimBe195
SimBe195 changed the base branch from master to tokenizer November 4, 2026 15:58
@SimBe195

SimBe195 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

I have one suggestion for this label scorer (I can also implement this myself in a separate PR). Speech LLMs usually have a very large vocab, but only a very small percentage of label extensions survive in the beam search. However, all scores are copied from GPU to CPU in every step, therefore I think it would make sense to make RASR copy only the top-max-beam-size scores per hypothesis. Concretely, I thought we could introduce a SparseScoreSpan (parallel to DenseScoreSpan) and a new SparseScoreAccessors, in which the getScore() function returns the actual score for labels in the list and the max score for all others. In this label scorer here, we would then need optional step model outputs (e.g. topk-scores and topk-indices) in the io-map. If they are set, only those are read, sorted, de-duplicated and cached as sparse scores. The actual top-k "pruning" then has to be implemented by the ONNX model, which should however not be a large change.

Yes I think this is a great idea but in a separate PR. It would also ideally come with some modifications to the search so that it only actually iterates over the non-max labels instead of still looping over all possible successors.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants