mindformers.models.t5.T5ForConditionalGeneration

class mindformers.models.t5.T5ForConditionalGeneration(config: mindformers.models.t5.t5_config.T5Config)[源代码]

A T5 model with the loss added.

参数

config (T5Config) – The network of the transformer.

实际案例

>>> from mindformers import T5ForConditionalGeneration, T5Tokenizer
>>> model = T5ForConditionalGeneration.from_pretrained('t5_small')
>>> tokenizer = T5Tokenizer.from_pretrained('t5_small')
>>> src_output = tokenizer(["hello world"], padding='max_length', max_length=model.config.seq_length,
...                        return_tensors='ms')
>>> model_input = tokenizer(["So happy to see you!"], padding='max_length',
...                         max_length=model.config.max_decode_length,
...                         return_tensors='ms')["input_ids"]
>>> input_ids = src_output['input_ids']
>>> attention_mask = src_output['attention_mask']
>>> output = model(input_ids, attention_mask, model_input)
>>> print(output)
[5.64458]
encoder_forward(source_ids, source_mask)[源代码]

Execute the encoder forward process