Abstract base class for all stopping criteria that can be applied during generation.
Kind: static class of generation/stopping_criteria
Kind: instance method of StoppingCriteria
Returns: Array.<boolean>
- A list of booleans indicating whether each sequence should be stopped.
Param | Type | Description |
---|---|---|
input_ids | Array.<Array<number>> | ( |
scores | Array.<Array<number>> | scores ( |
Kind: static class of generation/stopping_criteria
Constructs a new instance of StoppingCriteriaList
.
Adds a new stopping criterion to the list.
Kind: instance method of StoppingCriteriaList
Param | Type | Description |
---|---|---|
item | StoppingCriteria | The stopping criterion to add. |
Adds multiple stopping criteria to the list.
Kind: instance method of StoppingCriteriaList
Param | Type | Description |
---|---|---|
items | StoppingCriteria | StoppingCriteriaList | Array<StoppingCriteria> | The stopping criteria to add. |
This class can be used to stop generation whenever the full generated number of tokens exceeds max_length
.
Keep in mind for decoder-only type of transformers, this will include the initial prompted tokens.
Kind: static class of generation/stopping_criteria
Param | Type | Default | Description |
---|---|---|---|
max_length | number | The maximum length that the output sequence can have in number of tokens. | |
[max_position_embeddings] | number |
| The maximum model length, as defined by the model's |
This class can be used to stop generation whenever the “end-of-sequence” token is generated.
By default, it uses the model.generation_config.eos_token_id
.
Kind: static class of generation/stopping_criteria
new EosTokenCriteria(eos_token_id)
._call(input_ids, scores)
⇒ Array.<boolean>
Param | Type | Description |
---|---|---|
eos_token_id | number | Array<number> | The id of the end-of-sequence token. Optionally, use a list to set multiple end-of-sequence tokens. |
Kind: instance method of EosTokenCriteria
Param | Type |
---|---|
input_ids | Array.<Array<number>> |
scores | Array.<Array<number>> |
This class can be used to stop generation whenever the user interrupts the process.
Kind: static class of generation/stopping_criteria