MCPcopy Create free account
hub / github.com/InternScience/SciReason / get_ppl_from_template

Method get_ppl_from_template

opencompass/models/base.py:163–174  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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],

Callers 2

inferenceMethod · 0.80
inferenceMethod · 0.80

Calls 2

parse_templateMethod · 0.95
get_pplMethod · 0.95

Tested by

no test coverage detected