Commit b011af90 authored by Matt Hoffner's avatar Matt Hoffner
Browse files

push recommended diff from @gardner

parent 85d3b8d1
...@@ -36,7 +36,7 @@ class GGMLLM(BaseLM): ...@@ -36,7 +36,7 @@ class GGMLLM(BaseLM):
logger.error(f"RequestException: {e}") logger.error(f"RequestException: {e}")
time.sleep(delay) # wait before retrying time.sleep(delay) # wait before retrying
else: else:
raise Exception(f"Failed to get a valid response after {retries} retries. Last exception: {e}") raise Exception(f"Failed to get a valid response after {retries} retries.")
def loglikelihood(self, requests): def loglikelihood(self, requests):
...@@ -44,11 +44,11 @@ class GGMLLM(BaseLM): ...@@ -44,11 +44,11 @@ class GGMLLM(BaseLM):
return [] return []
res = [] res = []
for context, continuation in tqdm(requests): for context, continuation in tqdm(requests):
response = self.ggml_completion(self.base_url, context=context, continuation=continuation) response = self.ggml_completion(context=context, continuation=continuation)
if response and "choices" in response and response["choices"]: if response and "choices" in response and response["choices"]:
choice = response["choices"][0] choice = response["choices"][0]
logprobs = choice.get("logprobs") logprobs = choice.get("logprobs")
if logprobs and "token_logprobs" in logprobs: if logprobs and "token_logprobs" in logprobs and logprobs["token_logprobs"]:
logprob = logprobs["token_logprobs"][0] logprob = logprobs["token_logprobs"][0]
is_greedy = choice["finish_reason"] == "length" is_greedy = choice["finish_reason"] == "length"
res.append((logprob, is_greedy)) res.append((logprob, is_greedy))
...@@ -69,7 +69,7 @@ class GGMLLM(BaseLM): ...@@ -69,7 +69,7 @@ class GGMLLM(BaseLM):
inp = request[0] inp = request[0]
request_args = request[1] request_args = request[1]
until = request_args["until"] until = request_args["until"]
response = self.ggml_completion(self.base_url, context=inp, stop=until) response = self.ggml_completion(context=inp, stop=until)
if response and "choices" in response and response["choices"]: if response and "choices" in response and response["choices"]:
choice = response["choices"][0] choice = response["choices"][0]
if "text" in choice: if "text" in choice:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment