Buckets:

rtrm's picture
|
download
raw
47.4 kB

Metrics

Metrics

Metric[[lighteval.metrics.Metric]]

class lighteval.metrics.Metriclighteval.metrics.Metrichttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/metric_utils.py#L33[{"name": "metric_name", "val": ": str"}, {"name": "higher_is_better", "val": ": bool"}, {"name": "category", "val": ": SamplingMethod"}, {"name": "sample_level_fn", "val": ": lighteval.metrics.metrics_sample.SampleLevelComputation | lighteval.metrics.sample_preparator.Preparator"}, {"name": "corpus_level_fn", "val": ": typing.Union[lighteval.metrics.metrics_corpus.CorpusLevelComputation, typing.Callable]"}, {"name": "batched_compute", "val": ": bool = False"}]

CorpusLevelMetric[[lighteval.metrics.utils.metric_utils.CorpusLevelMetric]]

class lighteval.metrics.utils.metric_utils.CorpusLevelMetriclighteval.metrics.utils.metric_utils.CorpusLevelMetrichttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/metric_utils.py#L114[{"name": "metric_name", "val": ": str"}, {"name": "higher_is_better", "val": ": bool"}, {"name": "category", "val": ": SamplingMethod"}, {"name": "sample_level_fn", "val": ": lighteval.metrics.metrics_sample.SampleLevelComputation | lighteval.metrics.sample_preparator.Preparator"}, {"name": "corpus_level_fn", "val": ": typing.Union[lighteval.metrics.metrics_corpus.CorpusLevelComputation, typing.Callable]"}, {"name": "batched_compute", "val": ": bool = False"}] Metric computed over the whole corpora, with computations happening at the aggregation phase

SampleLevelMetric[[lighteval.metrics.utils.metric_utils.SampleLevelMetric]]

class lighteval.metrics.utils.metric_utils.SampleLevelMetriclighteval.metrics.utils.metric_utils.SampleLevelMetrichttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/metric_utils.py#L121[{"name": "metric_name", "val": ": str"}, {"name": "higher_is_better", "val": ": bool"}, {"name": "category", "val": ": SamplingMethod"}, {"name": "sample_level_fn", "val": ": lighteval.metrics.metrics_sample.SampleLevelComputation | lighteval.metrics.sample_preparator.Preparator"}, {"name": "corpus_level_fn", "val": ": typing.Union[lighteval.metrics.metrics_corpus.CorpusLevelComputation, typing.Callable]"}, {"name": "batched_compute", "val": ": bool = False"}] Metric computed per sample, then aggregated over the corpus

MetricGrouping[[lighteval.metrics.utils.metric_utils.MetricGrouping]]

class lighteval.metrics.utils.metric_utils.MetricGroupinglighteval.metrics.utils.metric_utils.MetricGroupinghttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/metric_utils.py#L103[{"name": "metric_name", "val": ": list"}, {"name": "higher_is_better", "val": ": dict"}, {"name": "category", "val": ": SamplingMethod"}, {"name": "sample_level_fn", "val": ": lighteval.metrics.metrics_sample.SampleLevelComputation | lighteval.metrics.sample_preparator.Preparator"}, {"name": "corpus_level_fn", "val": ": dict"}, {"name": "batched_compute", "val": ": bool = False"}] Some metrics are more advantageous to compute together at once. For example, if a costly preprocessing is the same for all metrics, it makes more sense to compute it once.

CorpusLevelMetricGrouping[[lighteval.metrics.utils.metric_utils.CorpusLevelMetricGrouping]]

class lighteval.metrics.utils.metric_utils.CorpusLevelMetricGroupinglighteval.metrics.utils.metric_utils.CorpusLevelMetricGroupinghttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/metric_utils.py#L128[{"name": "metric_name", "val": ": list"}, {"name": "higher_is_better", "val": ": dict"}, {"name": "category", "val": ": SamplingMethod"}, {"name": "sample_level_fn", "val": ": lighteval.metrics.metrics_sample.SampleLevelComputation | lighteval.metrics.sample_preparator.Preparator"}, {"name": "corpus_level_fn", "val": ": dict"}, {"name": "batched_compute", "val": ": bool = False"}] MetricGrouping computed over the whole corpora, with computations happening at the aggregation phase

SampleLevelMetricGrouping[[lighteval.metrics.utils.metric_utils.SampleLevelMetricGrouping]]

class lighteval.metrics.utils.metric_utils.SampleLevelMetricGroupinglighteval.metrics.utils.metric_utils.SampleLevelMetricGroupinghttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/metric_utils.py#L135[{"name": "metric_name", "val": ": list"}, {"name": "higher_is_better", "val": ": dict"}, {"name": "category", "val": ": SamplingMethod"}, {"name": "sample_level_fn", "val": ": lighteval.metrics.metrics_sample.SampleLevelComputation | lighteval.metrics.sample_preparator.Preparator"}, {"name": "corpus_level_fn", "val": ": dict"}, {"name": "batched_compute", "val": ": bool = False"}] MetricGrouping are computed per sample, then aggregated over the corpus

Corpus Metrics

CorpusLevelF1Score[[lighteval.metrics.metrics_corpus.CorpusLevelF1Score]]

class lighteval.metrics.metrics_corpus.CorpusLevelF1Scorelighteval.metrics.metrics_corpus.CorpusLevelF1Scorehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L81[{"name": "average", "val": ": str"}, {"name": "num_classes", "val": ": int = 2"}]

compute_corpuslighteval.metrics.metrics_corpus.CorpusLevelF1Score.compute_corpushttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L96[{"name": "items", "val": ": list"}] Computes the metric score over all the corpus generated items, by using the scikit learn implementation.

CorpusLevelPerplexityMetric[[lighteval.metrics.metrics_corpus.CorpusLevelPerplexityMetric]]

class lighteval.metrics.metrics_corpus.CorpusLevelPerplexityMetriclighteval.metrics.metrics_corpus.CorpusLevelPerplexityMetrichttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L164[{"name": "metric_type", "val": ": str"}]

compute_corpuslighteval.metrics.metrics_corpus.CorpusLevelPerplexityMetric.compute_corpushttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L182[{"name": "items", "val": ": list"}] Computes the metric score over all the corpus generated items.

CorpusLevelTranslationMetric[[lighteval.metrics.metrics_corpus.CorpusLevelTranslationMetric]]

class lighteval.metrics.metrics_corpus.CorpusLevelTranslationMetriclighteval.metrics.metrics_corpus.CorpusLevelTranslationMetrichttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L116[{"name": "metric_type", "val": ": str"}, {"name": "lang", "val": ": typing.Literal['zh', 'ja', 'ko', ''] = ''"}]

compute_corpuslighteval.metrics.metrics_corpus.CorpusLevelTranslationMetric.compute_corpushttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L142[{"name": "items", "val": ": list"}] Computes the metric score over all the corpus generated items, by using the sacrebleu implementation.

MatthewsCorrCoef[[lighteval.metrics.metrics_corpus.MatthewsCorrCoef]]

class lighteval.metrics.metrics_corpus.MatthewsCorrCoeflighteval.metrics.metrics_corpus.MatthewsCorrCoefhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L66[]

compute_corpuslighteval.metrics.metrics_corpus.MatthewsCorrCoef.compute_corpushttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_corpus.py#L67[{"name": "items", "val": ": list"}]- items (list[dict]) -- List of GenerativeCorpusMetricInput0floatScore Computes the Matthews Correlation Coefficient, using scikit learn (doc).

Sample Metrics

ExactMatches[[lighteval.metrics.metrics_sample.ExactMatches]]

class lighteval.metrics.metrics_sample.ExactMatcheslighteval.metrics.metrics_sample.ExactMatcheshttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L81[{"name": "aggregation_function", "val": ": typing.Callable[[list[float]], float] = "}, {"name": "normalize_gold", "val": ": typing.Optional[typing.Callable[[str], str]] = None"}, {"name": "normalize_pred", "val": ": typing.Optional[typing.Callable[[str], str]] = None"}, {"name": "strip_strings", "val": ": bool = False"}, {"name": "type_exact_match", "val": ": str = 'full'"}]

computelighteval.metrics.metrics_sample.ExactMatches.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L118[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0floatAggregated score over the current sample's items. Computes the metric over a list of golds and predictions for one single sample.

compute_one_itemlighteval.metrics.metrics_sample.ExactMatches.compute_one_itemhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L137[{"name": "gold", "val": ": str"}, {"name": "pred", "val": ": str"}]- gold (str) -- One of the possible references

  • pred (str) -- One of the possible predictions0floatThe exact match score. Will be 1 for a match, 0 otherwise. Compares two strings only.

F1_score[[lighteval.metrics.metrics_sample.F1_score]]

class lighteval.metrics.metrics_sample.F1_scorelighteval.metrics.metrics_sample.F1_scorehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L170[{"name": "aggregation_function", "val": ": typing.Callable[[list[float]], float] = "}, {"name": "normalize_gold", "val": ": typing.Optional[typing.Callable[[str], str]] = None"}, {"name": "normalize_pred", "val": ": typing.Optional[typing.Callable[[str], str]] = None"}, {"name": "strip_strings", "val": ": bool = False"}]

computelighteval.metrics.metrics_sample.F1_score.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L197[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0floatAggregated score over the current sample's items. Computes the metric over a list of golds and predictions for one single sample.

compute_one_itemlighteval.metrics.metrics_sample.F1_score.compute_one_itemhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L217[{"name": "gold", "val": ": str"}, {"name": "pred", "val": ": str"}]- gold (str) -- One of the possible references

  • pred (str) -- One of the possible predictions0floatThe f1 score over the bag of words, computed using nltk. Compares two strings only.

LoglikelihoodAcc[[lighteval.metrics.metrics_sample.LoglikelihoodAcc]]

class lighteval.metrics.metrics_sample.LoglikelihoodAcclighteval.metrics.metrics_sample.LoglikelihoodAcchttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L243[{"name": "logprob_normalization", "val": ": lighteval.metrics.normalizations.LogProbCharNorm | lighteval.metrics.normalizations.LogProbTokenNorm | lighteval.metrics.normalizations.LogProbPMINorm | None = None"}]

computelighteval.metrics.metrics_sample.LoglikelihoodAcc.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L254[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing choices and gold indices.

  • model_response (ModelResponse) -- The model's response containing logprobs.
  • **kwargs -- Additional keyword arguments.0intThe eval score: 1 if the best log-prob choice is in gold, 0 otherwise. Computes the log likelihood accuracy: is the choice with the highest logprob in choices_logprob present in the gold_ixs?

NormalizedMultiChoiceProbability[[lighteval.metrics.metrics_sample.NormalizedMultiChoiceProbability]]

class lighteval.metrics.metrics_sample.NormalizedMultiChoiceProbabilitylighteval.metrics.metrics_sample.NormalizedMultiChoiceProbabilityhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L297[{"name": "log_prob_normalization", "val": ": lighteval.metrics.normalizations.LogProbCharNorm | lighteval.metrics.normalizations.LogProbTokenNorm | lighteval.metrics.normalizations.LogProbPMINorm | None = None"}, {"name": "aggregation_function", "val": ": typing.Callable[[numpy.ndarray], float] = <function max at 0x7f179aceeff0>"}]

computelighteval.metrics.metrics_sample.NormalizedMultiChoiceProbability.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L313[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing choices and gold indices.

  • model_response (ModelResponse) -- The model's response containing logprobs.
  • **kwargs -- Additional keyword arguments.0floatThe probability of the best log-prob choice being a gold choice. Computes the log likelihood probability: chance of choosing the best choice.

Probability[[lighteval.metrics.metrics_sample.Probability]]

class lighteval.metrics.metrics_sample.Probabilitylighteval.metrics.metrics_sample.Probabilityhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L357[{"name": "normalization", "val": ": lighteval.metrics.normalizations.LogProbTokenNorm | None = None"}, {"name": "aggregation_function", "val": ": typing.Callable[[numpy.ndarray], float] = <function max at 0x7f179aceeff0>"}]

computelighteval.metrics.metrics_sample.Probability.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L373[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing choices and gold indices.

  • model_response (ModelResponse) -- The model's response containing logprobs.
  • **kwargs -- Additional keyword arguments.0floatThe probability of the best log-prob choice being a gold choice. Computes the log likelihood probability: chance of choosing the best choice.

Recall[[lighteval.metrics.metrics_sample.Recall]]

class lighteval.metrics.metrics_sample.Recalllighteval.metrics.metrics_sample.Recallhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L408[{"name": "k", "val": ": int"}]

computelighteval.metrics.metrics_sample.Recall.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L418[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing choices and gold indices.

  • model_response (ModelResponse) -- The model's response containing logprobs.
  • **kwargs -- Additional keyword arguments.0intScore: 1 if one of the top level predicted choices was correct, 0 otherwise. Computes the recall at the requested depth level: looks at the n best predicted choices (with the highest log probabilities) and see if there is an actual gold among them.

MRR[[lighteval.metrics.metrics_sample.MRR]]

class lighteval.metrics.metrics_sample.MRRlighteval.metrics.metrics_sample.MRRhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L438[{"name": "length_normalization", "val": ": bool = False"}]

computelighteval.metrics.metrics_sample.MRR.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L447[{"name": "model_response", "val": ": ModelResponse"}, {"name": "doc", "val": ": Doc"}, {"name": "**kwargs", "val": ""}]- model_response (ModelResponse) -- The model's response containing logprobs.

  • doc (Doc) -- The document containing choices and gold indices.
  • **kwargs -- Additional keyword arguments.0floatMRR score. Mean reciprocal rank. Measures the quality of a ranking of choices (ordered by correctness).

ROUGE[[lighteval.metrics.metrics_sample.ROUGE]]

class lighteval.metrics.metrics_sample.ROUGElighteval.metrics.metrics_sample.ROUGEhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L486[{"name": "methods", "val": ": str | list[str]"}, {"name": "multiple_golds", "val": ": bool = False"}, {"name": "bootstrap", "val": ": bool = False"}, {"name": "normalize_gold", "val": ": typing.Optional[typing.Callable] = None"}, {"name": "normalize_pred", "val": ": typing.Optional[typing.Callable] = None"}, {"name": "aggregation_function", "val": ": typing.Optional[typing.Callable] = None"}, {"name": "tokenizer", "val": ": object = None"}]

computelighteval.metrics.metrics_sample.ROUGE.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L533[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0float or dictAggregated score over the current sample's items. If several rouge functions have been selected, returns a dict which maps name and scores. Computes the metric(s) over a list of golds and predictions for one single sample.

BertScore[[lighteval.metrics.metrics_sample.BertScore]]

class lighteval.metrics.metrics_sample.BertScorelighteval.metrics.metrics_sample.BertScorehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L598[{"name": "normalize_gold", "val": ": typing.Optional[typing.Callable] = None"}, {"name": "normalize_pred", "val": ": typing.Optional[typing.Callable] = None"}]

computelighteval.metrics.metrics_sample.BertScore.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L628[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0dictScores over the current sample's items. Computes the prediction, recall and f1 score using the bert scorer.

Extractiveness[[lighteval.metrics.metrics_sample.Extractiveness]]

class lighteval.metrics.metrics_sample.Extractivenesslighteval.metrics.metrics_sample.Extractivenesshttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L661[{"name": "normalize_input", "val": ": = <function remove_braces at 0x7f1693a1eb00>"}, {"name": "normalize_pred", "val": ": = <function remove_braces_and_strip at 0x7f1693a1eb90>"}, {"name": "input_column", "val": ": str = 'text'"}, {"name": "language", "val": ": typing.Literal['en', 'de', 'fr', 'it'] = 'en'"}]

computelighteval.metrics.metrics_sample.Extractiveness.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L685[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing input text.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0dict[str, float]The extractiveness scores. Compute the extractiveness of the predictions.

This method calculates coverage, density, and compression scores for a single prediction against the input text.

Faithfulness[[lighteval.metrics.metrics_sample.Faithfulness]]

class lighteval.metrics.metrics_sample.Faithfulnesslighteval.metrics.metrics_sample.Faithfulnesshttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L717[{"name": "normalize_input", "val": ": typing.Callable = <function remove_braces at 0x7f1693a1eb00>"}, {"name": "normalize_pred", "val": ": typing.Callable = <function remove_braces_and_strip at 0x7f1693a1eb90>"}, {"name": "input_column", "val": ": str = 'text'"}]

computelighteval.metrics.metrics_sample.Faithfulness.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L738[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing input text.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0dict[str, float]The faithfulness scores. Compute the faithfulness of the predictions.

The SummaCZS (Summary Content Zero-Shot) model is used with configurable granularity and model variation.

BLEURT[[lighteval.metrics.metrics_sample.BLEURT]]

class lighteval.metrics.metrics_sample.BLEURTlighteval.metrics.metrics_sample.BLEURThttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L765[]

computelighteval.metrics.metrics_sample.BLEURT.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L786[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0floatScore over the current sample's items. Uses the stored BLEURT scorer to compute the score on the current sample.

BLEU[[lighteval.metrics.metrics_sample.BLEU]]

class lighteval.metrics.metrics_sample.BLEUlighteval.metrics.metrics_sample.BLEUhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L805[{"name": "n_gram", "val": ": int"}]

computelighteval.metrics.metrics_sample.BLEU.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L815[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0floatScore over the current sample's items. Computes the sentence level BLEU between the golds and each prediction, then takes the average.

StringDistance[[lighteval.metrics.metrics_sample.StringDistance]]

class lighteval.metrics.metrics_sample.StringDistancelighteval.metrics.metrics_sample.StringDistancehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L847[{"name": "metric_types", "val": ": list[str] | str"}, {"name": "strip_prediction", "val": ": bool = True"}]

computelighteval.metrics.metrics_sample.StringDistance.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L869[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0dictThe different scores computed Computes all the requested metrics on the golds and prediction.

edit_similaritylighteval.metrics.metrics_sample.StringDistance.edit_similarityhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L927[{"name": "s1", "val": ""}, {"name": "s2", "val": ""}]floatEdit similarity score between 0 and 1 Compute the edit similarity between two lists of strings.

Edit similarity is also used in the paper Lee, Katherine, et al. "Deduplicating training data makes language models better." arXiv preprint arXiv:2107.06499 (2021).

longest_common_prefix_lengthlighteval.metrics.metrics_sample.StringDistance.longest_common_prefix_lengthhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L920[{"name": "s1", "val": ": ndarray"}, {"name": "s2", "val": ": ndarray"}] Compute the length of the longest common prefix.

JudgeLLM[[lighteval.metrics.metrics_sample.JudgeLLM]]

class lighteval.metrics.metrics_sample.JudgeLLMlighteval.metrics.metrics_sample.JudgeLLMhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L942[{"name": "judge_model_name", "val": ": str"}, {"name": "template", "val": ": typing.Callable"}, {"name": "process_judge_response", "val": ": typing.Callable"}, {"name": "judge_backend", "val": ": typing.Literal['litellm', 'openai', 'transformers', 'vllm', 'tgi', 'inference-providers']"}, {"name": "short_judge_name", "val": ": str | None = None"}, {"name": "response_format", "val": ": pydantic.main.BaseModel | None = None"}, {"name": "url", "val": ": str | None = None"}, {"name": "hf_provider", "val": ": str | None = None"}, {"name": "max_tokens", "val": ": int | None = None"}, {"name": "backend_options", "val": ": dict | None = None"}]

JudgeLLMMTBench[[lighteval.metrics.metrics_sample.JudgeLLMMTBench]]

class lighteval.metrics.metrics_sample.JudgeLLMMTBenchlighteval.metrics.metrics_sample.JudgeLLMMTBenchhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L1046[{"name": "judge_model_name", "val": ": str"}, {"name": "template", "val": ": typing.Callable"}, {"name": "process_judge_response", "val": ": typing.Callable"}, {"name": "judge_backend", "val": ": typing.Literal['litellm', 'openai', 'transformers', 'vllm', 'tgi', 'inference-providers']"}, {"name": "short_judge_name", "val": ": str | None = None"}, {"name": "response_format", "val": ": pydantic.main.BaseModel | None = None"}, {"name": "url", "val": ": str | None = None"}, {"name": "hf_provider", "val": ": str | None = None"}, {"name": "max_tokens", "val": ": int | None = None"}, {"name": "backend_options", "val": ": dict | None = None"}]

computelighteval.metrics.metrics_sample.JudgeLLMMTBench.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L1047[{"name": "model_response", "val": ": list"}, {"name": "docs", "val": ": list"}, {"name": "**kwargs", "val": ""}] Compute the score of a generative task using a llm as a judge. The generative task can be multiturn with 2 turns max, in that case, we return scores for turn 1 and 2. Also returns user_prompt and judgement which are ignored later by the aggregator.

JudgeLLMMixEval[[lighteval.metrics.metrics_sample.JudgeLLMMixEval]]

class lighteval.metrics.metrics_sample.JudgeLLMMixEvallighteval.metrics.metrics_sample.JudgeLLMMixEvalhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L1078[{"name": "judge_model_name", "val": ": str"}, {"name": "template", "val": ": typing.Callable"}, {"name": "process_judge_response", "val": ": typing.Callable"}, {"name": "judge_backend", "val": ": typing.Literal['litellm', 'openai', 'transformers', 'vllm', 'tgi', 'inference-providers']"}, {"name": "short_judge_name", "val": ": str | None = None"}, {"name": "response_format", "val": ": pydantic.main.BaseModel | None = None"}, {"name": "url", "val": ": str | None = None"}, {"name": "hf_provider", "val": ": str | None = None"}, {"name": "max_tokens", "val": ": int | None = None"}, {"name": "backend_options", "val": ": dict | None = None"}]

computelighteval.metrics.metrics_sample.JudgeLLMMixEval.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L1079[{"name": "model_responses", "val": ": list"}, {"name": "docs", "val": ": list"}, {"name": "**kwargs", "val": ""}] Compute the score of a generative task using a llm as a judge. The generative task can be multiturn with 2 turns max, in that case, we return scores for turn 1 and 2. Also returns user_prompt and judgement which are ignored later by the aggregator.

MajAtK[[lighteval.metrics.metrics_sample.MajAtK]]

class lighteval.metrics.metrics_sample.MajAtKlighteval.metrics.metrics_sample.MajAtKhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L1216[{"name": "k", "val": ": int | None = None"}, {"name": "**kwargs", "val": ""}]

computelighteval.metrics.metrics_sample.MajAtK.computehttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/metrics_sample.py#L1229[{"name": "doc", "val": ": Doc"}, {"name": "model_response", "val": ": ModelResponse"}, {"name": "**kwargs", "val": ""}]- doc (Doc) -- The document containing gold references.

  • model_response (ModelResponse) -- The model's response containing predictions.
  • **kwargs -- Additional keyword arguments.0floatAggregated score over the current sample's items. Computes the metric over a list of golds and predictions for one single sample. It applies normalisation (if needed) to model prediction and gold, and takes the most frequent answer of all the available ones, then compares it to the gold.

LLM-as-a-Judge

JudgeLM[[lighteval.metrics.utils.llm_as_judge.JudgeLM]]

class lighteval.metrics.utils.llm_as_judge.JudgeLMlighteval.metrics.utils.llm_as_judge.JudgeLMhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/llm_as_judge.py#L67[{"name": "model", "val": ": str"}, {"name": "templates", "val": ": typing.Callable"}, {"name": "process_judge_response", "val": ": typing.Callable"}, {"name": "judge_backend", "val": ": typing.Literal['litellm', 'openai', 'transformers', 'tgi', 'vllm', 'inference-providers']"}, {"name": "url", "val": ": str | None = None"}, {"name": "api_key", "val": ": str | None = None"}, {"name": "max_tokens", "val": ": int = 512"}, {"name": "response_format", "val": ": BaseModel = None"}, {"name": "hf_provider", "val": ": typing.Optional[typing.Literal['black-forest-labs', 'cerebras', 'cohere', 'fal-ai', 'fireworks-ai', 'inference-providers', 'hyperbolic', 'nebius', 'novita', 'openai', 'replicate', 'sambanova', 'together']] = None"}, {"name": "backend_options", "val": ": dict | None = None"}]- model (str) -- The name of the model.

  • templates (Callable) -- A function taking into account the question, options, answer, and gold and returning the judge prompt.
  • process_judge_response (Callable) -- A function for processing the judge's response.
  • judge_backend (Literal["litellm", "openai", "transformers", "tgi", "vllm", "inference-providers"]) -- The backend for the judge.
  • url (str | None) -- The URL for the OpenAI API.
  • api_key (str | None) -- The API key for the OpenAI API (either OpenAI or HF key).
  • max_tokens (int) -- The maximum number of tokens to generate. Defaults to 512.
  • response_format (BaseModel | None) -- The format of the response from the API, used for the OpenAI and TGI backend.
  • hf_provider (Literal["black-forest-labs", "cerebras", "cohere", "fal-ai", "fireworks-ai", -- "inference-providers", "hyperbolic", "nebius", "novita", "openai", "replicate", "sambanova", "together"] | None): The HuggingFace provider when using the inference-providers backend.
  • backend_options (dict | None) -- Options for the backend. Currently only supported for litellm.0 A class representing a judge for evaluating answers using either the chosen backend.

Methods: evaluate_answer: Evaluates an answer using the OpenAI API or Transformers library. __lazy_load_client: Lazy loads the OpenAI client or Transformers pipeline. __call_api: Calls the API to get the judge's response. __call_transformers: Calls the Transformers pipeline to get the judge's response. __call_vllm: Calls the VLLM pipeline to get the judge's response.

dict_of_lists_to_list_of_dictslighteval.metrics.utils.llm_as_judge.JudgeLM.dict_of_lists_to_list_of_dictshttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/llm_as_judge.py#L204[{"name": "dict_of_lists", "val": ""}]- dict_of_lists -- A dictionary where each value is a list. All lists are expected to have the same length.0A list of dictionaries. Transform a dictionary of lists into a list of dictionaries.

Each dictionary in the output list will contain one element from each list in the input dictionary, with the same keys as the input dictionary.

Example:

dict_of_lists_to_list_of_dicts({'k': [1, 2, 3], 'k2': ['a', 'b', 'c']}) [{'k': 1, 'k2': 'a'}, {'k': 2, 'k2': 'b'}, {'k': 3, 'k2': 'c'}]

evaluate_answerlighteval.metrics.utils.llm_as_judge.JudgeLM.evaluate_answerhttps://github.com/huggingface/lighteval/blob/vr_994/src/lighteval/metrics/utils/llm_as_judge.py#L272[{"name": "question", "val": ": str"}, {"name": "answer", "val": ": str"}, {"name": "options", "val": ": list[str] | None = None"}, {"name": "gold", "val": ": str | None = None"}]- question (str) -- The prompt asked to the evaluated model.

  • answer (str) -- Answer given by the evaluated model.
  • options (list[str] | None) -- Optional list of answer options.
  • gold (str | None) -- Optional reference answer.0A tuple containing the score, prompts, and judgment. Evaluates an answer using either Transformers or OpenAI API.

Xet Storage Details

Size:
47.4 kB
·
Xet hash:
7ea265ad7d26f4b5bb18516f2d33008c3bc2472f9b4f6892d505c68331c4051f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.