Seq2SeqTask¶
- class flash.text.seq2seq.core.model.Seq2SeqTask(backbone='t5-small', tokenizer_kwargs=None, max_source_length=128, max_target_length=128, padding='max_length', loss_fn=None, optimizer='Adam', lr_scheduler=None, metrics=None, learning_rate=None, num_beams=None, enable_ort=False, output_transform=None)[source]¶
General Task for Sequence2Sequence.
- Parameters
max_source_length¶ (
int
) – The maximum length to pad / truncate input sequences to.max_target_length¶ (
int
) – The maximum length to pad / truncate target sequences to.padding¶ (
Union
[str
,bool
]) – The type of padding to apply. One of: “longest” orTrue
, “max_length”, “do_not_pad” orFalse
.loss_fn¶ (
Optional
[TypeVar
(LOSS_FN_TYPE
,Callable
,Mapping
,Sequence
,None
)]) – Loss function for trainingoptimizer¶ (
TypeVar
(OPTIMIZER_TYPE
,str
,Callable
,Tuple
[str
,Dict
[str
,Any
]],None
)) – Optimizer to use for training.lr_scheduler¶ (
Optional
[TypeVar
(LR_SCHEDULER_TYPE
,str
,Callable
,Tuple
[str
,Dict
[str
,Any
]],Tuple
[str
,Dict
[str
,Any
],Dict
[str
,Any
]],None
)]) – The LR scheduler to use during training.metrics¶ (
Optional
[TypeVar
(METRICS_TYPE
,Metric
,Mapping
,Sequence
,None
)]) – Metrics to compute for training and evaluation. Changing this argument currently has no effectlearning_rate¶ (
Optional
[float
]) – Learning rate to use for training, defaults to 3e-4num_beams¶ (
Optional
[int
]) – Number of beams to use in validation when generating predictions. Defaults to 4enable_ort¶ (
bool
) – Enable Torch ONNX Runtime Optimization: https://onnxruntime.ai/docs/#onnx-runtime-for-training
- classmethod available_finetuning_strategies(cls)¶
Returns a list containing the keys of the available Finetuning Strategies.
- classmethod available_lr_schedulers(cls)¶
Returns a list containing the keys of the available LR schedulers.
- classmethod available_optimizers(cls)¶
Returns a list containing the keys of the available Optimizers.
- classmethod available_outputs(cls)¶
Returns the list of available outputs (that can be used during prediction or serving) for this
Task
.Examples
..testsetup:
>>> from flash import Task
>>> print(Task.available_outputs()) ['preds', 'raw']