MCPcopy Create free account
hub / github.com/THUDM/LongWriter / __init__

Method __init__

train/patch/modeling_llama.py:923–937  ·  view source on GitHub ↗
(self, config: LlamaConfig)

Source from the content-addressed store, hash-verified

921 """
922
923 def __init__(self, config: LlamaConfig):
924 super().__init__(config)
925 self.padding_idx = config.pad_token_id
926 self.vocab_size = config.vocab_size
927
928 self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
929 self.layers = nn.ModuleList(
930 [LlamaDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
931 )
932 self.norm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
933 self.rotary_emb = LlamaRotaryEmbedding(config=config)
934 self.gradient_checkpointing = False
935
936 # Initialize weights and apply final processing
937 self.post_init()
938
939 def get_input_embeddings(self):
940 return self.embed_tokens

Callers

nothing calls this directly

Calls 4

LlamaDecoderLayerClass · 0.85
LlamaRMSNormClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected