MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / loglikelihood

Method loglikelihood

lm-eval-harness/lm_eval/api/model.py:32–54  ·  view source on GitHub ↗

Compute log-likelihood of generating a continuation from a context. Downstream tasks should attempt to use loglikelihood instead of other LM calls whenever possible. :param requests: list[Instance] A list of Instance objects, with property `args` which returns a

(self, requests)

Source from the content-addressed store, hash-verified

30
31 @abc.abstractmethod
32 def loglikelihood(self, requests) -> List[Tuple[float, bool]]:
33 """Compute log-likelihood of generating a continuation from a context.
34 Downstream tasks should attempt to use loglikelihood instead of other
35 LM calls whenever possible.
36
37 :param requests: list[Instance]
38 A list of Instance objects, with property `args` which returns a tuple (context, continuation).
39 `context: str`
40 Context string. Implementations of LM must be able to handle an
41 empty context string.
42 `continuation: str`
43 The continuation over which log likelihood will be calculated. If
44 there is a word boundary, the space should be in the continuation.
45 For example, context="hello" continuation=" world" is correct.
46
47 :return: list[tuple[float, bool]]
48 A list of pairs (logprob, isgreedy)
49 `logprob: float`
50 The log probability of `continuation`.
51 `isgreedy`:
52 Whether `continuation` would be generated by greedy sampling from `context`.
53 """
54 pass
55
56 @abc.abstractmethod
57 def loglikelihood_rolling(self, requests) -> List[Tuple[float, bool]]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected