Repository navigation
Conversation
With the flag, every note gets a MusicXML comment next to imgpos, e.g. <!-- conf: r:0.9987:0.9971;p:0.94:0.88;l:...;a:...;s:...;o:... --> with the softmax probability of the chosen token and its margin to the runner-up for each decoder branch. A choir rehearsal app uses this to flag uncertain measures for review. The token selection is still the plain argmax and without the flag nothing is computed or written.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
homr only outputs the decoder's argmax, so downstream tools can't tell a confident note from a guess. A choir rehearsal app uses the decoder's confidence to flag uncertain measures for human review.
What it does
With
--output-confidence, each<note>gets a comment next toimgpos, for example:One entry per decoder branch:
rrhythm,ppitch,llift,aarticulation,sslur/beam,oposition. Each entry isbranch:probability:margin: the softmax probability of the chosen token and its gap to the second most likely token, both in [0, 1]. A comment (likeimgpos) keeps the MusicXML schema-valid. The values describe model certainty and are not calibrated error rates.Opt-in
The flag sets
Config.output_confidence(default off). Without it nothing extra is computed, the output is unchanged, and token selection stays argmax. The decoder only reads logits it already has.Tests
tests/test_confidence.pyruns without model weights and covers the probability/margin helper, no comment without the flag, a parseable comment with values in range with the flag, a mocked decoder session that picks the same tokens with and without confidence, and the CLI flag defaulting to off.black,isortandruffpass; the related test files pass (107 tests);mypyreports only the two errors that also exist on main ininference_segnet.py. Not run yet: fullmake ci(training dependencies) and the Polish scores benchmark fromAGENTS.md. The default path is unchanged, so no difference is expected there. That's why this is a draft. Happy to add the benchmark run if you'd like to have it.AI usage
This was ported and drafted by Claude Code (an AI coding agent) from a patch we already run in production, and the agent ran the checks listed above. A person on our side approved submitting it. Feedback is very welcome, including "please do it differently".