Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
027e6524
Unverified
Commit
027e6524
authored
Nov 12, 2024
by
Xiaoyu Zhang
Committed by
GitHub
Nov 11, 2024
Browse files
support echo=true and logprobs in openai api when logprobs=1 in lm-evaluation-harness (#1998)
parent
b808a383
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
python/sglang/srt/openai_api/adapter.py
python/sglang/srt/openai_api/adapter.py
+5
-1
test/srt/test_openai_server.py
test/srt/test_openai_server.py
+3
-1
No files found.
python/sglang/srt/openai_api/adapter.py
View file @
027e6524
...
...
@@ -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
)
...
...
test/srt/test_openai_server.py
View file @
027e6524
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment