Callbacks for predicting within AdaptNLP using the fastai framework

class GatherInputsCallback[source]

GatherInputsCallback(after_create=None, before_fit=None, before_epoch=None, before_train=None, before_batch=None, after_pred=None, after_loss=None, before_backward=None, before_step=None, after_cancel_step=None, after_step=None, after_cancel_batch=None, after_batch=None, after_cancel_train=None, after_train=None, before_validate=None, after_cancel_validate=None, after_validate=None, after_cancel_epoch=None, after_epoch=None, after_cancel_fit=None, after_fit=None) :: Callback

Prepares basic input dictionary for HuggingFace Transformers

This Callback generates a very basic dictionary consisting of input_ids, attention_masks, and token_type_ids, and saves it to the attribute self.learn.inputs.

If further data is expected or needed from the batch, the additional Callback(s) should have an order of -2

class SetInputsCallback[source]

SetInputsCallback(as_dict=False) :: Callback

Callback which runs after GatherInputsCallback that sets self.learn.xb

class GeneratorCallback[source]

GeneratorCallback(num_beams:int, min_length:int, max_length:int, early_stopping:bool, input_ids:Optional[LongTensor]=None, do_sample:Optional[bool]=None, temperature:Optional[float]=None, top_k:Optional[int]=None, top_p:Optional[float]=None, repetition_penalty:Optional[float]=None, bad_words_ids:Optional[Iterable[int]]=None, bos_token_id:Optional[int]=None, pad_token_id:Optional[int]=None, eos_token_id:Optional[int]=None, length_penalty:Optional[float]=None, no_repeat_ngram_size:Optional[int]=None, encoder_no_repeat_ngram_size:Optional[int]=None, num_return_sequences:Optional[int]=None, max_time:Optional[float]=None, max_new_tokens:Optional[int]=None, decoder_start_token_id:Optional[int]=None, use_cache:Optional[bool]=None, num_beam_groups:Optional[int]=None, diversity_penalty:Optional[float]=None, prefix_allowed_tokens_fn:Optional[Callable[int, Tensor, List[int]]]=None, output_attentions:Optional[bool]=None, output_hidden_states:Optional[bool]=None, output_scores:Optional[bool]=None, return_dict_in_generate:Optional[bool]=None, forced_bos_token_id:Optional[int]=None, forced_eos_token_id:Optional[int]=None, remove_invalid_values:Optional[bool]=None, synced_gpus:Optional[bool]=None) :: Callback

Callback used for models that utilize self.model.generate