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
065bb947
Unverified
Commit
065bb947
authored
Sep 29, 2024
by
Jeffrey Fong
Committed by
GitHub
Sep 28, 2024
Browse files
Fix RuntimeEndpoint.select method (#1495)
parent
f42e9bfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
python/sglang/lang/backend/runtime_endpoint.py
python/sglang/lang/backend/runtime_endpoint.py
+13
-1
No files found.
python/sglang/lang/backend/runtime_endpoint.py
View file @
065bb947
...
@@ -244,7 +244,8 @@ class RuntimeEndpoint(BaseBackend):
...
@@ -244,7 +244,8 @@ class RuntimeEndpoint(BaseBackend):
"temperature"
:
0
,
"temperature"
:
0
,
},
},
"return_logprob"
:
True
,
"return_logprob"
:
True
,
"logprob_start_len"
:
max
(
prompt_len
-
2
,
0
),
# for token healing
"return_text_in_logprobs"
:
True
,
"logprob_start_len"
:
prompt_len
-
2
,
# For token healing
}
}
obj
=
self
.
_generate_http_request
(
s
,
data
)
obj
=
self
.
_generate_http_request
(
s
,
data
)
...
@@ -254,6 +255,17 @@ class RuntimeEndpoint(BaseBackend):
...
@@ -254,6 +255,17 @@ class RuntimeEndpoint(BaseBackend):
input_token_logprobs
=
[
r
[
"meta_info"
][
"input_token_logprobs"
]
for
r
in
obj
]
input_token_logprobs
=
[
r
[
"meta_info"
][
"input_token_logprobs"
]
for
r
in
obj
]
output_token_logprobs
=
[
r
[
"meta_info"
][
"output_token_logprobs"
]
for
r
in
obj
]
output_token_logprobs
=
[
r
[
"meta_info"
][
"output_token_logprobs"
]
for
r
in
obj
]
# Remove extra token if no token healing occurred
for
i
in
range
(
len
(
input_token_logprobs
)):
healed_token_str
=
input_token_logprobs
[
i
][
0
][
-
1
]
healed_token_logprob
=
input_token_logprobs
[
i
][
0
][
0
]
if
s
.
text_
.
endswith
(
healed_token_str
):
normalized_prompt_logprobs
[
i
]
=
(
normalized_prompt_logprobs
[
i
]
*
len
(
input_token_logprobs
[
i
])
-
healed_token_logprob
)
/
(
len
(
input_token_logprobs
[
i
])
-
1
)
input_token_logprobs
[
i
]
=
input_token_logprobs
[
i
][
1
:]
# Compute unconditional logprobs if required
# Compute unconditional logprobs if required
if
choices_method
.
requires_unconditional_logprobs
:
if
choices_method
.
requires_unconditional_logprobs
:
input_ids
=
[[
el
[
1
]
for
el
in
subl
]
for
subl
in
input_token_logprobs
]
input_ids
=
[[
el
[
1
]
for
el
in
subl
]
for
subl
in
input_token_logprobs
]
...
...
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