Get perplexity given a list of templates. Args: templates (List[PromptType]): A list of templates. mask_length (List[int]): A list of mask lengths. If provided, the perplexity will be calculated only on the unmasked tokens.
(self,
templates: List[PromptType],
mask_length=None)
| 161 | return self.template_parser.parse_template(prompt_template, mode) |
| 162 | |
| 163 | def get_ppl_from_template(self, |
| 164 | templates: List[PromptType], |
| 165 | mask_length=None): |
| 166 | """Get perplexity given a list of templates. |
| 167 | |
| 168 | Args: |
| 169 | templates (List[PromptType]): A list of templates. |
| 170 | mask_length (List[int]): A list of mask lengths. If provided, the |
| 171 | perplexity will be calculated only on the unmasked tokens. |
| 172 | """ |
| 173 | inputs = self.parse_template(templates, mode='ppl') |
| 174 | return self.get_ppl(inputs, mask_length) |
| 175 | |
| 176 | def get_ppl_tokenwise_from_template(self, |
| 177 | templates: List[PromptType], |
no test coverage detected