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

Method loglikelihood

lm-eval-harness/lm_eval/models/textsynth.py:98–120  ·  view source on GitHub ↗
(self, requests)

Source from the content-addressed store, hash-verified

96 raise NotImplementedError()
97
98 def loglikelihood(self, requests):
99 res = []
100 for context, continuation in tqdm(requests):
101 response = textsynth_completion(
102 url=self.api_url + "/v1/engines/" + self.engine + "/logprob",
103 headers={"Authorization": "Bearer " + self.api_key},
104 json={"context": context, "continuation": continuation},
105 )
106 resp = response.json()
107 if "logprob" in resp:
108 logprob = resp["logprob"]
109 is_greedy = resp["is_greedy"]
110 res.append((logprob, is_greedy))
111
112 self.cache_hook.add_partial(
113 "loglikelihood", (context, continuation), (logprob, is_greedy)
114 )
115 else:
116 logger.error(
117 f"The following response does not contain `logprobs`. Got:\n{resp}"
118 )
119 assert False
120 return res
121
122 def loglikelihood_rolling(self, requests):
123 # TODO: The TextSynth API does not support tokenized inputs so we cannot

Callers

nothing calls this directly

Calls 2

textsynth_completionFunction · 0.85
add_partialMethod · 0.80

Tested by

no test coverage detected