backprop.models.hf_seq2seq_tg_model package

backprop.models.hf_seq2seq_tg_model.model

class HFSeq2SeqTGModel(model_path=None, tokenizer_path=None, name: Optional[str] = None, description: Optional[str] = None, details: Optional[Dict] = None, tasks: Optional[List[str]] = None, model_class=<class 'transformers.models.auto.modeling_auto.AutoModelForSeq2SeqLM'>, tokenizer_class=<class 'transformers.models.auto.tokenization_auto.AutoTokenizer'>, device=None)[source]

Bases: backprop.models.generic_models.HFTextGenerationModel

Class for Hugging Face causal Seq2Seq generation models.

model_path

path to HF model

tokenizer_path

path to HF tokenizer

name

string identifier for the model. Lowercase letters and numbers. No spaces/special characters except dashes.

description

String description of the model.

tasks

List of supported task strings

details

Dictionary of additional details about the model

model_class

Class used to initialise model

tokenizer_class

Class used to initialise tokenizer

device

Device for model. Defaults to “cuda” if available.

__call__(task_input, task='text-generation')[source]

Uses the model for the text-generation task

Parameters
  • task_input – input dictionary according to the text-generation task specification

  • task – text-generation

encode_input(text, max_length=128)[source]
encode_output(text, max_length=32)[source]
static list_models()[source]
process_batch(params, task)[source]
training: bool
training_step(task_input)[source]

backprop.models.hf_seq2seq_tg_model.models_list