Adding two sequence-level and consistency-based uncertainty measures: Predictive Kernel Entropy and Spectral uncertainty#460
Open
nassimwalha wants to merge 3 commits into
Open
Conversation
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.
Both methods rely on the following stat calculators:
BlackboxSamplingGenerationCalculatororSamplingGenerationCalculatorto generate multiple samples from the target llm for a single input query.SampleSentenceEmbeddingsCalculator(newly created in this pull request), to compute sentence embeddings of the sampled answers using a SentenceTransformer model. The SentenceTransformer model is managed by the newly createdSentenceEmbedderclass inlm_polygraph.utils.sentence_embedder(implemented analogously toDberta).PKE computes pairwise kernel values of the embeeddings and then averages them out, SU creates an empirical kernel matrix out of the pairwise values, normalizes it and computes its Von Neumann Entropy.
PS: In the paper, SU comes with a decomposition into aleatoric and epistemic uncertainty using input clarifications. As this is not necessairly specific to SU and can be applied to any other sequence-level uncertainty method, implementing the decomposition will come in a future pull request.
Additional change: compatibility fixes of the class
AutoModelForVision2Seqfor transformers >= 5.0 (these were included in some parts of the repo already, but not everywhere)