MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / PanguAlphaModel

Class PanguAlphaModel

codegeex/mindspore/src/pangu_alpha.py:461–493  ·  view source on GitHub ↗

The PanguAlpha network consisting of two parts the backbone and the head Args: config(PanguAlphaConfig): the config of network Inputs: input_ids: the tokenized inputs input_mask: the mask indicating whether each position is a valid input past: the previou

Source from the content-addressed store, hash-verified

459
460
461class PanguAlphaModel(nn.Cell):
462 """
463 The PanguAlpha network consisting of two parts the backbone and the head
464 Args:
465 config(PanguAlphaConfig): the config of network
466 Inputs:
467 input_ids: the tokenized inputs
468 input_mask: the mask indicating whether each position is a valid input
469 past: the previous feature map
470 Returns:
471 logits: Tensor: the logits of the corresponding inputs with shape (batch_size, seq_length, vocab_size)
472 """
473
474 def __init__(self, config):
475 super(PanguAlphaModel, self).__init__()
476 # Network head to get logits over vocabulary
477 copied_parallel_config = copy.deepcopy(config.parallel_config)
478 if copied_parallel_config.pipeline_stage > 1:
479 copied_parallel_config.vocab_emb_dp = False
480 self.head = PanGuHead(
481 hidden_size=config.hidden_size,
482 parallel_config=copied_parallel_config,
483 )
484 self.head.pipeline_stage = config.parallel_config.pipeline_stage - 1
485 self.backbone = PanguAlpha_Model(config)
486 self.backbone.embedding.word_embedding.embedding_table.add_pipeline_stage(self.head.pipeline_stage)
487
488 def construct(self, input_ids, input_position, attention_mask,
489 init_reset=True, batch_valid_length=None):
490 output_states, word_table = self.backbone(input_ids, input_position, attention_mask,
491 init_reset, batch_valid_length)
492 logits = self.head(output_states, word_table)
493 return logits
494
495
496class PanGUAlphaWithLoss(Cell):

Callers 8

run_trainFunction · 0.90
run_train_pipelineFunction · 0.90
load_modelFunction · 0.90
load_modelFunction · 0.90
run_trainFunction · 0.90
load_modelFunction · 0.90
load_modelFunction · 0.90
load_modelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected