Unverified Commit 027e6524 authored by Xiaoyu Zhang's avatar Xiaoyu Zhang Committed by GitHub
Browse files

support echo=true and logprobs in openai api when logprobs=1 in lm-evaluation-harness (#1998)

parent b808a383
......@@ -498,6 +498,10 @@ def v1_generate_request(
)
prompts.append(request.prompt)
if request.echo and request.logprobs:
current_logprob_start_len = 0
else:
current_logprob_start_len = -1
sampling_params_list.append(
{
"temperature": request.temperature,
......@@ -517,7 +521,7 @@ def v1_generate_request(
}
)
return_logprobs.append(request.logprobs is not None and request.logprobs > 0)
logprob_start_lens.append(-1)
logprob_start_lens.append(current_logprob_start_len)
top_logprobs_nums.append(
request.logprobs if request.logprobs is not None else 0
)
......
......@@ -85,7 +85,9 @@ class TestOpenAIServer(unittest.TestCase):
# assert ret_num_top_logprobs == logprobs, f"{ret_num_top_logprobs} vs {logprobs}"
assert ret_num_top_logprobs > 0
assert response.choices[0].logprobs.token_logprobs[0]
# when echo=True and request.logprobs>0, logprob_start_len is 0, so the first token's logprob would be None.
if not echo:
assert response.choices[0].logprobs.token_logprobs[0]
assert response.id
assert response.created
......
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