lm_polygraph.generation_metrics.alignscore_utils module
- class lm_polygraph.generation_metrics.alignscore_utils.AlignScorer(model: str, batch_size: int, device: int, ckpt_path: str, evaluation_mode='nli_sp', verbose=True)[source]
Bases:
object
- class lm_polygraph.generation_metrics.alignscore_utils.BERTAlignModel(model='roberta-large', using_pretrained=True, *args, **kwargs)[source]
Bases:
Module- forward(batch)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class lm_polygraph.generation_metrics.alignscore_utils.ElectraDiscriminatorPredictions(config)[source]
Bases:
ModulePrediction module for the discriminator, made up of two dense layers.
- forward(discriminator_hidden_states)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class lm_polygraph.generation_metrics.alignscore_utils.Inferencer(ckpt_path='https://huggingface.co/yzha/AlignScore/resolve/main/AlignScore-large.ckpt', model='bert-base-uncased', batch_size=32, device='cuda', verbose=True)[source]
Bases:
object- inference_example_batch(premise: list, hypo: list)[source]
inference a example, premise: list hypo: list using self.inference to batch the process
SummaC Style aggregation
- inference_per_example(premise: str, hypo: str)[source]
inference a example, premise: string hypo: string using self.inference to batch the process
- class lm_polygraph.generation_metrics.alignscore_utils.ModelOutput(loss: torch.FloatTensor | None = None, all_loss: list | None = None, loss_nums: list | None = None, prediction_logits: torch.FloatTensor = None, seq_relationship_logits: torch.FloatTensor = None, tri_label_logits: torch.FloatTensor = None, reg_label_logits: torch.FloatTensor = None, hidden_states: Tuple[torch.FloatTensor] | None = None, attentions: Tuple[torch.FloatTensor] | None = None)[source]
Bases:
object- all_loss: list | None = None
- attentions: Tuple[FloatTensor] | None = None
- loss: FloatTensor | None = None
- loss_nums: list | None = None
- prediction_logits: FloatTensor = None
- reg_label_logits: FloatTensor = None
- seq_relationship_logits: FloatTensor = None
- tri_label_logits: FloatTensor = None