lm_polygraph.estimators.kernel_language_entropy module
- class lm_polygraph.estimators.kernel_language_entropy.KernelLanguageEntropy(t: float = 0.3, normalize: bool = True, scale: bool = True, jitter: float = 0)[source]
Bases:
EstimatorEstimates the sequence-level uncertainty of a language model following the method of “Kernel Language Entropy” as provided in the paper https://arxiv.org/pdf/2405.20003 Works with both whitebox and blackbox models (initialized using lm_polygraph.utils.model.BlackboxModel/WhiteboxModel).
This method calculates KLE(Kheat) = VNE(Kheat), where VNE is von Neumann entropy and Kheat is a heat kernel of a semantic graph over language model’s outputs.
- lm_polygraph.estimators.kernel_language_entropy.heat_kernel(laplacian: ndarray, t: float) ndarray[source]
- lm_polygraph.estimators.kernel_language_entropy.laplacian_matrix(weighted_graph: ndarray) ndarray[source]