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
OpenDAS
text-generation-inference
Commits
20ee71dc
Commit
20ee71dc
authored
Oct 11, 2023
by
OlivierDehaene
Browse files
fix: force one of max_new_tokens or truncate with slow tokenizer
parent
dd304cf1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
router/src/validation.rs
router/src/validation.rs
+8
-2
No files found.
router/src/validation.rs
View file @
20ee71dc
...
...
@@ -116,12 +116,16 @@ impl Validation {
// In this case, we don't know the real length in tokens of the inputs
// However, the inputs will be truncated by the python servers
// We make sure that truncate + max_new_tokens <= self.max_total_tokens
let
input_length
=
truncate
.unwrap_or
(
self
.max_input_length
);
let
max_new_tokens
:
u32
=
if
let
Some
(
max_new_tokens
)
=
max_new_tokens
{
max_new_tokens
}
else
{
self
.max_total_tokens
.saturating_sub
(
input_length
)
as
u32
if
let
Some
(
truncate
)
=
truncate
{
self
.max_total_tokens
.saturating_sub
(
truncate
)
as
u32
}
else
{
return
Err
(
ValidationError
::
UnsetMaxNewTokens
)
}
};
let
input_length
=
truncate
.unwrap_or
(
self
.max_input_length
);
// Validate MaxNewTokens
if
(
input_length
as
u32
+
max_new_tokens
)
>
self
.max_total_tokens
as
u32
{
...
...
@@ -393,6 +397,8 @@ pub enum ValidationError {
Truncate
(
usize
,
usize
),
#[error(
"`typical_p` must be > 0.0 and < 1.0"
)]
TypicalP
,
#[error(
"one of `max_new_tokens` or `truncate` must be set if a fast tokenizer is not in use"
)]
UnsetMaxNewTokens
,
#[error(
"`max_new_tokens` must be strictly positive"
)]
NegativeMaxNewTokens
,
#[error(
"`max_new_tokens` must be <= {0}. Given: {1}"
)]
...
...
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