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
jerrrrry
infinilm
Commits
1be6559f
Commit
1be6559f
authored
Feb 02, 2026
by
Ceng23333
Browse files
skip responding eos token
Signed-off-by:
Ceng23333
<
441651826@qq.com
>
parent
1ff7856a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
python/infinilm/server/inference_server.py
python/infinilm/server/inference_server.py
+24
-8
test/bench/test_benchmark.py
test/bench/test_benchmark.py
+1
-1
No files found.
python/infinilm/server/inference_server.py
View file @
1be6559f
...
...
@@ -293,14 +293,22 @@ class InferenceServer:
req
.
mark_canceled
()
break
# Send token
chunk
=
json
.
dumps
(
chunk_json
(
request_id
,
content
=
token_output
.
token_text
,
model
=
self
.
model_id
),
ensure_ascii
=
False
,
# Skip EOS token text for OpenAI API compatibility
# Check if this token is an EOS token by comparing token_id with eos_token_ids
eos_token_ids
=
self
.
engine
.
engine
.
eos_token_ids
is_eos_token
=
(
eos_token_ids
and
token_output
.
token_id
in
eos_token_ids
)
yield
f
"data:
{
chunk
}
\n\n
"
if
not
is_eos_token
and
token_output
.
token_text
:
# Send token
chunk
=
json
.
dumps
(
chunk_json
(
request_id
,
content
=
token_output
.
token_text
,
model
=
self
.
model_id
),
ensure_ascii
=
False
,
)
yield
f
"data:
{
chunk
}
\n\n
"
if
token_output
.
finished
:
finish_reason
=
self
.
_convert_finish_reason
(
...
...
@@ -374,7 +382,15 @@ class InferenceServer:
req
.
mark_canceled
()
break
output_text
+=
token_output
.
token_text
# Skip EOS token text for OpenAI API compatibility
# Check if this token is an EOS token by comparing token_id with eos_token_ids
eos_token_ids
=
self
.
engine
.
engine
.
eos_token_ids
is_eos_token
=
(
eos_token_ids
and
token_output
.
token_id
in
eos_token_ids
)
if
not
is_eos_token
:
output_text
+=
token_output
.
token_text
if
token_output
.
finished
:
break
...
...
test/bench/test_benchmark.py
View file @
1be6559f
...
...
@@ -4,7 +4,6 @@ import argparse
import
time
import
re
import
csv
from
datasets
import
load_dataset
,
Dataset
import
numpy
as
np
import
infinicore
from
infinilm.modeling_utils
import
load_model_state_dict_by_file
...
...
@@ -12,6 +11,7 @@ from infinilm.distributed import DistConfig
from
infinilm.cache
import
StaticKVCacheConfig
from
infinilm.infer_engine
import
GenerationConfig
,
InferEngine
from
infinilm.cache
import
StaticKVCacheConfig
from
datasets
import
load_dataset
,
Dataset
from
abc
import
ABC
,
abstractmethod
...
...
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