generation/stopping_criteria
- generation/stopping_criteria
generation/stopping_criteria.StoppingCriteria
Abstract base class for all stopping criteria that can be applied during generation.
Kind: static class of generation/stopping_criteria
stoppingCriteria._call(input_ids, scores) ⇒ <code> Array. < boolean > </code>
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 ( |
generation/stopping_criteria.StoppingCriteriaList
Kind: static class of generation/stopping_criteria
new StoppingCriteriaList()
Constructs a new instance of StoppingCriteriaList
.
stoppingCriteriaList.push(item)
Adds a new stopping criterion to the list.
Kind: instance method of StoppingCriteriaList
Param | Type | Description |
---|---|---|
item | StoppingCriteria | The stopping criterion to add. |
stoppingCriteriaList.extend(items)
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. |
generation/stopping_criteria.MaxLengthCriteria
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
new MaxLengthCriteria(max_length, [max_position_embeddings])
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 |
generation/stopping_criteria.EosTokenCriteria
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
- .EosTokenCriteria
new EosTokenCriteria(eos_token_id)
._call(input_ids, scores)
⇒Array.<boolean>
new EosTokenCriteria(eos_token_id)
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. |
eosTokenCriteria._call(input_ids, scores) ⇒ <code> Array. < boolean > </code>
Kind: instance method of EosTokenCriteria
Param | Type |
---|---|
input_ids | Array.<Array<number>> |
scores | Array.<Array<number>> |
generation/stopping_criteria.InterruptableStoppingCriteria
This class can be used to stop generation whenever the user interrupts the process.
Kind: static class of generation/stopping_criteria
< > Update on GitHub